libcontainer: cgroups: add tests for pids.max == "max"

Signed-off-by: Aleksa Sarai <asarai@suse.de>
This commit is contained in:
Aleksa Sarai 2016-03-14 18:08:47 +11:00
parent 087b953dc5
commit a6d5179f60
1 changed files with 26 additions and 2 deletions

View File

@ -81,7 +81,31 @@ func TestPidsStats(t *testing.T) {
t.Fatalf("Expected %d, got %d for pids.current", 1337, stats.PidsStats.Current) t.Fatalf("Expected %d, got %d for pids.current", 1337, stats.PidsStats.Current)
} }
if stats.PidsStats.Max != maxLimited { if stats.PidsStats.Limit != maxLimited {
t.Fatalf("Expected %d, got %d for pids.max", maxLimited, stats.PidsStats.Max) t.Fatalf("Expected %d, got %d for pids.max", maxLimited, stats.PidsStats.Limit)
}
}
func TestPidsStatsUnlimited(t *testing.T) {
helper := NewCgroupTestUtil("pids", t)
defer helper.cleanup()
helper.writeFileContents(map[string]string{
"pids.current": strconv.Itoa(4096),
"pids.max": "max",
})
pids := &PidsGroup{}
stats := *cgroups.NewStats()
if err := pids.GetStats(helper.CgroupPath, &stats); err != nil {
t.Fatal(err)
}
if stats.PidsStats.Current != 4096 {
t.Fatalf("Expected %d, got %d for pids.current", 4096, stats.PidsStats.Current)
}
if stats.PidsStats.Limit != 0 {
t.Fatalf("Expected %d, got %d for pids.max", 0, stats.PidsStats.Limit)
} }
} }