Skip to content

Commit 4d84dcc

Browse files
kkdwvdAlexei Starovoitov
authored andcommitted
selftests/bpf: Print log buffer for exceptions test only on failure
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>
1 parent a5ea265 commit 4d84dcc

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

tools/testing/selftests/bpf/prog_tests/exceptions.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ static void test_exceptions_success(void)
103103
goto done; \
104104
} \
105105
if (load_ret != 0) { \
106-
printf("%s\n", log_buf); \
107-
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) \
106+
if (!ASSERT_OK_PTR(strstr(log_buf, msg), "strstr")) { \
107+
printf("%s\n", log_buf); \
108108
goto done; \
109+
} \
109110
} \
110111
if (!load_ret && attach_err) { \
111112
if (!ASSERT_ERR_PTR(link = bpf_program__attach(prog), "attach err")) \

0 commit comments

Comments
 (0)