machine, topology_test: not read system file

GetClockSpeed() uses the information from the file
/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq when it exists.

Make sure it is not used for tests.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano 2020-05-06 09:23:14 +02:00
parent 414043db03
commit bf311ce408
No known key found for this signature in database
GPG Key ID: E4730F97F60286ED
2 changed files with 3 additions and 1 deletions

View File

@ -50,9 +50,9 @@ var (
isMemoryController = regexp.MustCompile("mc[0-9]+")
isDimm = regexp.MustCompile("dimm[0-9]+")
machineArch = getMachineArch()
maxFreqFile = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
)
const maxFreqFile = "/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq"
const sysFsCPUCoreID = "core_id"
const sysFsCPUPhysicalPackageID = "physical_package_id"
const sysFsCPUTopology = "topology"

View File

@ -393,6 +393,7 @@ func TestMemoryInfoOnArchThatDoNotExposeMemoryController(t *testing.T) {
}
func TestClockSpeedOnCpuUpperCase(t *testing.T) {
maxFreqFile = "" // do not read the system max frequency
machineArch = "" // overwrite package variable
testfile := "./testdata/cpuinfo_upper_case" // mock cpuinfo with CPU MHz
@ -407,6 +408,7 @@ func TestClockSpeedOnCpuUpperCase(t *testing.T) {
}
func TestClockSpeedOnCpuLowerCase(t *testing.T) {
maxFreqFile = "" // do not read the system max frequency
machineArch = "" // overwrite package variable
testfile := "./testdata/cpuinfo_lower_case" // mock cpuinfo with cpu MHz