Correctly detect attr binary during tests

This commit is contained in:
benrubson 2017-06-13 11:12:30 +02:00 committed by Jakob Unterwurzacher
parent d216cc4208
commit 8d8506f2eb

View File

@ -13,6 +13,20 @@ require("tests/common.pl");
my $tempDir = $ENV{'TMPDIR'} || "/tmp";
# Find attr binary
# Linux
my @binattr = ("attr", "-l");
if(system("which xattr > /dev/null 2>&1") == 0)
{
# Mac OS X
@binattr = ("xattr", "-l");
}
if(system("which lsextattr > /dev/null 2>&1") == 0)
{
# FreeBSD
@binattr = ("lsextattr", "user");
}
# Helper function
# Create a new empty working directory
sub newWorkingDir
@ -84,7 +98,7 @@ sub symlink_test
$dec = readlink("$decrypted/symlink");
ok( $dec eq $target, "symlink to '$target'") or
print("# (original) $target' != '$dec' (decrypted)\n");
system("attr", "-l", "$decrypted/symlink");
system(@binattr, "$decrypted/symlink");
my $return_code = $?;
is($return_code, 0, "symlink to '$target' extended attributes can be read (return code was $return_code)");
unlink("$plain/symlink");