From: Paul Meyer Date: Sun, 7 Jun 2026 12:01:05 +0000 (+0200) Subject: tests: don't leak TESTFUNCS count into run_test_table() exit code X-Git-Tag: v261-rc4~71 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce31ff043e6257caf33b87b320225ef5c3c91b80;p=thirdparty%2Fsystemd.git tests: don't leak TESTFUNCS count into run_test_table() exit code strv_split_full() returns the number of parsed entries, which was assigned to r, the variable that also holds the run's exit status. With TESTFUNCS set, a passing run of only void tests then exited with the entry count (e.g. 1) instead of EXIT_SUCCESS. Use a separate variable for the split result. Before: $ env TESTFUNCS=test_copy_tree meson test -C build -v test-copy 1/1 test - systemd:test-copy FAIL 0.01s exit status 1 $ env TESTFUNCS=test_copy_tree:test_copy_file_fd meson test -C build -v test-copy 1/1 test - systemd:test-copy FAIL 0.01s exit status 2 Now: $ env TESTFUNCS=test_copy_tree:test_copy_file_fd meson test -C build -v test-copy 1/1 test - systemd:test-copy OK 0.01s Co-developed-by: Claude Opus 4.8 Signed-off-by: Paul Meyer --- diff --git a/src/shared/tests.c b/src/shared/tests.c index 176c7fb13f3..1dc54318fa2 100644 --- a/src/shared/tests.c +++ b/src/shared/tests.c @@ -386,9 +386,9 @@ int run_test_table(const TestFunc *start, const TestFunc *end) { const char *e = getenv("TESTFUNCS"); if (e) { - r = strv_split_full(&tests, e, ":", EXTRACT_DONT_COALESCE_SEPARATORS); - if (r < 0) - return log_error_errno(r, "Failed to parse $TESTFUNCS: %m"); + int n = strv_split_full(&tests, e, ":", EXTRACT_DONT_COALESCE_SEPARATORS); + if (n < 0) + return log_error_errno(n, "Failed to parse $TESTFUNCS: %m"); } for (const TestFunc *t = start; t + 1 <= end; t++) {