From bcd25c805a5dcb2f6c1c7967e908c06737c66058 Mon Sep 17 00:00:00 2001 From: Renan DelValle Date: Fri, 17 Jan 2020 09:43:34 -0800 Subject: [PATCH] Renaming variable in test. --- rapl-daemon/util.go | 3 +-- rapl-daemon/util_test.go | 17 ++++++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/rapl-daemon/util.go b/rapl-daemon/util.go index 4207e8f..1d86483 100644 --- a/rapl-daemon/util.go +++ b/rapl-daemon/util.go @@ -61,8 +61,7 @@ func capNode(base string, percentage int) error { return nil } -// maxPower returns the value in float of the maximum watts a power zone -// can use. +// maxPower returns the value in float of the maximum watts a power zone can use. func maxPower(maxFile string) (uint64, error) { maxPower, err := ioutil.ReadFile(maxFile) if err != nil { diff --git a/rapl-daemon/util_test.go b/rapl-daemon/util_test.go index ffada72..5e26faa 100644 --- a/rapl-daemon/util_test.go +++ b/rapl-daemon/util_test.go @@ -35,12 +35,12 @@ func TestMain(m *testing.M) { initialWatts := strconv.FormatUint(maxWattage, 10) - err = ioutil.WriteFile(filepath.Join(zonePath, maxPowerFileShortWindow), []byte(initialWatts), 0444) + err = ioutil.WriteFile(filepath.Join(zonePath, maxPowerFileLongWindow), []byte(initialWatts), 0444) if err != nil { log.Fatal(err) } - err = ioutil.WriteFile(filepath.Join(zonePath, powerLimitFileShortWindow), []byte(initialWatts), 0644) + err = ioutil.WriteFile(filepath.Join(zonePath, powerLimitFileLongWindow), []byte(initialWatts), 0644) if err != nil { log.Fatal(err) } @@ -48,30 +48,29 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -// TODO(rdelvalle): Create filesystem only once and allow tests to use it func TestCapNode(t *testing.T) { err := capNode(raplDir, 95) assert.NoError(t, err) - t.Run("badPercentage", func(t *testing.T) { + t.Run("bad-percentage", func(t *testing.T) { err := capNode(raplDir, 1000) assert.Error(t, err) }) - t.Run("zeroPercent", func(t *testing.T) { + t.Run("zero-percent", func(t *testing.T) { err := capNode(raplDir, 0) assert.Error(t, err) }) } func TestMaxPower(t *testing.T) { - maxFile := filepath.Join(raplDir, raplPrefixCPU+":0", maxPowerFileShortWindow) + maxFile := filepath.Join(raplDir, raplPrefixCPU+":0", maxPowerFileLongWindow) maxWatts, err := maxPower(maxFile) assert.NoError(t, err) assert.Equal(t, maxWattage, maxWatts) - t.Run("nameDoesNotExist", func(t *testing.T) { + t.Run("name-does-not-exist", func(t *testing.T) { _, err := maxPower("madeupname") assert.Error(t, err) }) @@ -81,7 +80,7 @@ func TestCapZone(t *testing.T) { const percentage float64 = .50 powercap := uint64(math.Ceil(float64(maxWattage) * percentage)) - limitFile := filepath.Join(raplDir, raplPrefixCPU+":0", powerLimitFileShortWindow) + limitFile := filepath.Join(raplDir, raplPrefixCPU+":0", powerLimitFileLongWindow) err := capZone(limitFile, powercap) assert.NoError(t, err) @@ -92,7 +91,7 @@ func TestCapZone(t *testing.T) { assert.NoError(t, err) assert.Equal(t, powercap, newCap) - t.Run("nameDoesNotExist", func(t *testing.T) { + t.Run("name-does-not-exist", func(t *testing.T) { err := capZone("madeupname", powercap) assert.Error(t, err) })