Skip to content

Commit

Permalink
Add test for cgroups load when missing hierarchy in one subsystem
Browse files Browse the repository at this point in the history
Signed-off-by: MichaelKatsoulis <michaelkatsoulis88@gmail.com>
  • Loading branch information
MichaelKatsoulis committed Nov 2, 2018
1 parent f6cbfb4 commit 7d825b2
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions cgroup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,20 @@ func checkTaskid(mock *mockCgroup, path string, expected int) error {
return nil
}

func mockNewNotInRdma(subsystems []Subsystem, path Path, resources *specs.LinuxResources) (Cgroup, error) {
for _, s := range subsystems {
if s.Name() != Rdma {
if err := initializeSubsystem(s, path, resources); err != nil {
return nil, err
}
}
}
return &cgroup{
path: path,
subsystems: subsystems,
}, nil
}

func TestLoad(t *testing.T) {
mock, err := newMock()
if err != nil {
Expand All @@ -218,6 +232,36 @@ func TestLoad(t *testing.T) {
}
}

func TestLoadWithMissingSubsystems(t *testing.T) {
mock, err := newMock()
if err != nil {
t.Fatal(err)
}
defer mock.delete()
subsystems, err := mock.hierarchy()
if err != nil {
t.Error(err)
return
}
control, err := mockNewNotInRdma(subsystems, StaticPath("test"), &specs.LinuxResources{})
if err != nil {
t.Error(err)
return
}
if control, err = Load(mock.hierarchy, StaticPath("test")); err != nil {
t.Error(err)
return
}
if control == nil {
t.Error("control is nil")
return
}
if len(control.Subsystems()) != len(subsystems) - 1 {
t.Error("wrong number of active subsystems")
return
}
}

func TestDelete(t *testing.T) {
mock, err := newMock()
if err != nil {
Expand Down

0 comments on commit 7d825b2

Please sign in to comment.