Merge pull request #393 from benrubson/sudo

Run "sudo" tests also if user is root
This commit is contained in:
Valient Gough 2017-08-27 11:37:02 -07:00 committed by GitHub
commit cc140546a1
2 changed files with 18 additions and 5 deletions

View File

@ -29,6 +29,7 @@ tests will run almost instantly:
Integration tests will take ~20 seconds to run and will mount an
encrypted filesystem and run tests on it:
*running integration tests from root (or with sudo) will run additional ones*
make integration

View File

@ -34,6 +34,7 @@ if(system("which lsextattr > /dev/null 2>&1") == 0)
$setattr = "setextattr -h user encfs hello";
$getattr = "getextattr -h user encfs";
}
# Do we support xattr ?
my $have_xattr = 1;
if(system("./build/encfs --verbose --version 2>&1 | grep -q HAVE_XATTR") != 0)
@ -41,6 +42,17 @@ if(system("./build/encfs --verbose --version 2>&1 | grep -q HAVE_XATTR") != 0)
$have_xattr = 0;
}
# Did we ask, or are we simply able to run "sudo" tests ?
my $sudo_cmd;
if ($> == 0)
{
$sudo_cmd="";
}
elsif (defined($ENV{'SUDO_TESTS'}))
{
$sudo_cmd="sudo";
}
# test filesystem in standard config mode
&runTests('standard');
@ -443,8 +455,8 @@ sub checkReadError
# Test that write errors are correctly thrown up to us
sub checkWriteError
{
# No OSX impl, and requires sudo which is inconvenient outside of CI.
if($^O eq "darwin" || !defined($ENV{'SUDO_TESTS'})) {
# No OSX impl (for now, feel free to find how to), and requires "sudo".
if($^O eq "darwin" || !defined($sudo_cmd)) {
ok(1, "write error");
ok(1, "write error");
ok(1, "write error");
@ -455,7 +467,7 @@ sub checkWriteError
my $mnt = "$workingDir/checkWriteError.mnt";
mkdir($crypt) || BAIL_OUT($!);
mkdir($mnt) || BAIL_OUT($!);
system("sudo mount -t tmpfs -o size=1m tmpfs $crypt");
system("$sudo_cmd mount -t tmpfs -o size=1m tmpfs $crypt");
ok( $? == 0, "mount command returns 0") || return;
system("./build/encfs --standard --extpass=\"echo test\" $crypt $mnt 2>&1");
ok( $? == 0, "encfs command returns 0") || return;
@ -464,6 +476,6 @@ sub checkWriteError
ok ($!{ENOSPC}, "write returned $! instead of ENOSPC");
close OUT;
portable_unmount($mnt);
system("sudo umount $crypt");
system("$sudo_cmd umount $crypt");
}
}