Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
selftests/harness: Fix tests timeout and race condition
We cannot use CLONE_VFORK because we also need to wait for the timeout signal. Restore tests timeout by using the original fork() call in __run_test() but also in __TEST_F_IMPL(). Also fix a race condition when waiting for the test child process. Because test metadata are shared between test processes, only the parent process must set the test PID (child). Otherwise, t->pid may be set to zero, leading to inconsistent error cases: # RUN layout1.rule_on_mountpoint ... # rule_on_mountpoint: Test ended in some other way [127] # OK layout1.rule_on_mountpoint ok 20 layout1.rule_on_mountpoint As safeguards, initialize the "status" variable with a valid exit code, and handle unknown test exits as errors. The use of fork() introduces a new race condition in landlock/fs_test.c which seems to be specific to hostfs bind mounts, but I haven't found the root cause and it's difficult to trigger. I'll try to fix it with another patch. Cc: Christian Brauner <[email protected]> Cc: Günther Noack <[email protected]> Cc: Jakub Kicinski <[email protected]> Cc: Kees Cook <[email protected]> Cc: Shuah Khan <[email protected]> Cc: Will Drewry <[email protected]> Cc: [email protected] Closes: https://lore.kernel.org/r/[email protected] Fixes: a86f189 ("selftests/harness: Fix interleaved scheduling leading to race conditions") Fixes: 24cf65a ("selftests/harness: Share _metadata between forked processes") Link: https://lore.kernel.org/r/[email protected] Tested-by: Mark Brown <[email protected]> Signed-off-by: Mickaël Salaün <[email protected]>
- Loading branch information