File: default_linux_test.go

package info (click to toggle)
golang-github-containers-common 0.64.1%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,932 kB
  • sloc: makefile: 132; sh: 111
file content (35 lines) | stat: -rw-r--r-- 659 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package config

import (
	"errors"
	"os"
	"path/filepath"
	"strings"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestDefaultMaskedPaths(t *testing.T) {
	maskedPaths, err := getMaskedPaths()
	assert.NoError(t, err)

	root := "/sys/devices/system/cpu"

	entries, err := os.ReadDir(root)
	assert.NoError(t, err)

	for _, entry := range entries {
		if !strings.HasPrefix(entry.Name(), "cpu") {
			continue
		}
		path := filepath.Join(root, entry.Name(), "thermal_throttle")
		if _, err := os.Stat(path); err != nil {
			if errors.Is(err, os.ErrNotExist) {
				continue
			}
			assert.NoError(t, err)
		}
		assert.Contains(t, maskedPaths, path)
	}
}