Commit 19ad209
selftests/harness: Fix tests timeout and race condition
commit 130e428 upstream.
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 <brauner@kernel.org>
Cc: Günther Noack <gnoack@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Kees Cook <keescook@chromium.org>
Cc: Shuah Khan <shuah@kernel.org>
Cc: Will Drewry <wad@chromium.org>
Cc: stable@vger.kernel.org
Closes: https://lore.kernel.org/r/9341d4db-5e21-418c-bf9e-9ae2da7877e1@sirena.org.uk
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/20240621180605.834676-1-mic@digikod.net
Tested-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Mickaël Salaün <mic@digikod.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent c116475 commit 19ad209
1 file changed
Lines changed: 24 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
71 | 69 | | |
72 | 70 | | |
73 | 71 | | |
| |||
82 | 80 | | |
83 | 81 | | |
84 | 82 | | |
85 | | - | |
86 | | - | |
87 | | - | |
88 | | - | |
89 | | - | |
90 | | - | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | 83 | | |
97 | 84 | | |
98 | 85 | | |
| |||
437 | 424 | | |
438 | 425 | | |
439 | 426 | | |
440 | | - | |
| 427 | + | |
441 | 428 | | |
442 | 429 | | |
443 | 430 | | |
| |||
1016 | 1003 | | |
1017 | 1004 | | |
1018 | 1005 | | |
1019 | | - | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
| 1012 | + | |
| 1013 | + | |
1020 | 1014 | | |
1021 | 1015 | | |
1022 | 1016 | | |
| |||
1028 | 1022 | | |
1029 | 1023 | | |
1030 | 1024 | | |
1031 | | - | |
| 1025 | + | |
| 1026 | + | |
| 1027 | + | |
| 1028 | + | |
| 1029 | + | |
| 1030 | + | |
| 1031 | + | |
| 1032 | + | |
| 1033 | + | |
1032 | 1034 | | |
1033 | 1035 | | |
1034 | 1036 | | |
| |||
1083 | 1085 | | |
1084 | 1086 | | |
1085 | 1087 | | |
| 1088 | + | |
1086 | 1089 | | |
1087 | 1090 | | |
1088 | 1091 | | |
| |||
1218 | 1221 | | |
1219 | 1222 | | |
1220 | 1223 | | |
| 1224 | + | |
1221 | 1225 | | |
1222 | 1226 | | |
1223 | 1227 | | |
| |||
1236 | 1240 | | |
1237 | 1241 | | |
1238 | 1242 | | |
1239 | | - | |
1240 | | - | |
| 1243 | + | |
| 1244 | + | |
1241 | 1245 | | |
1242 | 1246 | | |
1243 | | - | |
| 1247 | + | |
1244 | 1248 | | |
1245 | 1249 | | |
1246 | 1250 | | |
1247 | 1251 | | |
| 1252 | + | |
1248 | 1253 | | |
1249 | 1254 | | |
1250 | 1255 | | |
| |||
0 commit comments