From 64b01a086965e7fc74103473de8d07ef926c4a01 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Wed, 19 Jul 2017 22:15:29 +0200 Subject: [PATCH] tests: check if the second mount works as well Should prevent things like https://github.com/vgough/encfs/issues/343 from happening again. --- test.sh | 10 ++++++++++ tests/normal.t.pl | 35 +++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) create mode 100755 test.sh diff --git a/test.sh b/test.sh new file mode 100755 index 0000000..6609005 --- /dev/null +++ b/test.sh @@ -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 diff --git a/tests/normal.t.pl b/tests/normal.t.pl index 1f2d7f8..b65274c 100755 --- a/tests/normal.t.pl +++ b/tests/normal.t.pl @@ -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); +}