fix slice sharing bug in cgroup manager

This commit is contained in:
David Ashpole
2018-11-05 17:42:42 -08:00
parent 7ac1f8974b
commit d4f6ae3615
2 changed files with 29 additions and 1 deletions

View File

@@ -20,9 +20,34 @@ package cm
import (
"path"
"reflect"
"testing"
)
// TestNewCgroupName tests confirms that #68416 is fixed
func TestNewCgroupName(t *testing.T) {
a := ParseCgroupfsToCgroupName("/a/")
ab := NewCgroupName(a, "b")
expectedAB := CgroupName([]string{"a", "", "b"})
if !reflect.DeepEqual(ab, expectedAB) {
t.Errorf("Expected %d%+v; got %d%+v", len(expectedAB), expectedAB, len(ab), ab)
}
abc := NewCgroupName(ab, "c")
expectedABC := CgroupName([]string{"a", "", "b", "c"})
if !reflect.DeepEqual(abc, expectedABC) {
t.Errorf("Expected %d%+v; got %d%+v", len(expectedABC), expectedABC, len(abc), abc)
}
_ = NewCgroupName(ab, "d")
if !reflect.DeepEqual(abc, expectedABC) {
t.Errorf("Expected %d%+v; got %d%+v", len(expectedABC), expectedABC, len(abc), abc)
}
}
func TestCgroupNameToSystemdBasename(t *testing.T) {
testCases := []struct {
input CgroupName