Skip to content

Commit

Permalink
selftests/bpf: remove filtered subtests from output
Browse files Browse the repository at this point in the history
Currently filtered subtests show up in the output as skipped.

Before:
$ sudo ./test_progs -t log_fixup/missing_map
 torvalds#94 /1     log_fixup/bad_core_relo_trunc_none:SKIP
 torvalds#94 /2     log_fixup/bad_core_relo_trunc_partial:SKIP
 torvalds#94 /3     log_fixup/bad_core_relo_trunc_full:SKIP
 torvalds#94 /4     log_fixup/bad_core_relo_subprog:SKIP
 torvalds#94 /5     log_fixup/missing_map:OK
 torvalds#94        log_fixup:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED

After:
$ sudo ./test_progs -t log_fixup/missing_map
 torvalds#94 /5     log_fixup/missing_map:OK
 torvalds#94        log_fixup:OK
Summary: 1/1 PASSED, 0 SKIPPED, 0 FAILED

Signed-off-by: Mykola Lysenko <mykolal@fb.com>
  • Loading branch information
mykola-lysenko authored and intel-lab-lkp committed May 20, 2022
1 parent 834650b commit 724810b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/testing/selftests/bpf/test_progs.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ static void dump_test_log(const struct prog_test_def *test,
int i;
struct subtest_state *subtest_state;
bool subtest_failed;
bool subtest_filtered;
bool print_subtest;

/* we do not print anything in the worker thread */
Expand All @@ -283,9 +284,10 @@ static void dump_test_log(const struct prog_test_def *test,
for (i = 0; i < test_state->subtest_num; i++) {
subtest_state = &test_state->subtest_states[i];
subtest_failed = subtest_state->error_cnt;
subtest_filtered = subtest_state->filtered;
print_subtest = verbose() || force_log || subtest_failed;

if (skip_ok_subtests && !subtest_failed)
if ((skip_ok_subtests && !subtest_failed) || subtest_filtered)
continue;

if (subtest_state->log_cnt && print_subtest) {
Expand Down Expand Up @@ -417,7 +419,7 @@ bool test__start_subtest(const char *subtest_name)
state->subtest_num,
test->test_name,
subtest_name)) {
subtest_state->skipped = true;
subtest_state->filtered = true;
return false;
}

Expand Down Expand Up @@ -1123,6 +1125,7 @@ static int dispatch_thread_send_subtests(int sock_fd, struct test_state *state)
subtest_state->name = strdup(msg.subtest_done.name);
subtest_state->error_cnt = msg.subtest_done.error_cnt;
subtest_state->skipped = msg.subtest_done.skipped;
subtest_state->filtered = msg.subtest_done.filtered;

/* collect all logs */
if (msg.subtest_done.have_log)
Expand Down Expand Up @@ -1418,6 +1421,7 @@ static int worker_main_send_subtests(int sock, struct test_state *state)

msg.subtest_done.error_cnt = subtest_state->error_cnt;
msg.subtest_done.skipped = subtest_state->skipped;
msg.subtest_done.filtered = subtest_state->filtered;
msg.subtest_done.have_log = false;

if (verbose() || state->force_log || subtest_state->error_cnt) {
Expand Down
2 changes: 2 additions & 0 deletions tools/testing/selftests/bpf/test_progs.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct subtest_state {
char *log_buf;
int error_cnt;
bool skipped;
bool filtered;

FILE *stdout;
};
Expand Down Expand Up @@ -156,6 +157,7 @@ struct msg {
char name[MAX_SUBTEST_NAME + 1];
int error_cnt;
bool skipped;
bool filtered;
bool have_log;
} subtest_done;
};
Expand Down

0 comments on commit 724810b

Please sign in to comment.