From 3394e37405e44be3c260fcd9c4fa344e347c5813 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 14 Jan 2021 10:32:51 -0800 Subject: [PATCH 1/3] libct/cg/sd/TestRangeToBits: be less verbose As we run unit tests with -v, this case produces lots of output which was handy while working on the code, but now it's more like noise: === RUN TestRangeToBits cpuset_test.go:43: case: "" cpuset_test.go:46: got error: empty value cpuset_test.go:43: case: "0" cpuset_test.go:53: expected [1], got [1] cpuset_test.go:43: case: "1" cpuset_test.go:53: expected [2], got [2] cpuset_test.go:43: case: "0-1" cpuset_test.go:53: expected [3], got [3] cpuset_test.go:43: case: "0,1" cpuset_test.go:53: expected [3], got [3] cpuset_test.go:43: case: ",0,1," cpuset_test.go:53: expected [3], got [3] cpuset_test.go:43: case: "0-3" cpuset_test.go:53: expected [15], got [15] cpuset_test.go:43: case: "0,1,2-3" cpuset_test.go:53: expected [15], got [15] cpuset_test.go:43: case: "4-7" cpuset_test.go:53: expected [240], got [240] cpuset_test.go:43: case: "0-7" cpuset_test.go:53: expected [255], got [255] cpuset_test.go:43: case: "0-15" cpuset_test.go:53: expected [255 255], got [255 255] cpuset_test.go:43: case: "16" cpuset_test.go:53: expected [1 0 0], got [1 0 0] cpuset_test.go:43: case: "0-3,32-33" cpuset_test.go:53: expected [3 0 0 0 15], got [3 0 0 0 15] cpuset_test.go:43: case: "1, 2, 1-2" cpuset_test.go:53: expected [6], got [6] cpuset_test.go:43: case: " , 1 , 3 , 5-7,\t" cpuset_test.go:53: expected [234], got [234] cpuset_test.go:43: case: "128-130,1" cpuset_test.go:53: expected [7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2], got [7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2] cpuset_test.go:43: case: "-" cpuset_test.go:46: got error: strconv.ParseUint: parsing "": invalid syntax cpuset_test.go:43: case: "1-" cpuset_test.go:46: got error: strconv.ParseUint: parsing "": invalid syntax cpuset_test.go:43: case: "-3" cpuset_test.go:46: got error: strconv.ParseUint: parsing "": invalid syntax cpuset_test.go:43: case: "54-53" cpuset_test.go:46: got error: invalid range: 54-53 cpuset_test.go:43: case: "1 - 2" cpuset_test.go:46: got error: strconv.ParseUint: parsing "1 ": invalid syntax --- PASS: TestRangeToBits (0.00s) Only log errors. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/systemd/cpuset_test.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/libcontainer/cgroups/systemd/cpuset_test.go b/libcontainer/cgroups/systemd/cpuset_test.go index 6f8fde073..7dda1e3c0 100644 --- a/libcontainer/cgroups/systemd/cpuset_test.go +++ b/libcontainer/cgroups/systemd/cpuset_test.go @@ -40,19 +40,16 @@ func TestRangeToBits(t *testing.T) { } for _, tc := range testCases { - t.Logf("case: %q", tc.in) out, err := rangeToBits(tc.in) if err != nil { - t.Logf(" got error: %s", err) if !tc.isErr { - t.Error(" ^^^ unexpected error") + t.Errorf("case %q: unexpected error: %v", tc.in, err) } continue } - t.Logf(" expected %v, got %v", tc.out, out) if !bytes.Equal(out, tc.out) { - t.Error(" ^^^ unexpected result") + t.Errorf("case %q: expected %v, got %v", tc.in, tc.out, out) } } } From 657a24ce01293c9db8cfbe1648b3a47ebc10a31c Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 14 Jan 2021 10:38:59 -0800 Subject: [PATCH 2/3] libct/cg/TestGetHugePageSizeImpl: only log errors This: > === RUN TestGetHugePageSizeImpl > utils_test.go:504: (input [hugepages-akB], error strconv.Atoi: parsing "a": invalid syntax) feels like an error but it's not. Only log errors. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/utils_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libcontainer/cgroups/utils_test.go b/libcontainer/cgroups/utils_test.go index 1645ae7b0..11bc7d883 100644 --- a/libcontainer/cgroups/utils_test.go +++ b/libcontainer/cgroups/utils_test.go @@ -501,9 +501,8 @@ func TestGetHugePageSizeImpl(t *testing.T) { warns.Reset() output, err := getHugePageSizeFromFilenames(c.input) if err != nil { - t.Logf("(input %v, error %v)", c.input, err) if !c.isErr { - t.Error("unexpected error ^^^^") + t.Errorf("input %v, expected nil, got error: %v", c.input, err) } // no more checks continue From c7357aaddbafd591291664466dc634ceefb17968 Mon Sep 17 00:00:00 2001 From: Kir Kolyshkin Date: Thu, 14 Jan 2021 10:43:07 -0800 Subject: [PATCH 3/3] libct/cg/ebpf/testDeviceFilter: rm verbose logging These tests are quite verbose, it was probably good for development but seems excessive for CI: > === RUN TestDeviceFilter_Nil > devicefilter_test.go:29: TestDeviceFilter_Nil: devices: [] > 0: LdXMemW dst: r2 src: r1 off: 0 imm: 0 > 1: And32Imm dst: r2 imm: 65535 > 2: LdXMemW dst: r3 src: r1 off: 0 imm: 0 > 3: RSh32Imm dst: r3 imm: 16 > 4: LdXMemW dst: r4 src: r1 off: 4 imm: 0 > 5: LdXMemW dst: r5 src: r1 off: 8 imm: 0 > block-0: > 6: Mov32Imm dst: r0 imm: 0 > 7: Exit > --- PASS: TestDeviceFilter_Nil (0.00s) ... and so on Remove t.Logf. Signed-off-by: Kir Kolyshkin --- libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go | 1 - 1 file changed, 1 deletion(-) diff --git a/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go b/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go index 1ed7a0717..f714bcac2 100644 --- a/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go +++ b/libcontainer/cgroups/ebpf/devicefilter/devicefilter_test.go @@ -26,7 +26,6 @@ func testDeviceFilter(t testing.TB, devices []*devices.Rule, expectedStr string) t.Fatalf("%s: %v (devices: %+v)", t.Name(), err, devices) } s := insts.String() - t.Logf("%s: devices: %+v\n%s", t.Name(), devices, s) if expectedStr != "" { hashed := hash(s, "//") expectedHashed := hash(expectedStr, "//")