[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Acl-devel] [PATCH attr 3/5] test: make running parallel/out-of-tree saf
From: |
Mike Frysinger |
Subject: |
[Acl-devel] [PATCH attr 3/5] test: make running parallel/out-of-tree safe |
Date: |
Wed, 8 Jan 2014 14:29:18 -0500 |
Change the run program to update PATH to find the tools locally
automatically. This lets us avoid having to always build in the
tree and allows for direct running.
Also update the program to create a tempdir for each test to run
inside of. This way we can run all the tests in parallel without
randomly clobbering each other.
---
test/attr.test | 26 +++++++++++++-------------
test/root/getfattr.test | 16 ++++++++--------
test/run | 26 +++++++++++++++++++++++++-
3 files changed, 46 insertions(+), 22 deletions(-)
diff --git a/test/attr.test b/test/attr.test
index c9a8ee0..5cb810e 100644
--- a/test/attr.test
+++ b/test/attr.test
@@ -139,7 +139,7 @@ Test extended attribute block sharing
$ touch f g h
$ setfattr -n user.novalue f g h
- $ getfattr f g h | ../sort-getfattr-output
+ $ getfattr f g h | sort-getfattr-output
> # file: f
> user.novalue
>
@@ -151,7 +151,7 @@ Test extended attribute block sharing
>
$ setfattr -n user.name -v value f
- $ getfattr f g h | ../sort-getfattr-output
+ $ getfattr f g h | sort-getfattr-output
> # file: f
> user.name
> user.novalue
@@ -163,7 +163,7 @@ Test extended attribute block sharing
> user.novalue
>
- $ getfattr -d f g h | ../sort-getfattr-output
+ $ getfattr -d f g h | sort-getfattr-output
> # file: f
> user.name="value"
> user.novalue
@@ -176,7 +176,7 @@ Test extended attribute block sharing
>
$ setfattr -n user.name -v value g
- $ getfattr f g h | ../sort-getfattr-output
+ $ getfattr f g h | sort-getfattr-output
> # file: f
> user.name
> user.novalue
@@ -190,7 +190,7 @@ Test extended attribute block sharing
>
$ setfattr -x user.novalue h
- $ getfattr f g h | ../sort-getfattr-output
+ $ getfattr f g h | sort-getfattr-output
> # file: f
> user.name
> user.novalue
@@ -211,7 +211,7 @@ Attributes of symlinks vs. the files pointed to
$ setfattr -h -n user.filename -v l l
> setfattr: l: Operation not permitted
- $ getfattr -d f l | ../sort-getfattr-output
+ $ getfattr -d f l | sort-getfattr-output
> # file: f
> user.filename="l"
>
@@ -276,7 +276,7 @@ Tests for proper path recursion reported by Tony Ernst
<address@hidden> bnc#457660
$ setfattr -n "user.9" 1/2/3
$ setfattr -n "user.a" 1/2/3
- $ getfattr -h -L -R -m '.' -e hex 1 | grep -v selinux |
./sort-getfattr-output
+ $ getfattr -h -L -R -m '.' -e hex 1 | grep -v selinux |
sort-getfattr-output
> # file: 1
> user.9
> user.a
@@ -290,7 +290,7 @@ Tests for proper path recursion reported by Tony Ernst
<address@hidden> bnc#457660
> user.a
>
- $ getfattr -h -P -R -m '.' -e hex 1/2 | grep -v selinux |
./sort-getfattr-output
+ $ getfattr -h -P -R -m '.' -e hex 1/2 | grep -v selinux |
sort-getfattr-output
> # file: 1/2
> user.9
> user.a
@@ -314,7 +314,7 @@ Test for proper recursion of directory structures with -L
-P -R
$ setfattr -n "user.a" 1/link
$ setfattr -n "user.a" 1/sub/sub-file
$ setfattr -n "user.a" 1/sub
- $ getfattr -P -R 1 | ./sort-getfattr-output
+ $ getfattr -P -R 1 | sort-getfattr-output
> # file: 1
> user.a
>
@@ -334,7 +334,7 @@ Test for proper recursion of directory structures with -L
-P -R
> user.a
>
- $ getfattr -R -P 1/sub | ./sort-getfattr-output
+ $ getfattr -R -P 1/sub | sort-getfattr-output
> # file: 1/sub
> user.a
>
@@ -345,7 +345,7 @@ Test for proper recursion of directory structures with -L
-P -R
> user.a
>
- $ getfattr -L -R 1 | ./sort-getfattr-output
+ $ getfattr -L -R 1 | sort-getfattr-output
> # file: 1
> user.a
>
@@ -368,7 +368,7 @@ Test for proper recursion of directory structures with -L
-P -R
> user.a
>
- $ getfattr -R 1/sub/link | ./sort-getfattr-output
+ $ getfattr -R 1/sub/link | sort-getfattr-output
> # file: 1/sub/link
> user.a
>
@@ -376,7 +376,7 @@ Test for proper recursion of directory structures with -L
-P -R
> user.a
>
- $ getfattr -L -R 1/sub/link | ./sort-getfattr-output
+ $ getfattr -L -R 1/sub/link | sort-getfattr-output
> # file: 1/sub/link
> user.a
>
diff --git a/test/root/getfattr.test b/test/root/getfattr.test
index 0c5d5dc..d06d966 100644
--- a/test/root/getfattr.test
+++ b/test/root/getfattr.test
@@ -25,7 +25,7 @@ With -h, we do not dereference symlinks:
>
Do the same for symlinks we find in a directory hierarchy:
- $ getfattr -m- -Rd . | ../sort-getfattr-output
+ $ getfattr -m- -Rd . | sort-getfattr-output
> # file: f
> user.test="test"
>
@@ -33,7 +33,7 @@ Do the same for symlinks we find in a directory hierarchy:
> user.test="test"
>
- $ getfattr -m- -Rhd . | ../sort-getfattr-output
+ $ getfattr -m- -Rhd . | sort-getfattr-output
> # file: f
> user.test="test"
>
@@ -43,7 +43,7 @@ Do the same for symlinks we find in a directory hierarchy:
Make sure we follow symlinks on the command line only when we should:
$ ln -s . here
- $ getfattr -m- -Rd here | ../sort-getfattr-output
+ $ getfattr -m- -Rd here | sort-getfattr-output
> # file: here/f
> user.test="test"
>
@@ -53,7 +53,7 @@ Make sure we follow symlinks on the command line only when we
should:
$ getfattr -m- -Rhd here
- $ getfattr -m- -RLhd here | ../sort-getfattr-output
+ $ getfattr -m- -RLhd here | sort-getfattr-output
> # file: here/f
> user.test="test"
>
@@ -66,7 +66,7 @@ Make sure we follow symlinks on the command line only when we
should:
Make sure we recurse into sub-directories:
$ mkdir sub
$ mv f l sub
- $ getfattr -m- -Rd . | ../sort-getfattr-output
+ $ getfattr -m- -Rd . | sort-getfattr-output
> # file: sub/f
> user.test="test"
>
@@ -74,7 +74,7 @@ Make sure we recurse into sub-directories:
> user.test="test"
>
- $ getfattr -m- -Rhd . | ../sort-getfattr-output
+ $ getfattr -m- -Rhd . | sort-getfattr-output
> # file: sub/f
> user.test="test"
>
@@ -87,7 +87,7 @@ Make sure we follow symlinks to directories only when we
should:
$ ln -s ../sub sub2/to-sub
$ getfattr -m- -Rhd sub2
- $ getfattr -m- -RLhd sub2 | ../sort-getfattr-output
+ $ getfattr -m- -RLhd sub2 | sort-getfattr-output
> # file: sub2/to-sub/f
> user.test="test"
>
@@ -99,7 +99,7 @@ Make sure we follow symlinks to directories only when we
should:
Symlink loop detection:
$ ln -s .. sub/up
- $ getfattr -m- -RLhd . | ../sort-getfattr-output
+ $ getfattr -m- -RLhd . | sort-getfattr-output
> # file: sub/f
> user.test="test"
>
diff --git a/test/run b/test/run
index cf15252..562d2c4 100755
--- a/test/run
+++ b/test/run
@@ -51,7 +51,10 @@
#
use strict;
+use Cwd qw(abs_path);
use FileHandle;
+use File::Basename qw(basename dirname);
+use File::Path qw(rmtree);
use Getopt::Std;
use POSIX qw(isatty setuid getcwd);
use vars qw($opt_l $opt_v);
@@ -67,9 +70,25 @@ if (isatty(fileno(STDOUT))) {
$FAILED = "\033[31m\033[1m" . $FAILED . "\033[m";
}
+# Add the current dir to PATH so we can find sort-getfattr-output and such.
+$ENV{"PATH"} = abs_path(dirname($0)) . ":$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($>);
$ENV{"TGROUP"} = getgrgid($));
+open(TEST_FILE, $ARGV[0]);
+
+# Create a tempdir to run in for parallel test execution.
+my $tmpdir = $ARGV[0] . ".dir";
+rmtree($tmpdir);
+if (!mkdir($tmpdir)) {
+ $tmpdir = getcwd() . "/" . basename($ARGV[0]) . ".dir";
+ rmtree($tmpdir);
+ mkdir($tmpdir) or die "could not create $tmpdir";
+}
+chdir($tmpdir) or die "could not enter $tmpdir";
+
sub exec_test($$);
sub process_test($$$$);
@@ -80,7 +99,7 @@ my $lineno;
my $width = ($ENV{COLUMNS} || 80) >> 1;
for (;;) {
- my $line = <>; $lineno++;
+ my $line = <TEST_FILE>; $lineno++;
if (defined $line) {
# Substitute %VAR and %{VAR} with environment variables.
$line =~ s[%(\w+)][$ENV{$1}]eg;
@@ -120,6 +139,11 @@ if (isatty(fileno(STDOUT))) {
}
}
print $status, "\n";
+
+# Now clean up the testdir.
+chdir("..");
+rmtree($tmpdir);
+
exit $failed ? 1 : 0;
--
1.8.4.3
- [Acl-devel] [PATCH attr 0/5] modernize the build system, Mike Frysinger, 2014/01/08
- [Acl-devel] [PATCH attr 3/5] test: make running parallel/out-of-tree safe,
Mike Frysinger <=
- [Acl-devel] [PATCH attr 2/5] move gettext logic into misc.h, Mike Frysinger, 2014/01/08
- [Acl-devel] [PATCH attr 1/5] punt debian/rpm packaging logic, Mike Frysinger, 2014/01/08
- [Acl-devel] [PATCH attr 5/5] po: regenerate files after move, Mike Frysinger, 2014/01/08
- [Acl-devel] [PATCH attr 4/5] modernize build system, Mike Frysinger, 2014/01/08
- Re: [Acl-devel] [PATCH attr 0/5] modernize the build system, Wolfram Sang, 2014/01/08
- Re: [Acl-devel] [PATCH attr 0/5] modernize the build system, Andreas Grünbacher, 2014/01/09