summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/.gitignore1
-rw-r--r--test/Makemodule.am4
-rw-r--r--test/root/getfattr.test4
-rwxr-xr-xtest/run15
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
diff --git a/test/run b/test/run
index 562d2c4..4b1f8d0 100755
--- a/test/run
+++ b/test/run
@@ -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: