Skip to content

Commit

Permalink
Run sudo tests also if user is root
Browse files Browse the repository at this point in the history
  • Loading branch information
benrubson committed Aug 26, 2017
1 parent 03d0ae7 commit c7cea40
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
3 changes: 2 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ tests will run almost instantly:
make test

Integration tests will take ~20 seconds to run and will mount an
encrypted filesystem and run tests on it:
encrypted filesystem and run tests on it:
*running integration tests from root (or with sudo) will run additional ones*

make integration

Expand Down
20 changes: 16 additions & 4 deletions integration/normal.t.pl
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,25 @@
$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)
{
$have_xattr = 0;
}

# Did we ask, or are we simply able to run "sudo" tests ?
my $sudo_cmd;
if (! $<)
{
$sudo_cmd="";
}
elsif (defined($ENV{'SUDO_TESTS'}))
{
$sudo_cmd="sudo";
}

# test filesystem in standard config mode
&runTests('standard');

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

0 comments on commit c7cea40

Please sign in to comment.