[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Wed Sep 9 17:12:14 UTC 2015


The branch master has been updated
       via  84d90cf335209e6c1dcb5124d2ddf14ea617212f (commit)
       via  ceffb33db28d067fde07531c3fd36a0ed4b95ded (commit)
      from  2dcac136a8c4e37646b717b68eeccc191d074bf0 (commit)


- Log -----------------------------------------------------------------
commit 84d90cf335209e6c1dcb5124d2ddf14ea617212f
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Sep 9 17:36:21 2015 +0200

    Add a simple test for the new rehash command
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

commit ceffb33db28d067fde07531c3fd36a0ed4b95ded
Author: Richard Levitte <levitte at openssl.org>
Date:   Wed Sep 9 17:29:06 2015 +0200

    Make sure the temporary error log resides in a well defined location
    
    If a test recipe does something like this:
    
        indir "foo.$$" => sub {
            chmod 0500, File::Spec->curdir();
            ok(run(app(["something"])));
        }
    
    we get a problem, because we were storing the temporary stderr file in
    the current directory at all times (so while inside the 'indir', we
    would attemp to store it in "foo.$$").
    
    So, change our ways to always store that temporary file in the exact
    same location, defined by the environment variable RESULT_D, or
    failing that TEST_D, or failing that $TOP/test.
    
    Reviewed-by: Rich Salz <rsalz at openssl.org>

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

Summary of changes:
 test/recipes/40-test_rehash.t | 56 +++++++++++++++++++++++++++++++++++++++++++
 test/testlib/OpenSSL/Test.pm  |  3 ++-
 2 files changed, 58 insertions(+), 1 deletion(-)
 create mode 100644 test/recipes/40-test_rehash.t

diff --git a/test/recipes/40-test_rehash.t b/test/recipes/40-test_rehash.t
new file mode 100644
index 0000000..514d0d3
--- /dev/null
+++ b/test/recipes/40-test_rehash.t
@@ -0,0 +1,56 @@
+#! /usr/bin/perl
+
+use strict;
+use warnings;
+
+use File::Spec::Functions;
+use File::Copy;
+use File::Basename;
+use OpenSSL::Test qw/:DEFAULT top_file/;
+
+setup("test_rehash");
+
+plan tests => 4;
+
+indir "rehash.$$" => sub {
+    prepare();
+    ok(run(app(["openssl", "rehash", curdir()])),
+       'Testing normal rehash operations');
+}, create => 1, cleanup => 1;
+
+indir "rehash.$$" => sub {
+    prepare(sub { chmod 400, $_ foreach (@_); });
+    ok(run(app(["openssl", "rehash", curdir()])),
+       'Testing rehash operations on readonly files');
+}, create => 1, cleanup => 1;
+
+indir "rehash.$$" => sub {
+    ok(run(app(["openssl", "rehash", curdir()])),
+       'Testing rehash operations on empty directory');
+}, create => 1, cleanup => 1;
+
+indir "rehash.$$" => sub {
+    prepare();
+    chmod 0500, curdir();
+    isnt(run(app(["openssl", "rehash", curdir()])), 1,
+         'Testing rehash operations on readonly directory');
+    chmod 0700, curdir();       # make it writable again, so cleanup works
+}, create => 1, cleanup => 1;
+
+sub prepare {
+    my @sourcefiles =
+        sort map { glob(top_file('certs', 'demo', "*.$_")) } ('pem',
+                                                              'crt',
+                                                              'cer',
+                                                              'crl');
+    my @destfiles = ();
+    foreach (@sourcefiles) {
+        copy($_, curdir());
+        push @destfiles, catfile(curdir(), basename($_));
+    }
+    foreach (@_) {
+        die "Internal error, argument is not CODE"
+            unless (ref($_) eq 'CODE');
+        $_->(@destfiles);
+    }
+}
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm
index f378351..c64d68d 100644
--- a/test/testlib/OpenSSL/Test.pm
+++ b/test/testlib/OpenSSL/Test.pm
@@ -720,7 +720,8 @@ sub __build_cmd {
 
     $saved_stderr = $opts{stderr}		if defined($opts{stderr});
 
-    my $errlog = $num ? "$test_name.$num.tmp_err" : "$test_name.tmp_err";
+    my $errlog =
+        __results_file($num ? "$test_name.$num.tmp_err" : "$test_name.tmp_err");
     my $display_cmd = "$cmd$arg_str$stdin$stdout$stderr";
     $cmd .= "$arg_str$stdin$stdout 2> $errlog";
 


More information about the openssl-commits mailing list