mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
selftests/bpf: Report failed subtest count in test_progs summary
The final summary line is asymmetric: the PASSED field reports both the
number of top-level tests and the number of subtests within them, while
the FAILED field reports only top-level tests:
Summary: 640/5750 PASSED, 7760 SKIPPED, 100 FAILED
There is no way to tell whether those 100 failing tests amount to 100
broken subtests or 1000. So count subtests with a non-zero error_cnt
into a new sub_fail_cnt and print it alongside fail_cnt:
Summary: 640/5750 PASSED, 7760 SKIPPED, 100/342 FAILED
^^^^^
This is correct for -j runs, as subtest_states[] is populated both in
sequential and parallel modes.
A test that fails without declaring any subtests contributes 0 to
sub_fail_cnt. That mirrors the existing behaviour of sub_succ_cnt for
tests that pass without subtests, keeping the two numerators
comparable.
Also emit the new count as a "failed_subtest" field in the JSON output,
for parity with the existing "success_subtest".
Note that this changes the trailing field of the summary line from a bare
integer to "A/B", so anything scraping "N FAILED" out of it needs updating.
While here, fix the fail_cnt comment in struct test_env, which claims it
counts "total failed tests + sub-tests".
Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20260807204434.1036279-4-vineet.gupta@linux.dev
This commit is contained in:
committed by
Daniel Borkmann
parent
2614285f32
commit
7bd1dd3fb8
@@ -1656,8 +1656,8 @@ static void *dispatch_thread(void *ctx)
|
||||
|
||||
static void calculate_summary_and_print_errors(struct test_env *env)
|
||||
{
|
||||
int i;
|
||||
int succ_cnt = 0, fail_cnt = 0, sub_succ_cnt = 0, skip_cnt = 0;
|
||||
int i, j;
|
||||
int succ_cnt = 0, fail_cnt = 0, sub_succ_cnt = 0, sub_fail_cnt = 0, skip_cnt = 0;
|
||||
json_writer_t *w = NULL;
|
||||
|
||||
for (i = 0; i < prog_test_cnt; i++) {
|
||||
@@ -1670,10 +1670,14 @@ static void calculate_summary_and_print_errors(struct test_env *env)
|
||||
sub_succ_cnt += state->sub_succ_cnt;
|
||||
skip_cnt += state->skip_cnt;
|
||||
|
||||
if (state->error_cnt)
|
||||
if (state->error_cnt) {
|
||||
fail_cnt++;
|
||||
else if (!test->not_built)
|
||||
for (j = 0; j < state->subtest_num; j++)
|
||||
if (state->subtest_states[j].error_cnt)
|
||||
sub_fail_cnt++;
|
||||
} else if (!test->not_built) {
|
||||
succ_cnt++;
|
||||
}
|
||||
}
|
||||
|
||||
if (env->json) {
|
||||
@@ -1688,6 +1692,7 @@ static void calculate_summary_and_print_errors(struct test_env *env)
|
||||
jsonw_uint_field(w, "success_subtest", sub_succ_cnt);
|
||||
jsonw_uint_field(w, "skipped", skip_cnt);
|
||||
jsonw_uint_field(w, "failed", fail_cnt);
|
||||
jsonw_uint_field(w, "failed_subtest", sub_fail_cnt);
|
||||
jsonw_name(w, "results");
|
||||
jsonw_start_array(w);
|
||||
}
|
||||
@@ -1728,12 +1733,12 @@ static void calculate_summary_and_print_errors(struct test_env *env)
|
||||
fclose(env->json);
|
||||
|
||||
if (env->not_built_cnt)
|
||||
printf("Summary: %d/%d PASSED, %d SKIPPED (%d not built), %d FAILED\n",
|
||||
printf("Summary: %d/%d PASSED, %d SKIPPED (%d not built), %d/%d FAILED\n",
|
||||
succ_cnt, sub_succ_cnt, skip_cnt, env->not_built_cnt,
|
||||
fail_cnt);
|
||||
fail_cnt, sub_fail_cnt);
|
||||
else
|
||||
printf("Summary: %d/%d PASSED, %d SKIPPED, %d FAILED\n",
|
||||
succ_cnt, sub_succ_cnt, skip_cnt, fail_cnt);
|
||||
printf("Summary: %d/%d PASSED, %d SKIPPED, %d/%d FAILED\n",
|
||||
succ_cnt, sub_succ_cnt, skip_cnt, fail_cnt, sub_fail_cnt);
|
||||
|
||||
env->succ_cnt = succ_cnt;
|
||||
env->sub_succ_cnt = sub_succ_cnt;
|
||||
|
||||
@@ -124,7 +124,7 @@ struct test_env {
|
||||
|
||||
int succ_cnt; /* successful tests */
|
||||
int sub_succ_cnt; /* successful sub-tests */
|
||||
int fail_cnt; /* total failed tests + sub-tests */
|
||||
int fail_cnt; /* failed tests */
|
||||
int skip_cnt; /* skipped tests */
|
||||
int not_built_cnt; /* tests not built */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user