Skip to content

Commit

Permalink
tests: check if the second mount works as well
Browse files Browse the repository at this point in the history
Should prevent things like #343
from happening again.
  • Loading branch information
rfjakob committed Jul 19, 2017
1 parent c8ff1f9 commit 64b01a0
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
10 changes: 10 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -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
35 changes: 33 additions & 2 deletions tests/normal.t.pl
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,6 +47,7 @@ sub runTests
&internalModification;
&grow;
&umask0777;
&create_unmount_remount;

&configFromPipe;
&cleanup;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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);
}

0 comments on commit 64b01a0

Please sign in to comment.