Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Fix unit tests not running as non-root user on linux
Browse files Browse the repository at this point in the history
  • Loading branch information
KingKoopasGoomba committed Jul 26, 2022
1 parent c591423 commit 65db5f3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/power/c_states_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,17 +23,17 @@ func setupCoreCStatesTests(cpufiles map[string]map[string]map[string]string) fun

for cpu, states := range cpufiles {
if cpu == "driver" {
os.MkdirAll(filepath.Join(basePath, strings.Split(cStatesDrvPath, "/")[0]), 0644)
os.MkdirAll(filepath.Join(basePath, strings.Split(cStatesDrvPath, "/")[0]), os.ModePerm)
for driver := range states {
os.WriteFile(filepath.Join(basePath, cStatesDrvPath), []byte(driver), 0644)
break
}
continue
}
cpuStatesDir := filepath.Join(basePath, cpu, cStatesDir)
os.MkdirAll(filepath.Join(cpuStatesDir), 0644)
os.MkdirAll(filepath.Join(cpuStatesDir), os.ModePerm)
for state, props := range states {
os.Mkdir(filepath.Join(cpuStatesDir, state), 0644)
os.Mkdir(filepath.Join(cpuStatesDir, state), os.ModePerm)
for propFile, value := range props {
os.WriteFile(filepath.Join(cpuStatesDir, state, propFile), []byte(value), 0644)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/power/core_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func setupCoreTests(cpufiles map[string]map[string]string) func() {

for cpuName, cpuDetails := range cpufiles {
cpudir := filepath.Join(basePath, cpuName)
os.MkdirAll(filepath.Join(cpudir, "cpufreq"), 0644)
os.MkdirAll(filepath.Join(cpudir, "cpufreq"), os.ModePerm)
os.WriteFile(filepath.Join(cpudir, scalingDrvFile), []byte("intel_pstate\n"), 0664)
for prop, value := range cpuDetails {
switch prop {
Expand Down

0 comments on commit 65db5f3

Please sign in to comment.