summaryrefslogtreecommitdiffstats
path: root/test/testlib
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2016-03-18 08:57:52 +0100
committerRichard Levitte <levitte@openssl.org>2016-03-18 15:25:23 +0100
commit2ef157afb9254d043b0f8e0909c7f050bb5389a5 (patch)
tree2a855d4b6c7d8d5a695b385dbfbe8cc0fb863715 /test/testlib
parent71cdcfc6069ca8afe92cda636805a8c46f000862 (diff)
Make OpenSSL::Test::run() sensitive to signals
$? in perl gets the status value from wait(2), which is a word with the exit code in the upper half and the number of a raised signal in the lower half. OpenSSL::Test::run() ignored the signal half up until now. With this change, we recalculate an exit code the same way the Unix shells do, using this formula: ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8); Reviewed-by: Rich Salz <rsalz@openssl.org> Reviewed-by: Emilia Käsper <emilia@openssl.org>
Diffstat (limited to 'test/testlib')
-rw-r--r--test/testlib/OpenSSL/Test.pm9
1 files changed, 7 insertions, 2 deletions
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm
index ecac93f8db..2b0c0506c8 100644
--- a/test/testlib/OpenSSL/Test.pm
+++ b/test/testlib/OpenSSL/Test.pm
@@ -324,12 +324,17 @@ sub run {
my @r = ();
my $r = 0;
my $e = 0;
+
+ # The dance we do with $? is the same dance the Unix shells appear to
+ # do. For example, a program that gets aborted (and therefore signals
+ # SIGABRT = 6) will appear to exit with the code 134. We mimic this
+ # to make it easier to compare with a manual run of the command.
if ($opts{capture}) {
@r = `$prefix$cmd`;
- $e = $? >> 8;
+ $e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);
} else {
system("$prefix$cmd");
- $e = $? >> 8;
+ $e = ($? & 0x7f) ? ($? & 0x7f)|0x80 : ($? >> 8);
$r = $hooks{exit_checker}->($e);
}