Check if test was killed by signal in makeTestFile.
Tests killed by a signal should cause the .t script to exit with an error code, otherwise its exit code will be 0, and the test harness won't be aware of the unsuccessful exit. This change also makes the test runner more robust, so attaching to a running test (e.g. with gdb or strace) won't cause the .t script to exit.
This commit is contained in:
committed by
Andrew Johnson
parent
54ca2cb595
commit
cb0688c850
@@ -140,6 +140,8 @@ else {
|
||||
######################################## Code for Unix run-hosts
|
||||
print $OUT <<__UNIX__;
|
||||
|
||||
use POSIX qw(WIFEXITED WIFSIGNALED WEXITSTATUS);
|
||||
|
||||
my \$pid = fork();
|
||||
die "\$tool: Can't fork for '$error': \$!\\n"
|
||||
unless defined \$pid;
|
||||
@@ -154,9 +156,19 @@ if (\$pid) {
|
||||
};
|
||||
|
||||
alarm \$timeout;
|
||||
waitpid \$pid, 0;
|
||||
alarm 0;
|
||||
exit \$? >> 8;
|
||||
while (1) {
|
||||
waitpid \$pid, 0;
|
||||
if (WIFEXITED(\$?)) {
|
||||
# normal exit
|
||||
alarm 0;
|
||||
exit WEXITSTATUS(\$?);
|
||||
} elsif (WIFSIGNALED(\$?)) {
|
||||
# terminated by signal
|
||||
alarm 0;
|
||||
die "\$tool: Test was terminated by signal '\$?'\\n";
|
||||
}
|
||||
# non-terminal change of status, continue waiting
|
||||
}
|
||||
}
|
||||
else {
|
||||
# Child process
|
||||
|
||||
Reference in New Issue
Block a user