[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Acl-devel] [PATCH attr 2/2] test: fix cleanup & running as root
From: |
Mike Frysinger |
Subject: |
[Acl-devel] [PATCH attr 2/2] test: fix cleanup & running as root |
Date: |
Fri, 10 Jan 2014 10:07:34 -0500 |
This fixes a bug when doing the cleanup of tests in a subdir by making
sure we chdir back to our starting point.
We also move the root test out of XFAIL and instead do the root checking
at runtime. If we are root, the test passes nicely, otherwise it marks
itself as SKIP quickly.
These are fixing issues noticed when doing the update to libacl.
---
test/.gitignore | 1 +
test/Makemodule.am | 4 ++--
test/root/getfattr.test | 4 ++++
test/run | 15 +++++++++++++--
4 files changed, 20 insertions(+), 4 deletions(-)
create mode 100644 test/.gitignore
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:
--
1.8.4.3