diff options
-rw-r--r-- | test/.gitignore | 1 | ||||
-rw-r--r-- | test/Makemodule.am | 4 | ||||
-rw-r--r-- | test/root/getfattr.test | 4 | ||||
-rwxr-xr-x | test/run | 15 |
4 files changed, 20 insertions, 4 deletions
diff --git a/test/.gitignore b/test/.gitignore new file mode 100644 index 0000000..e6e5019 --- /dev/null +++ b/test/.gitignore @@ -0,0 +1 @@ +*.dir/ diff --git a/test/Makemodule.am b/test/Makemodule.am index 459a74c..deaed3a 100644 --- a/test/Makemodule.am +++ b/test/Makemodule.am @@ -1,8 +1,8 @@ XFAIL_TESTS = \ - test/ext/fs.test \ - test/root/getfattr.test + test/ext/fs.test TESTS = \ test/attr.test \ + test/root/getfattr.test \ $(XFAIL_TESTS) EXTRA_DIST += \ diff --git a/test/root/getfattr.test b/test/root/getfattr.test index d06d966..8319de7 100644 --- a/test/root/getfattr.test +++ b/test/root/getfattr.test @@ -1,3 +1,7 @@ +Cry immediately if we are not running as root. + + $ require_root + $ mkdir d $ cd d @@ -70,8 +70,10 @@ if (isatty(fileno(STDOUT))) { $FAILED = "\033[31m\033[1m" . $FAILED . "\033[m"; } +# Export this dir to tests so they can access data files if needed. +$ENV{"TESTDIR"} = abs_path(dirname($0)); # Add the current dir to PATH so we can find sort-getfattr-output and such. -$ENV{"PATH"} = abs_path(dirname($0)) . ":$ENV{PATH}"; +$ENV{"PATH"} = $ENV{"TESTDIR"} . ":$ENV{PATH}"; # Add the parent dir to PATH so we can find the compiled tools. $ENV{"PATH"} = dirname(abs_path(dirname($0))) . ":$ENV{PATH}"; $ENV{"TUSER"} = getpwuid($>); @@ -87,6 +89,7 @@ if (!mkdir($tmpdir)) { rmtree($tmpdir); mkdir($tmpdir) or die "could not create $tmpdir"; } +my $pretmpdir = getcwd(); chdir($tmpdir) or die "could not enter $tmpdir"; sub exec_test($$); @@ -141,7 +144,7 @@ if (isatty(fileno(STDOUT))) { print $status, "\n"; # Now clean up the testdir. -chdir(".."); +chdir($pretmpdir); rmtree($tmpdir); exit $failed ? 1 : 0; @@ -279,6 +282,14 @@ sub exec_test($$) { return su($prog->[1]); } elsif ($prog->[0] eq "sg") { return sg($prog->[1]); + } elsif ($prog->[0] eq "require_root") { + my $ret = su("root"); + if ($! != 0) { + print $ret->[0]; + warn "required root failed; skipping test"; + exit 77; + } + return []; } elsif ($prog->[0] eq "export") { my ($name, $value) = split /=/, $prog->[1]; # FIXME: need to evaluate $value, so that things like this will work: |