diff options
| author | KaFai Wan <kafai.wan@linux.dev> | 2026-10-12 22:02:01 +0800 |
|---|---|---|
| committer | Alexei Starovoitov <ast@kernel.org> | 2026-10-16 00:34:10 +0000 |
| commit | 7ebf808caa76c500d52a714f7dc39a1f4952c4d3 (patch) | |
| tree | 2977e8d7c12b7d9e99b10910eaf154f7c57cb9ae /tools/testing | |
| parent | cc4b1c161d92992544cc571a2475baa5b072e120 (diff) | |
selftests/bpf: Skip compare_text subtest when stdout is not saved
stdio_hijack_init() does not set subtest_state->stdout_saved when
running with -v in non-parallel mode, since output goes straight to
stdout. In that case subtest_state->log_buf is left NULL, so the
compare_text_mismatch subtest crashes when inspecting it. Skip it when
stdout was not saved.
Fixes: bd71904697c6 ("selftests/bpf: Add compare_text_to_expected() helper")
Signed-off-by: KaFai Wan <kafai.wan@linux.dev>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://patch.msgid.link/20261012140202.2754552-4-kafai.wan@linux.dev
Diffstat (limited to 'tools/testing')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c b/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c index b4cd7c7ff439..ddb6cdc1579f 100644 --- a/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c +++ b/tools/testing/selftests/bpf/prog_tests/prog_tests_framework.c @@ -203,14 +203,18 @@ void test_prog_tests_framework_compare_text(void) } if (test__start_subtest("compare_text_mismatch")) { - err = compare_text_to_expected("line two\n", "line one\n"); - fflush(stdout); + if (!env.subtest_state->stdout_saved) { + test__skip(); + } else { + err = compare_text_to_expected("line two\n", "line one\n"); + fflush(stdout); - ASSERT_EQ(err, -1, "mismatch_rc"); - ASSERT_HAS_SUBSTR(env.subtest_state->log_buf, "-line one", - "diff_has_expected"); - ASSERT_HAS_SUBSTR(env.subtest_state->log_buf, "+line two", - "diff_has_actual"); + ASSERT_EQ(err, -1, "mismatch_rc"); + ASSERT_HAS_SUBSTR(env.subtest_state->log_buf, "-line one", + "diff_has_expected"); + ASSERT_HAS_SUBSTR(env.subtest_state->log_buf, "+line two", + "diff_has_actual"); + } test__end_subtest(); } } |
