|
| 1 | +// SPDX-License-Identifier: (LGPL-2.1 OR BSD-2-Clause) |
| 2 | + |
| 3 | +#include "test_progs.h" |
| 4 | +#include "testing_helpers.h" |
| 5 | + |
| 6 | +static void clear_test_result(struct test_result *result) |
| 7 | +{ |
| 8 | + result->error_cnt = 0; |
| 9 | + result->sub_succ_cnt = 0; |
| 10 | + result->skip_cnt = 0; |
| 11 | +} |
| 12 | + |
| 13 | +void test_prog_tests_framework(void) |
| 14 | +{ |
| 15 | + struct test_result *result = env.test_result; |
| 16 | + |
| 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 |
| 19 | + // each dummy subtest |
| 20 | + |
| 21 | + // test we properly count skipped tests with subtests |
| 22 | + if (test__start_subtest("test_good_subtest")) |
| 23 | + test__end_subtest(); |
| 24 | + if (!ASSERT_EQ(result->skip_cnt, 0, "skip_cnt_check")) |
| 25 | + return; |
| 26 | + if (!ASSERT_EQ(result->error_cnt, 0, "error_cnt_check")) |
| 27 | + return; |
| 28 | + if (!ASSERT_EQ(result->subtest_num, 1, "subtest_num_check")) |
| 29 | + return; |
| 30 | + clear_test_result(result); |
| 31 | + |
| 32 | + if (test__start_subtest("test_skip_subtest")) { |
| 33 | + test__skip(); |
| 34 | + test__end_subtest(); |
| 35 | + } |
| 36 | + if (test__start_subtest("test_skip_subtest")) { |
| 37 | + test__skip(); |
| 38 | + test__end_subtest(); |
| 39 | + } |
| 40 | + if (!ASSERT_EQ(result->skip_cnt, 2, "skip_cnt_check")) |
| 41 | + return; |
| 42 | + if (!ASSERT_EQ(result->subtest_num, 3, "subtest_num_check")) |
| 43 | + return; |
| 44 | + clear_test_result(result); |
| 45 | + |
| 46 | + if (test__start_subtest("test_fail_subtest")) { |
| 47 | + test__fail(); |
| 48 | + test__end_subtest(); |
| 49 | + } |
| 50 | + if (!ASSERT_EQ(result->error_cnt, 1, "error_cnt_check")) |
| 51 | + return; |
| 52 | + if (!ASSERT_EQ(result->subtest_num, 4, "subtest_num_check")) |
| 53 | + return; |
| 54 | + clear_test_result(result); |
| 55 | +} |
0 commit comments