summaryrefslogtreecommitdiffstats
path: root/util
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2021-06-10 13:00:54 +0200
committerTomas Mraz <tomas@openssl.org>2021-06-10 15:24:05 +0200
commitbedda72ff771a41c317daa7bdb7cbe14608fbc03 (patch)
tree9e5d23482211597e59612c114691c551dc0be6d6 /util
parent586820831afdd01954d82cb068e252cb1772081c (diff)
OpenSSL::Test: Treat SRCDATA directory specially, as it might not exist
Not all tests come with a SRCDATA directory. if it doesn't exist, we simply drop it from the internal table of directories. OpenSSL::Test::srcdata_dir() and OpenSSL::Test::srcdata_file() may return undef in that case. However, recipes shouldn't try to refer to a non-existing data directory, so if that happens, it's a programming error and must be corrected. Fixes #15679 Reviewed-by: Paul Dale <pauli@openssl.org> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/15700)
Diffstat (limited to 'util')
-rw-r--r--util/perl/OpenSSL/Test.pm11
1 files changed, 10 insertions, 1 deletions
diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm
index ee6962931b..00db3d41c8 100644
--- a/util/perl/OpenSSL/Test.pm
+++ b/util/perl/OpenSSL/Test.pm
@@ -995,6 +995,10 @@ sub __env {
rmtree($directories{RESULTS}, { safe => 0, keep_root => 1 });
mkpath($directories{RESULTS});
+ # All directories are assumed to exist, except for SRCDATA. If that one
+ # doesn't exist, just drop it.
+ delete $directories{SRCDATA} unless -d $directories{SRCDATA};
+
push @direnv, "TOP" if $ENV{TOP};
push @direnv, "SRCTOP" if $ENV{SRCTOP};
push @direnv, "BLDTOP" if $ENV{BLDTOP};
@@ -1094,6 +1098,8 @@ sub __fuzz_file {
sub __data_file {
BAIL_OUT("Must run setup() first") if (! $test_name);
+ return undef unless exists $directories{SRCDATA};
+
my $f = pop;
return catfile($directories{SRCDATA},@_,$f);
}
@@ -1101,6 +1107,8 @@ sub __data_file {
sub __data_dir {
BAIL_OUT("Must run setup() first") if (! $test_name);
+ return undef unless exists $directories{SRCDATA};
+
return catdir($directories{SRCDATA},@_);
}
@@ -1200,7 +1208,8 @@ sub __cwd {
print STDERR "\n";
print STDERR " \$directories{BLDTEST} = \"$directories{BLDTEST}\"\n";
print STDERR " \$directories{SRCTEST} = \"$directories{SRCTEST}\"\n";
- print STDERR " \$directories{SRCDATA} = \"$directories{SRCDATA}\"\n";
+ print STDERR " \$directories{SRCDATA} = \"$directories{SRCDATA}\"\n"
+ if exists $directories{SRCDATA};
print STDERR " \$directories{RESULTS} = \"$directories{RESULTS}\"\n";
print STDERR " \$directories{BLDAPPS} = \"$directories{BLDAPPS}\"\n";
print STDERR " \$directories{SRCAPPS} = \"$directories{SRCAPPS}\"\n";