Skip to content

Commit

Permalink
balloons: fix unit tests
Browse files Browse the repository at this point in the history
CPUTopologyLevel is now a cfgapi type, there is no more custom parser
to be tested.

Signed-off-by: Antti Kervinen <[email protected]>
  • Loading branch information
askervin authored and klihub committed Nov 30, 2023
1 parent ccd229f commit 6f2781b
Showing 1 changed file with 1 addition and 44 deletions.
45 changes: 1 addition & 44 deletions cmd/plugins/balloons/policy/cputree_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ func TestWalk(t *testing.T) {
foundLevel := CPUTopologyLevelUndefined
rv := tree.DepthFirstWalk(func(tn *cpuTreeNode) error {
foundName = tn.name
foundLevel = tn.level
foundLevel = string(tn.level)
return nil
})
if rv != nil {
Expand Down Expand Up @@ -669,49 +669,6 @@ func TestCpuLocations(t *testing.T) {
}
}

func TestCPUTopologyLevel(t *testing.T) {
var lvl CPUTopologyLevel
if lvl != CPUTopologyLevelUndefined {
t.Errorf("unexpected default inital value for lvl: %s, expected undefined", lvl)
}
if err := lvl.UnmarshalJSON([]byte("\"\"")); err != nil || lvl != CPUTopologyLevelUndefined {
t.Errorf("unexpected outcome unmarshalling topology level: \"\", error: %s, result: %s", err, lvl)
}
if err := lvl.UnmarshalJSON([]byte("\"system\"")); err != nil || lvl != CPUTopologyLevelSystem {
t.Errorf("unexpected outcome unmarshalling topology level: system, error: %s, result: %s", err, lvl)
}
if err := lvl.UnmarshalJSON([]byte("\"NUMA\"")); err != nil || lvl != CPUTopologyLevelNuma {
t.Errorf("unexpected outcome unmarshalling topology level: \"NUMA\", error: %s, result: %s", err, lvl)
}
if err := lvl.UnmarshalJSON([]byte("\"undefined\"")); err == nil {
t.Errorf("unexpected outcome unmarshalling topology level: \"undefined\", error: %s, result: %s", err, lvl)
}
if err := lvl.UnmarshalJSON([]byte("system")); err == nil {
t.Errorf("unexpected non-error outcome unmarshalling topology level: system, error: %s, result: %s", err, lvl)
}
if err := lvl.UnmarshalJSON([]byte("0")); err == nil {
t.Errorf("unexpected non-error outcome unmarshalling topology level: 0, error: %s, result: %s", err, lvl)
}
if err := lvl.UnmarshalJSON([]byte("\"4\"")); err == nil {
t.Errorf("unexpected non-error outcome unmarshalling topology level: \"0\", error: %s, result: %s", err, lvl)
}
if undefBytes, err := CPUTopologyLevelUndefined.MarshalJSON(); err != nil {
t.Errorf("unexpected error marshaling undefined: %s", err)
} else {
if err = lvl.UnmarshalJSON(undefBytes); err != nil || lvl != CPUTopologyLevelUndefined {
t.Errorf("unexpected outcome unmarshaling marshaled undefined: error: %s, result: %s", err, lvl)
}
}
if threadBytes, err := CPUTopologyLevelThread.MarshalJSON(); err != nil {
t.Errorf("unexpected error marshaling thread: %s", err)
} else {
if err = lvl.UnmarshalJSON(threadBytes); err != nil || lvl != CPUTopologyLevelThread {
t.Errorf("unexpected outcome unmarshaling marshaled thread: error: %s, result: %s", err, lvl)
}
}

}

func TestSplitLevel(t *testing.T) {
root, _ := newCpuTreeFromInt5([5]int{2, 2, 2, 4, 2})
newRoot := root.SplitLevel(CPUTopologyLevelNuma,
Expand Down

0 comments on commit 6f2781b

Please sign in to comment.