From: Richard Levitte Date: Thu, 10 Jun 2021 11:00:54 +0000 (+0200) Subject: OpenSSL::Test: Treat SRCDATA directory specially, as it might not exist X-Git-Tag: openssl-3.0.0-beta1~106 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bedda72ff771a41c317daa7bdb7cbe14608fbc03;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15700) --- diff --git a/util/perl/OpenSSL/Test.pm b/util/perl/OpenSSL/Test.pm index ee6962931b9..00db3d41c89 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";