Skip to content

Commit 28f09ad

Browse files
committed
test(daemon_ipc): fall back to /proc/self/exe when the recorded runner path cannot exec
The userns smoke probe now re-execs cbm_test_program_path (argv[0]) so it works under Valgrind, where /proc/self/exe does not name the test-runner. argv[0] can be relative, and earlier tests may change the working directory, so a failed exec of the recorded path now retries /proc/self/exe before reporting exit code 3 (re-exec failure).
1 parent 9da7715 commit 28f09ad

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎tests/test_daemon_ipc.c‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5587,9 +5587,14 @@ TEST(daemon_ipc_posix_single_uid_userns_real_smoke_issue1830) {
55875587
* Re-exec so the decision is made by a process that STARTED here, which
55885588
* is also the only shape production ever takes. */
55895589
/* /proc/self/exe can name Valgrind itself here. Re-exec the runner
5590-
* path recorded from argv[0] so the probe starts fresh in the namespace. */
5591-
(void)execl(cbm_test_program_path, "test-runner", "--userns-secure-probe", probe,
5592-
(char *)NULL);
5590+
* path recorded from argv[0] so the probe starts fresh in the namespace.
5591+
* A relative argv[0] stops resolving once an earlier test changes the
5592+
* working directory, so fall back to /proc/self/exe. */
5593+
if (cbm_test_program_path) {
5594+
(void)execl(cbm_test_program_path, "test-runner", "--userns-secure-probe", probe,
5595+
(char *)NULL);
5596+
}
5597+
(void)execl("/proc/self/exe", "test-runner", "--userns-secure-probe", probe, (char *)NULL);
55935598
_exit(3); /* exec failed -- distinct from secure(0)/refused(1)/skip(2) */
55945599
}
55955600
if (child < 0) {

0 commit comments

Comments
 (0)