Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Correctly display subtest skip status

In skip_account(), test->skip_cnt is set to 0 at the end, this makes next print
statement never display SKIP status for the subtest. This patch moves the
accounting logic after the print statement, fixing the issue.

This patch also added SKIP status display for normal tests.

Signed-off-by: Yucong Sun <fallentree@fb.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20210817044732.3263066-3-fallentree@fb.com

authored by

Yucong Sun and committed by
Andrii Nakryiko
f667d1d6 26d82640

+13 -12
+13 -12
tools/testing/selftests/bpf/test_progs.c
··· 148 148 struct prog_test_def *test = env.test; 149 149 int sub_error_cnt = test->error_cnt - test->old_error_cnt; 150 150 151 - if (sub_error_cnt) 152 - env.fail_cnt++; 153 - else if (test->skip_cnt == 0) 154 - env.sub_succ_cnt++; 155 - skip_account(); 156 - 157 151 dump_test_log(test, sub_error_cnt); 158 152 159 153 fprintf(env.stdout, "#%d/%d %s:%s\n", 160 154 test->test_num, test->subtest_num, test->subtest_name, 161 155 sub_error_cnt ? "FAIL" : (test->skip_cnt ? "SKIP" : "OK")); 156 + 157 + if (sub_error_cnt) 158 + env.fail_cnt++; 159 + else if (test->skip_cnt == 0) 160 + env.sub_succ_cnt++; 161 + skip_account(); 162 162 163 163 free(test->subtest_name); 164 164 test->subtest_name = NULL; ··· 786 786 test__end_subtest(); 787 787 788 788 test->tested = true; 789 - if (test->error_cnt) 790 - env.fail_cnt++; 791 - else 792 - env.succ_cnt++; 793 - skip_account(); 794 789 795 790 dump_test_log(test, test->error_cnt); 796 791 797 792 fprintf(env.stdout, "#%d %s:%s\n", 798 793 test->test_num, test->test_name, 799 - test->error_cnt ? "FAIL" : "OK"); 794 + test->error_cnt ? "FAIL" : (test->skip_cnt ? "SKIP" : "OK")); 795 + 796 + if (test->error_cnt) 797 + env.fail_cnt++; 798 + else 799 + env.succ_cnt++; 800 + skip_account(); 800 801 801 802 reset_affinity(); 802 803 restore_netns();