mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-11 02:13:56 +09:00
Userland: Unlink file after waiting for child in run-tests
TestProcFs expects to be able to stat its stdout and stderr. The new ProcFS implemetnation properly forwards the symlinks for /proc/pid/fd/[1,2] to the temporary file that we had unlinked prior to spawning the process. However, this makes it so that a normal stat on the symlink to that file fails (as expected). Move the unlink to after we've waited on the child, so that we know it won't be trying any funny business with its stdout/stderr anymore.
This commit is contained in:
parent
cc0a376c95
commit
ae4240788c
Notes:
sideshowbarker
2024-07-18 11:14:56 +09:00
Author: https://github.com/ADKaster
Commit: ae4240788c
Pull-request: https://github.com/SerenityOS/serenity/pull/8328
1 changed files with 7 additions and 4 deletions
|
@ -193,9 +193,6 @@ FileResult TestRunner::run_test_file(const String& test_path)
|
|||
int child_out_err_file = mkstemp(child_out_err_path);
|
||||
VERIFY(child_out_err_file >= 0);
|
||||
|
||||
int ret = unlink(child_out_err_path);
|
||||
VERIFY(ret == 0);
|
||||
|
||||
(void)posix_spawn_file_actions_adddup2(&file_actions, child_out_err_file, STDOUT_FILENO);
|
||||
(void)posix_spawn_file_actions_adddup2(&file_actions, child_out_err_file, STDERR_FILENO);
|
||||
(void)posix_spawn_file_actions_addchdir(&file_actions, path_for_test.dirname().characters());
|
||||
|
@ -209,7 +206,7 @@ FileResult TestRunner::run_test_file(const String& test_path)
|
|||
|
||||
pid_t child_pid = -1;
|
||||
// FIXME: Do we really want to copy test runner's entire env?
|
||||
ret = posix_spawn(&child_pid, test_path.characters(), &file_actions, nullptr, const_cast<char* const*>(argv.data()), environ);
|
||||
int ret = posix_spawn(&child_pid, test_path.characters(), &file_actions, nullptr, const_cast<char* const*>(argv.data()), environ);
|
||||
VERIFY(ret == 0);
|
||||
VERIFY(child_pid > 0);
|
||||
|
||||
|
@ -234,6 +231,12 @@ FileResult TestRunner::run_test_file(const String& test_path)
|
|||
kill(child_pid, SIGCONT);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the child's stdout from /tmp. This does cause the temp file to be observable
|
||||
// while the test is executing, but if it hangs that might even be a bonus :)
|
||||
ret = unlink(child_out_err_path);
|
||||
VERIFY(ret == 0);
|
||||
|
||||
return FileResult { move(path_for_test), get_time_in_ms() - start_time, test_result, child_out_err_file };
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue