Skip to content

Commit

Permalink
selftests/bpf: Print log buffer for exceptions test only on failure
Browse files Browse the repository at this point in the history
Alexei reported seeing log messages for some test cases even though we
just wanted to match the error string from the verifier. Move the
printing of the log buffer to a guarded condition so that we only print
it when we fail to match on the expected string in the log buffer,
preventing unneeded output when running the test.

Reported-by: Alexei Starovoitov <ast@kernel.org>
Fixes: d2a9371 ("selftests/bpf: Add tests for BPF exceptions")
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Link: https://lore.kernel.org/r/20230918155233.297024-2-memxor@gmail.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
  • Loading branch information
Kumar Kartikeya Dwivedi authored and Alexei Starovoitov committed Sep 19, 2023
1 parent a5ea265 commit 4d84dcc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/exceptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ static void test_exceptions_success(void)
goto done; \
} \
if (load_ret != 0) { \
printf("%s\n", log_buf); \
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) \
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) { \
printf("%s\n", log_buf); \
goto done; \
} \
} \
if (!load_ret && attach_err) { \
if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \
Expand Down

0 comments on commit 4d84dcc

Please sign in to comment.