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 <noreply@anthropic.com>
Signed-off-by: Paul Meyer <katexochen0@gmail.com>
This commit is contained in:
Paul Meyer
2026-06-07 19:23:48 +01:00
committed by Luca Boccassi
parent 1e551e5ea0
commit ce31ff043e
+3 -3
View File
@@ -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++) {