OSDN Git Service

selftests/bpf: Check whether to run selftest
authorDaniel Müller <deso@posteo.net>
Thu, 25 May 2023 23:22:48 +0000 (23:22 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 25 May 2023 23:51:05 +0000 (16:51 -0700)
The sockopt test invokes test__start_subtest and then unconditionally
asserts the success. That means that even if deny-listed, any test will
still run and potentially fail.
Evaluate the return value of test__start_subtest() to achieve the
desired behavior, as other tests do.

Signed-off-by: Daniel Müller <deso@posteo.net>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20230525232248.640465-1-deso@posteo.net
tools/testing/selftests/bpf/prog_tests/sockopt.c

index 33dd453..9e6a5e3 100644 (file)
@@ -1060,7 +1060,9 @@ void test_sockopt(void)
                return;
 
        for (i = 0; i < ARRAY_SIZE(tests); i++) {
-               test__start_subtest(tests[i].descr);
+               if (!test__start_subtest(tests[i].descr))
+                       continue;
+
                ASSERT_OK(run_test(cgroup_fd, &tests[i]), tests[i].descr);
        }