aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime@cerno.tech>2022-06-08 19:11:27 +0200
committerMaxime Ripard <maxime@cerno.tech>2022-06-08 19:11:27 +0200
commit6e2b347d42e54282e4c6cfa08272db462b178f7f (patch)
tree7686345b2e24c406a57feffcad558484f9552366 /tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c
parentdrm/atomic: Force bridge self-refresh-exit on CRTC switch (diff)
parentLinux 5.19-rc1 (diff)
downloadwireguard-linux-6e2b347d42e54282e4c6cfa08272db462b178f7f.tar.xz
wireguard-linux-6e2b347d42e54282e4c6cfa08272db462b178f7f.zip
Merge v5.19-rc1 into drm-misc-fixes
Let's kick-off the start of the 5.19 fix cycle Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c b/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c
new file mode 100644
index 000000000000..14f2796076e0
--- /dev/null
+++ b/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
+
+#include "test_progs.h"
+#include "testing_helpers.h"
+
+static void clear_test_state(struct test_state *state)
+{
+ state->error_cnt = 0;
+ state->sub_succ_cnt = 0;
+ state->skip_cnt = 0;
+}
+
+void test_prog_tests_framework(void)
+{
+ struct test_state *state = env.test_state;
+
+ /* in all the ASSERT calls below we need to return on the first
+ * error due to the fact that we are cleaning the test state after
+ * each dummy subtest
+ */
+
+ /* test we properly count skipped tests with subtests */
+ if (test__start_subtest("test_good_subtest"))
+ test__end_subtest();
+ if (!ASSERT_EQ(state->skip_cnt, 0, "skip_cnt_check"))
+ return;
+ if (!ASSERT_EQ(state->error_cnt, 0, "error_cnt_check"))
+ return;
+ if (!ASSERT_EQ(state->subtest_num, 1, "subtest_num_check"))
+ return;
+ clear_test_state(state);
+
+ if (test__start_subtest("test_skip_subtest")) {
+ test__skip();
+ test__end_subtest();
+ }
+ if (test__start_subtest("test_skip_subtest")) {
+ test__skip();
+ test__end_subtest();
+ }
+ if (!ASSERT_EQ(state->skip_cnt, 2, "skip_cnt_check"))
+ return;
+ if (!ASSERT_EQ(state->subtest_num, 3, "subtest_num_check"))
+ return;
+ clear_test_state(state);
+
+ if (test__start_subtest("test_fail_subtest")) {
+ test__fail();
+ test__end_subtest();
+ }
+ if (!ASSERT_EQ(state->error_cnt, 1, "error_cnt_check"))
+ return;
+ if (!ASSERT_EQ(state->subtest_num, 4, "subtest_num_check"))
+ return;
+ clear_test_state(state);
+}