Skip to content
Snippets Groups Projects
Commit 6a246f5c authored by Tony Wasserka's avatar Tony Wasserka Committed by Marge Bot
Browse files

aco/tests: Fix deadlock for too large test lists


The write() to the communication pipe shared with check_output.py would block
for large test output streams since the pipe's consumer wouldn't be launched
until the write already completed.

Reviewed-by: default avatarDaniel Schürmann <daniel@schuermann.dev>
Part-of: <mesa/mesa!7461>
parent a240341e
No related branches found
No related tags found
Loading
......@@ -173,14 +173,28 @@ int check_output(char **argv)
int stdin_pipe[2];
pipe(stdin_pipe);
write(stdin_pipe[1], checker_stdin_data, checker_stdin_size);
close(stdin_pipe[1]);
dup2(stdin_pipe[0], STDIN_FILENO);
execlp(ACO_TEST_PYTHON_BIN, ACO_TEST_PYTHON_BIN, ACO_TEST_SOURCE_DIR "/check_output.py", NULL);
fprintf(stderr, "%s: execl() failed: %s\n", argv[0], strerror(errno));
return 99;
pid_t child_pid = fork();
if (child_pid == -1) {
fprintf(stderr, "%s: fork() failed: %s\n", argv[0], strerror(errno));
return 99;
} else if (child_pid != 0) {
/* Evaluate test output externally using Python */
dup2(stdin_pipe[0], STDIN_FILENO);
close(stdin_pipe[0]);
close(stdin_pipe[1]);
execlp(ACO_TEST_PYTHON_BIN, ACO_TEST_PYTHON_BIN, ACO_TEST_SOURCE_DIR "/check_output.py", NULL);
fprintf(stderr, "%s: execlp() failed: %s\n", argv[0], strerror(errno));
return 99;
} else {
/* Feed input data to the Python process. Writing large streams to
* stdin will block eventually, so this is done in a forked process
* to let the test checker process chunks of data as they arrive */
write(stdin_pipe[1], checker_stdin_data, checker_stdin_size);
close(stdin_pipe[0]);
close(stdin_pipe[1]);
exit(0);
}
}
bool match_test(std::string name, std::string pattern)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment