Skip to content

Commit

Permalink
cgroups: add test for disable oom killer
Browse files Browse the repository at this point in the history
Signed-off-by: Hu Keping <hukeping@huawei.com>
  • Loading branch information
HuKeping committed Mar 6, 2015
1 parent 295c708 commit 4332ffc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cgroups/fs/memory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,30 @@ func TestMemoryStatsBadMaxUsageFile(t *testing.T) {
t.Fatal("Expected failure")
}
}

func TestMemorySetOomControl(t *testing.T) {
helper := NewCgroupTestUtil("memory", t)
defer helper.cleanup()

const (
oom_kill_disable = 1 // disable oom killer, default is 0
)

helper.writeFileContents(map[string]string{
"memory.oom_control": strconv.Itoa(oom_kill_disable),
})

memory := &MemoryGroup{}
if err := memory.Set(helper.CgroupPath, helper.CgroupData.c); err != nil {
t.Fatal(err)
}

value, err := getCgroupParamUint(helper.CgroupPath, "memory.oom_control")
if err != nil {
t.Fatalf("Failed to parse memory.oom_control - %s", err)
}

if value != oom_kill_disable {
t.Fatalf("Got the wrong value, set memory.oom_control failed.")
}
}

0 comments on commit 4332ffc

Please sign in to comment.