From a6d5179f601f1f5b8b2e98589df46ce8e6c7f5c9 Mon Sep 17 00:00:00 2001 From: Aleksa Sarai Date: Mon, 14 Mar 2016 18:08:47 +1100 Subject: [PATCH] libcontainer: cgroups: add tests for pids.max == "max" Signed-off-by: Aleksa Sarai --- libcontainer/cgroups/fs/pids_test.go | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/libcontainer/cgroups/fs/pids_test.go b/libcontainer/cgroups/fs/pids_test.go index d4e3555f..10671247 100644 --- a/libcontainer/cgroups/fs/pids_test.go +++ b/libcontainer/cgroups/fs/pids_test.go @@ -81,7 +81,31 @@ func TestPidsStats(t *testing.T) { t.Fatalf("Expected %d, got %d for pids.current", 1337, stats.PidsStats.Current) } - if stats.PidsStats.Max != maxLimited { - t.Fatalf("Expected %d, got %d for pids.max", maxLimited, stats.PidsStats.Max) + if stats.PidsStats.Limit != maxLimited { + 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) } }