[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Fri Mar 18 14:26:16 UTC 2016


The branch master has been updated
       via  ef33d131850440da8556f08996f63898e849d267 (commit)
       via  2ef157afb9254d043b0f8e0909c7f050bb5389a5 (commit)
      from  71cdcfc6069ca8afe92cda636805a8c46f000862 (commit)


- Log -----------------------------------------------------------------
commit ef33d131850440da8556f08996f63898e849d267
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri Mar 18 12:16:53 2016 +0100

    Add a test to see that signals are caught as failures
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>
    Reviewed-by: Emilia Käsper <emilia at openssl.org>

commit 2ef157afb9254d043b0f8e0909c7f050bb5389a5
Author: Richard Levitte <levitte at openssl.org>
Date:   Fri Mar 18 08:57:52 2016 +0100

    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 at openssl.org>
    Reviewed-by: Emilia Käsper <emilia at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 test/aborttest.c             | 17 +++++++++++++++++
 test/build.info              |  5 +++++
 test/recipes/01-test_abort.t |  9 +++++++++
 test/testlib/OpenSSL/Test.pm |  9 +++++++--
 4 files changed, 38 insertions(+), 2 deletions(-)
 create mode 100644 test/aborttest.c
 create mode 100644 test/recipes/01-test_abort.t

diff --git a/test/aborttest.c b/test/aborttest.c
new file mode 100644
index 0000000..98aeddf
--- /dev/null
+++ b/test/aborttest.c
@@ -0,0 +1,17 @@
+/*
+ * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ *
+ * Licensed under the OpenSSL licenses, (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * https://www.openssl.org/source/license.html
+ * or in the file LICENSE in the source distribution.
+ */
+
+#include <openssl/crypto.h>
+
+int main(int argc, char **argv)
+{
+    OPENSSL_die("Voluntary abort", __FILE__, __LINE__);
+    return 0;
+}
diff --git a/test/build.info b/test/build.info
index cd5d8cd..74f83a3 100644
--- a/test/build.info
+++ b/test/build.info
@@ -1,5 +1,6 @@
 {- use File::Spec::Functions qw/catdir rel2abs/; -}
 PROGRAMS=\
+        aborttest \
         nptest bntest \
         ectest ecdsatest ecdhtest gmdifftest pbelutest ideatest \
         md2test md4test md5test \
@@ -15,6 +16,10 @@ PROGRAMS=\
         packettest asynctest secmemtest srptest memleaktest \
         dtlsv1listentest ct_test threadstest afalgtest
 
+SOURCE[aborttest]=aborttest.c
+INCLUDE[aborttest]={- rel2abs(catdir($builddir,"../include")) -} ../include
+DEPEND[aborttest]=../libcrypto
+
 SOURCE[nptest]=nptest.c
 INCLUDE[nptest]={- rel2abs(catdir($builddir,"../include")) -} ../include
 DEPEND[nptest]=../libcrypto
diff --git a/test/recipes/01-test_abort.t b/test/recipes/01-test_abort.t
new file mode 100644
index 0000000..4a6cf97
--- /dev/null
+++ b/test/recipes/01-test_abort.t
@@ -0,0 +1,9 @@
+#! /usr/bin/perl
+
+use OpenSSL::Test;
+
+setup("test_abort");
+
+plan tests => 1;
+
+is(run(test(["aborttest"])), 0, "Testing that abort is caught correctly");
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm
index ecac93f..2b0c050 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);
     }
 


More information about the openssl-commits mailing list