diff --git a/tests/auth/writeoldkey-t b/tests/auth/writeoldkey-t index 614dcb6031..efb32a1d26 100755 --- a/tests/auth/writeoldkey-t +++ b/tests/auth/writeoldkey-t @@ -7,7 +7,7 @@ use lib $ENV{C_TAP_SOURCE} . "/tests-lib/perl5"; use afstest qw(src_path obj_path); use Test::More; use File::Temp qw/tempdir/; -use Cwd qw/abs_path/; +use Cwd qw/abs_path getcwd/; use File::Compare; use Sys::Hostname; use Socket; @@ -27,6 +27,7 @@ $cmd = abs_path($cmd); my $keyfile = src_path("tests/auth/KeyFile.short"); $keyfile = abs_path($keyfile); +my $origdir = getcwd(); my $dir = tempdir('afs_XXXXXX', CLEANUP => 1); chdir($dir) @@ -37,3 +38,7 @@ system($cmd) == 0 ok(compare("KeyFile", $keyfile) == 0, "writekeyfile generates expected KeyFile"); + +# The cleanup handler needs to run in the original directory. +chdir($origdir) + or die("chdir $origdir failed: $?");