diff options
author | Richard Levitte <levitte@openssl.org> | 2016-06-20 14:03:12 +0200 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2016-06-21 14:52:34 +0200 |
commit | 3da9eeb1582ed06aad55aa1b450e37376fedf3ab (patch) | |
tree | 39c32beb9c83c1489b7c3dc89392061122c02298 /test/testlib | |
parent | c952780c25f67d0645ef5e57a8ac7dae6ce2d586 (diff) |
OpenSSL::Test: Fix directory calculations in __cwd()
We recalculate the location of the directories we keep track of.
However, we did so after having moved to the new directory already, so
the data we did the calculations from were possibly not quite correct.
This change moves the calculations to happen before moving to the new
directory.
This issue is sporadic, and possibly dependent on the platform.
Reviewed-by: Matt Caswell <matt@openssl.org>
Diffstat (limited to 'test/testlib')
-rw-r--r-- | test/testlib/OpenSSL/Test.pm | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm index 2cfb22a653..6a10afd653 100644 --- a/test/testlib/OpenSSL/Test.pm +++ b/test/testlib/OpenSSL/Test.pm @@ -821,12 +821,10 @@ sub __cwd { mkpath($dir); } - # Should we just bail out here as well? I'm unsure. - return undef unless chdir($dir); - - if ($opts{cleanup}) { - rmtree(".", { safe => 0, keep_root => 1 }); - } + # We are recalculating the directories we keep track of, but need to save + # away the result for after having moved into the new directory. + my %tmp_directories = (); + my %tmp_ENV = (); # For each of these directory variables, figure out where they are relative # to the directory we want to move to if they aren't absolute (if they are, @@ -835,7 +833,7 @@ sub __cwd { foreach (@dirtags) { if (!file_name_is_absolute($directories{$_})) { my $newpath = abs2rel(rel2abs($directories{$_}), rel2abs($dir)); - $directories{$_} = $newpath; + $tmp_directories{$_} = $newpath; } } @@ -845,10 +843,22 @@ sub __cwd { foreach (@direnv) { if (!file_name_is_absolute($ENV{$_})) { my $newpath = abs2rel(rel2abs($ENV{$_}), rel2abs($dir)); - $ENV{$_} = $newpath; + $tmp_ENV{$_} = $newpath; } } + # Should we just bail out here as well? I'm unsure. + return undef unless chdir($dir); + + if ($opts{cleanup}) { + rmtree(".", { safe => 0, keep_root => 1 }); + } + + %directories = %tmp_directories; + foreach (keys %tmp_ENV) { + $ENV{$_} = $tmp_ENV{$_}; + } + if ($debug) { print STDERR "DEBUG: __cwd(), directories and files:\n"; print STDERR " \$directories{BLDTEST} = \"$directories{BLDTEST}\"\n"; |