From 7ebf808caa76c500d52a714f7dc39a1f4952c4d3 Mon Sep 17 00:00:00 2001 From: KaFai Wan Date: Mon, 12 Oct 2026 22:02:01 +0800 Subject: [PATCH] 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 Signed-off-by: Alexei Starovoitov Link: https://patch.msgid.link/20261012140202.2754552-4-kafai.wan@linux.dev --- .../bpf/prog_tests/prog_tests_framework.c | 18 +++++++++++------- 1 file 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(); } } -- knotmirror 0.0.1