diff --git a/libcontainer/cgroups/fs/blkio_test.go b/libcontainer/cgroups/fs/blkio_test.go index 793c04325..2f5ff2aa8 100644 --- a/libcontainer/cgroups/fs/blkio_test.go +++ b/libcontainer/cgroups/fs/blkio_test.go @@ -283,7 +283,6 @@ func TestBlkioSetMultipleWeightDevice(t *testing.T) { if err != nil { t.Fatal(err) } - if value != weightDeviceAfter { t.Fatalf("Got the wrong value, set %s failed.", blkio.weightDeviceFilename) } @@ -772,9 +771,8 @@ func TestBlkioSetThrottleReadBpsDevice(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "blkio.throttle.read_bps_device") if err != nil { - t.Fatalf("Failed to parse blkio.throttle.read_bps_device - %s", err) + t.Fatal(err) } - if value != throttleAfter { t.Fatal("Got the wrong value, set blkio.throttle.read_bps_device failed.") } @@ -803,9 +801,8 @@ func TestBlkioSetThrottleWriteBpsDevice(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "blkio.throttle.write_bps_device") if err != nil { - t.Fatalf("Failed to parse blkio.throttle.write_bps_device - %s", err) + t.Fatal(err) } - if value != throttleAfter { t.Fatal("Got the wrong value, set blkio.throttle.write_bps_device failed.") } @@ -834,9 +831,8 @@ func TestBlkioSetThrottleReadIOpsDevice(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "blkio.throttle.read_iops_device") if err != nil { - t.Fatalf("Failed to parse blkio.throttle.read_iops_device - %s", err) + t.Fatal(err) } - if value != throttleAfter { t.Fatal("Got the wrong value, set blkio.throttle.read_iops_device failed.") } @@ -865,9 +861,8 @@ func TestBlkioSetThrottleWriteIOpsDevice(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "blkio.throttle.write_iops_device") if err != nil { - t.Fatalf("Failed to parse blkio.throttle.write_iops_device - %s", err) + t.Fatal(err) } - if value != throttleAfter { t.Fatal("Got the wrong value, set blkio.throttle.write_iops_device failed.") } diff --git a/libcontainer/cgroups/fs/cpu_test.go b/libcontainer/cgroups/fs/cpu_test.go index adfe8c2d5..4e9c2ff9f 100644 --- a/libcontainer/cgroups/fs/cpu_test.go +++ b/libcontainer/cgroups/fs/cpu_test.go @@ -32,9 +32,8 @@ func TestCpuSetShares(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.shares") if err != nil { - t.Fatalf("Failed to parse cpu.shares - %s", err) + t.Fatal(err) } - if value != sharesAfter { t.Fatal("Got the wrong value, set cpu.shares failed.") } @@ -73,7 +72,7 @@ func TestCpuSetBandWidth(t *testing.T) { quota, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.cfs_quota_us") if err != nil { - t.Fatalf("Failed to parse cpu.cfs_quota_us - %s", err) + t.Fatal(err) } if quota != quotaAfter { t.Fatal("Got the wrong value, set cpu.cfs_quota_us failed.") @@ -81,21 +80,23 @@ func TestCpuSetBandWidth(t *testing.T) { period, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.cfs_period_us") if err != nil { - t.Fatalf("Failed to parse cpu.cfs_period_us - %s", err) + t.Fatal(err) } if period != periodAfter { t.Fatal("Got the wrong value, set cpu.cfs_period_us failed.") } + rtRuntime, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.rt_runtime_us") if err != nil { - t.Fatalf("Failed to parse cpu.rt_runtime_us - %s", err) + t.Fatal(err) } if rtRuntime != rtRuntimeAfter { t.Fatal("Got the wrong value, set cpu.rt_runtime_us failed.") } + rtPeriod, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.rt_period_us") if err != nil { - t.Fatalf("Failed to parse cpu.rt_period_us - %s", err) + t.Fatal(err) } if rtPeriod != rtPeriodAfter { t.Fatal("Got the wrong value, set cpu.rt_period_us failed.") @@ -191,21 +192,23 @@ func TestCpuSetRtSchedAtApply(t *testing.T) { rtRuntime, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.rt_runtime_us") if err != nil { - t.Fatalf("Failed to parse cpu.rt_runtime_us - %s", err) + t.Fatal(err) } if rtRuntime != rtRuntimeAfter { t.Fatal("Got the wrong value, set cpu.rt_runtime_us failed.") } + rtPeriod, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cpu.rt_period_us") if err != nil { - t.Fatalf("Failed to parse cpu.rt_period_us - %s", err) + t.Fatal(err) } if rtPeriod != rtPeriodAfter { t.Fatal("Got the wrong value, set cpu.rt_period_us failed.") } + pid, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "cgroup.procs") if err != nil { - t.Fatalf("Failed to parse cgroup.procs - %s", err) + t.Fatal(err) } if pid != 1234 { t.Fatal("Got the wrong value, set cgroup.procs failed.") diff --git a/libcontainer/cgroups/fs/cpuset_test.go b/libcontainer/cgroups/fs/cpuset_test.go index 2f0877c3e..05872ed6c 100644 --- a/libcontainer/cgroups/fs/cpuset_test.go +++ b/libcontainer/cgroups/fs/cpuset_test.go @@ -59,9 +59,8 @@ func TestCPUSetSetCpus(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "cpuset.cpus") if err != nil { - t.Fatalf("Failed to parse cpuset.cpus - %s", err) + t.Fatal(err) } - if value != cpusAfter { t.Fatal("Got the wrong value, set cpuset.cpus failed.") } @@ -88,9 +87,8 @@ func TestCPUSetSetMems(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "cpuset.mems") if err != nil { - t.Fatalf("Failed to parse cpuset.mems - %s", err) + t.Fatal(err) } - if value != memsAfter { t.Fatal("Got the wrong value, set cpuset.mems failed.") } diff --git a/libcontainer/cgroups/fs/devices_test.go b/libcontainer/cgroups/fs/devices_test.go index a0ef145d8..1a49b4a89 100644 --- a/libcontainer/cgroups/fs/devices_test.go +++ b/libcontainer/cgroups/fs/devices_test.go @@ -37,7 +37,7 @@ func TestDevicesSetAllow(t *testing.T) { // The default deny rule must be written. value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "devices.deny") if err != nil { - t.Fatalf("Failed to parse devices.deny: %s", err) + t.Fatal(err) } if value[0] != 'a' { t.Errorf("Got the wrong value (%q), set devices.deny failed.", value) @@ -45,7 +45,7 @@ func TestDevicesSetAllow(t *testing.T) { // Permitted rule must be written. if value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "devices.allow"); err != nil { - t.Fatalf("Failed to parse devices.allow: %s", err) + t.Fatal(err) } else if value != "c 1:5 rwm" { t.Errorf("Got the wrong value (%q), set devices.allow failed.", value) } diff --git a/libcontainer/cgroups/fs/freezer_test.go b/libcontainer/cgroups/fs/freezer_test.go index e41b1ad4a..7117795ba 100644 --- a/libcontainer/cgroups/fs/freezer_test.go +++ b/libcontainer/cgroups/fs/freezer_test.go @@ -25,7 +25,7 @@ func TestFreezerSetState(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "freezer.state") if err != nil { - t.Fatalf("Failed to parse freezer.state - %s", err) + t.Fatal(err) } if value != string(configs.Thawed) { t.Fatal("Got the wrong value, set freezer.state failed.") diff --git a/libcontainer/cgroups/fs/hugetlb_test.go b/libcontainer/cgroups/fs/hugetlb_test.go index 01b6889d4..181f243ec 100644 --- a/libcontainer/cgroups/fs/hugetlb_test.go +++ b/libcontainer/cgroups/fs/hugetlb_test.go @@ -57,7 +57,7 @@ func TestHugetlbSetHugetlb(t *testing.T) { limit := fmt.Sprintf(limit, pageSize) value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, limit) if err != nil { - t.Fatalf("Failed to parse %s - %s", limit, err) + t.Fatal(err) } if value != hugetlbAfter { t.Fatalf("Set hugetlb.limit_in_bytes failed. Expected: %v, Got: %v", hugetlbAfter, value) diff --git a/libcontainer/cgroups/fs/memory_test.go b/libcontainer/cgroups/fs/memory_test.go index dbc055f43..92fba42bc 100644 --- a/libcontainer/cgroups/fs/memory_test.go +++ b/libcontainer/cgroups/fs/memory_test.go @@ -64,7 +64,7 @@ func TestMemorySetMemory(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.limit_in_bytes - %s", err) + t.Fatal(err) } if value != memoryAfter { t.Fatal("Got the wrong value, set memory.limit_in_bytes failed.") @@ -72,7 +72,7 @@ func TestMemorySetMemory(t *testing.T) { value, err = fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.soft_limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.soft_limit_in_bytes - %s", err) + t.Fatal(err) } if value != reservationAfter { t.Fatal("Got the wrong value, set memory.soft_limit_in_bytes failed.") @@ -100,7 +100,7 @@ func TestMemorySetMemoryswap(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.memsw.limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.memsw.limit_in_bytes - %s", err) + t.Fatal(err) } if value != memoryswapAfter { t.Fatal("Got the wrong value, set memory.memsw.limit_in_bytes failed.") @@ -137,14 +137,15 @@ func TestMemorySetMemoryLargerThanSwap(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.limit_in_bytes - %s", err) + t.Fatal(err) } if value != memoryAfter { t.Fatal("Got the wrong value, set memory.limit_in_bytes failed.") } + value, err = fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.memsw.limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.memsw.limit_in_bytes - %s", err) + t.Fatal(err) } if value != memoryswapAfter { t.Fatal("Got the wrong value, set memory.memsw.limit_in_bytes failed.") @@ -176,14 +177,15 @@ func TestMemorySetSwapSmallerThanMemory(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.limit_in_bytes - %s", err) + t.Fatal(err) } if value != memoryAfter { t.Fatalf("Got the wrong value (%d != %d), set memory.limit_in_bytes failed", value, memoryAfter) } + value, err = fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.memsw.limit_in_bytes") if err != nil { - t.Fatalf("Failed to parse memory.memsw.limit_in_bytes - %s", err) + t.Fatal(err) } if value != memoryswapAfter { t.Fatalf("Got the wrong value (%d != %d), set memory.memsw.limit_in_bytes failed", value, memoryswapAfter) @@ -209,7 +211,7 @@ func TestMemorySetMemorySwappinessDefault(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.swappiness") if err != nil { - t.Fatalf("Failed to parse memory.swappiness - %s", err) + t.Fatal(err) } if value != swappinessAfter { t.Fatalf("Got the wrong value (%d), set memory.swappiness = %d failed.", value, swappinessAfter) @@ -427,9 +429,8 @@ func TestMemorySetOomControl(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "memory.oom_control") if err != nil { - t.Fatalf("Failed to parse memory.oom_control - %s", err) + t.Fatal(err) } - if value != oomKillDisable { t.Fatalf("Got the wrong value, set memory.oom_control failed.") } diff --git a/libcontainer/cgroups/fs/net_cls_test.go b/libcontainer/cgroups/fs/net_cls_test.go index 1bb99eb22..d96814a3e 100644 --- a/libcontainer/cgroups/fs/net_cls_test.go +++ b/libcontainer/cgroups/fs/net_cls_test.go @@ -33,7 +33,7 @@ func TestNetClsSetClassid(t *testing.T) { // So. we just judge if we successfully write classid into file value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "net_cls.classid") if err != nil { - t.Fatalf("Failed to parse net_cls.classid - %s", err) + t.Fatal(err) } if value != classidAfter { t.Fatal("Got the wrong value, set net_cls.classid failed.") diff --git a/libcontainer/cgroups/fs/net_prio_test.go b/libcontainer/cgroups/fs/net_prio_test.go index 3f48e04a0..a2092b69b 100644 --- a/libcontainer/cgroups/fs/net_prio_test.go +++ b/libcontainer/cgroups/fs/net_prio_test.go @@ -29,7 +29,7 @@ func TestNetPrioSetIfPrio(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "net_prio.ifpriomap") if err != nil { - t.Fatalf("Failed to parse net_prio.ifpriomap - %s", err) + t.Fatal(err) } if !strings.Contains(value, "test 5") { t.Fatal("Got the wrong value, set net_prio.ifpriomap failed.") diff --git a/libcontainer/cgroups/fs/pids_test.go b/libcontainer/cgroups/fs/pids_test.go index 7f3157475..66edfe880 100644 --- a/libcontainer/cgroups/fs/pids_test.go +++ b/libcontainer/cgroups/fs/pids_test.go @@ -31,9 +31,8 @@ func TestPidsSetMax(t *testing.T) { value, err := fscommon.GetCgroupParamUint(helper.CgroupPath, "pids.max") if err != nil { - t.Fatalf("Failed to parse pids.max - %s", err) + t.Fatal(err) } - if value != maxLimited { t.Fatalf("Expected %d, got %d for setting pids.max - limited", maxLimited, value) } @@ -55,9 +54,8 @@ func TestPidsSetUnlimited(t *testing.T) { value, err := fscommon.GetCgroupParamString(helper.CgroupPath, "pids.max") if err != nil { - t.Fatalf("Failed to parse pids.max - %s", err) + t.Fatal(err) } - if value != "max" { t.Fatalf("Expected %s, got %s for setting pids.max - unlimited", "max", value) }