diff --git a/tests/common.pl b/tests/common.pl index d997114..3a14e36 100755 --- a/tests/common.pl +++ b/tests/common.pl @@ -1,3 +1,16 @@ +# Portable FUSE unmount +# works on Linux AND OSX +sub portable_unmount { + my $crypt = shift; + my $fusermount = qx(which fusermount); + chomp($fusermount); + if(-f $fusermount) { + qx($fusermount -u "$crypt"); + } else { + qx(umount "$crypt"); + } +} + # Helper function # Get the MD5 sum of the file open at the filehandle use Digest::MD5 qw(md5_hex); diff --git a/tests/normal.t.pl b/tests/normal.t.pl index 7f0d779..b38a19d 100755 --- a/tests/normal.t.pl +++ b/tests/normal.t.pl @@ -316,15 +316,7 @@ sub mount # Unmount and delete mountpoint sub cleanup { - my $fusermount = qx(which fusermount); - chomp($fusermount); - if(-f $fusermount) - { - qx($fusermount -u "$crypt"); - } else - { - qx(umount "$crypt"); - } + portable_unmount($crypt); rmdir $crypt; ok( ! -d $crypt, "unmount ok, mount point removed"); diff --git a/tests/reverse.t.pl b/tests/reverse.t.pl index 35a98b8..b7f9196 100755 --- a/tests/reverse.t.pl +++ b/tests/reverse.t.pl @@ -32,8 +32,8 @@ sub newWorkingDir # Unmount and delete mountpoint sub cleanup { - system("fusermount -u $decrypted"); - system("fusermount -u $ciphertext"); + portable_unmount($decrypted); + portable_unmount($ciphertext); our $workingDir; rmtree($workingDir); ok( ! -d $workingDir, "working dir removed");