tests: check if the second mount works as well

Should prevent things like https://github.com/vgough/encfs/issues/343
from happening again.
This commit is contained in:
Jakob Unterwurzacher 2017-07-19 22:15:29 +02:00 committed by rfjakob
parent c8ff1f94e8
commit 64b01a0869
2 changed files with 43 additions and 2 deletions

10
test.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash -eu
./build/checkops &> /dev/null
for i in $(mount | grep -e "/tmp/encfs-reverse-tests-\|/tmp/encfs-tests-" | cut -f3 -d" "); do
echo "Warning: unmounting leftover filesystem: $i"
fusermount -u $i
done
perl -MTest::Harness -e '$$Test::Harness::debug=1; runtests @ARGV;' tests/*.t.pl

View File

@ -2,7 +2,7 @@
# Test EncFS normal and paranoid mode
use Test::More tests => 106;
use Test::More tests => 116;
use File::Path;
use File::Copy;
use File::Temp;
@ -47,6 +47,7 @@ sub runTests
&internalModification;
&grow;
&umask0777;
&create_unmount_remount;
&configFromPipe;
&cleanup;
@ -196,7 +197,7 @@ sub fileCreation
# ensure there is an encrypted version.
my $c = encName("df.txt");
cmp_ok( length($c), '>', 8, "encrypted name ok" );
ok( -f "$raw/$c", "encrypted file created" );
ok( -f "$raw/$c", "encrypted file $raw/$c created" );
# check contents
my $count = qx(grep -c crypt-$$ "$crypt/df.txt");
@ -360,3 +361,33 @@ sub configFromPipe
waitpid($child, 0);
ok( 0 == $?, "encfs mount with named pipe based config failed");
}
sub create_unmount_remount
{
my $crypt = "$workingDir/create_remount.crypt";
my $mnt = "$workingDir/create_remount.mnt";
mkdir($crypt) || BAIL_OUT($!);
mkdir($mnt) || BAIL_OUT($!);
system("./build/encfs --standard --extpass=\"echo test\" $crypt $mnt 2>&1");
ok( $? == 0, "encfs command returns 0") || return;
ok( -f "$crypt/.encfs6.xml", "created control file") || return;
# Write some text
my $contents = "hello world\n";
ok( open(OUT, "> $mnt/test_file_1"), "write content");
print OUT $contents;
close OUT;
# Unmount
portable_unmount($mnt);
# Mount again
system("./build/encfs --extpass=\"echo test\" $crypt $mnt 2>&1");
ok( $? == 0, "encfs command returns 0") || return;
# Check if content is still there
checkContents("$mnt/test_file_1", $contents);
portable_unmount($mnt);
}