1 // SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause)
3 #include "test_progs.h"
4 #include "testing_helpers.h"
6 static void clear_test_state(struct test_state *state)
9 state->sub_succ_cnt = 0;
13 void test_prog_tests_framework(void)
15 struct test_state *state = env.test_state;
17 /* in all the ASSERT calls below we need to return on the first
18 * error due to the fact that we are cleaning the test state after
22 /* test we properly count skipped tests with subtests */
23 if (test__start_subtest("test_good_subtest"))
25 if (!ASSERT_EQ(state->skip_cnt, 0, "skip_cnt_check"))
27 if (!ASSERT_EQ(state->error_cnt, 0, "error_cnt_check"))
29 if (!ASSERT_EQ(state->subtest_num, 1, "subtest_num_check"))
31 clear_test_state(state);
33 if (test__start_subtest("test_skip_subtest")) {
37 if (test__start_subtest("test_skip_subtest")) {
41 if (!ASSERT_EQ(state->skip_cnt, 2, "skip_cnt_check"))
43 if (!ASSERT_EQ(state->subtest_num, 3, "subtest_num_check"))
45 clear_test_state(state);
47 if (test__start_subtest("test_fail_subtest")) {
51 if (!ASSERT_EQ(state->error_cnt, 1, "error_cnt_check"))
53 if (!ASSERT_EQ(state->subtest_num, 4, "subtest_num_check"))
55 clear_test_state(state);