From ed65857daea84a2f687d56c902bdf9ec679d6a19 Mon Sep 17 00:00:00 2001 From: Rohit Jnagal Date: Tue, 29 Apr 2014 00:32:05 +0000 Subject: [PATCH] Another test to check for invalid stats. Docker-DCO-1.1-Signed-off-by: Rohit Jnagal (github: rjnagal) --- cgroups/fs/cpu_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/cgroups/fs/cpu_test.go b/cgroups/fs/cpu_test.go index ed9c0de..698ae92 100644 --- a/cgroups/fs/cpu_test.go +++ b/cgroups/fs/cpu_test.go @@ -38,3 +38,20 @@ func TestNoCpuStatFile(t *testing.T) { t.Fatal("Expected to fail, but did not.") } } + +func TestInvalidCpuStat(t *testing.T) { + helper := NewCgroupTestUtil("cpu", t) + defer helper.cleanup() + cpuStatContent := `nr_periods 2000 + nr_throttled 200 + throttled_time fortytwo` + helper.writeFileContents(map[string]string{ + "cpu.stat": cpuStatContent, + }) + + cpu := &cpuGroup{} + _, err := cpu.Stats(helper.CgroupData) + if err == nil { + t.Fatal("Expected failed stat parsing.") + } +}