test/recipes/90-test_store.t: Add a few cases with files starting with 'file:'
authorRichard Levitte <levitte@openssl.org>
Wed, 12 Jul 2017 10:42:16 +0000 (12:42 +0200)
committerRichard Levitte <levitte@openssl.org>
Sat, 15 Jul 2017 16:53:07 +0000 (18:53 +0200)
These cases are performed on Linux only.  They check that files with
names starting with 'file:' can be processed as well.

Reviewed-by: Andy Polyakov <appro@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3907)

test/recipes/90-test_store.t

index aae46963c0e765f6891b9b5fc0d7dca01d5186b0..699a67ee81a6045537fc05d0ac78de8699399538 100644 (file)
@@ -7,6 +7,7 @@
 # https://www.openssl.org/source/license.html
 
 use File::Spec;
+use File::Copy;
 use MIME::Base64;
 use OpenSSL::Test qw(:DEFAULT srctop_file srctop_dir bldtop_file data_file);
 
@@ -55,10 +56,24 @@ my @generated_files =
      "ec-key-pkcs8-pbes2-sha1.pem", "ec-key-pkcs8-pbes2-sha1.der",
      "ec-key-aes256-cbc-sha256.p12",
     );
+my %generated_file_files =
+    $^O eq 'linux'
+    ? ( "test/testx509.pem" => "file:testx509.pem",
+        "test/testrsa.pem" => "file:testrsa.pem",
+        "test/testrsapub.pem" => "file:testrsapub.pem",
+        "test/testcrl.pem" => "file:testcrl.pem",
+        "apps/server.pem" => "file:server.pem" )
+    : ();
+my @noexist_file_files =
+    ( "file:blahdiblah.pem",
+      "file:test/blahdibleh.der" );
+
 
 my $n = (3 * scalar @noexist_files)
     + (6 * scalar @src_files)
     + (4 * scalar @generated_files)
+    + (scalar keys %generated_file_files)
+    + (scalar @noexist_file_files)
     + 3;
 
 plan tests => $n;
@@ -96,6 +111,12 @@ indir "store_$$" => sub {
             ok(!run(app(["openssl", "storeutl", "-passin", "pass:password",
                          to_file_uri($_)])));
         }
+        foreach (values %generated_file_files) {
+            ok(run(app(["openssl", "storeutl", $_])));
+        }
+        foreach (@noexist_file_files) {
+            ok(!run(app(["openssl", "storeutl", $_])));
+        }
         {
             my $dir = srctop_dir("test", "certs");
             ok(run(app(["openssl", "storeutl", $dir])));
@@ -287,6 +308,16 @@ sub init {
                           close $outfh;
                           return 1;
                       }, grep(/\.der$/, @generated_files))
+            && runall(sub {
+                          my $srcfile = shift;
+                          my $dstfile = $generated_file_files{$srcfile};
+
+                          unless (copy srctop_file($srcfile), $dstfile) {
+                              warn "$!\n";
+                              return 0;
+                          }
+                          return 1;
+                      }, keys %generated_file_files)
            );
 }