Skip to contentSkip to conversation

acl: test/ improvements and integrate with make

PATCH In review [email protected] 3 participants 12 messages Jan 8, 2009 – Feb 9, 2009 Kbuild

lore
Share & tools
lore
#0 lore raw

cover acl: test/ improvements and integrate with make

Hello-

This series makes some improvements to the acl tests to integrate them into make and add a few testing features to the harness.

The most useful feature is being able to run make test from the root of the source tree to build the tree to run a generic set of tests.

Cheers,

Brandon

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#1 lore raw

PATCH 1/5 acl: add make test target and use make to run tests

The tests are difficult to run. So, this patch adds a Make target that sets up the path and runs *.test files in the test/ directory.

nfs specific tests can be ran from the test directory by running make nfs

tests requiring root can be ran from the test directory by running make nfs

---
 Makefile      |    6 +++++-
 test/Makefile |   26 +++++++++++++++++++-------
 2 files changed, 24 insertions(+), 8 deletions(-)
test/Makefile +19 -7
Index: acl-2.2.47/test/Makefile
===================================================================
@@ -2,13 +2,25 @@
 # Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
 #
 
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
+TEST = $(wildcard *.test)
+ROOT = $(wildcard root/*.test)
+NFS = $(wildcard nfs/*.test)
 
-LSRCFILES = run make-tree \
-	    cp.test getfacl-noacl.test misc.test nfs-dir.test \
-	    nfsacl.test permissions.test setfacl.test
+PATH := $(abspath ../getfacl/):$(abspath ../setfacl/):$(abspath ../chacl/):$(PATH)
 
-include $(BUILDRULES)
+all: $(TEST)
+root: $(ROOT)
+nfs: $(NFS)
 
-default install install-dev install-lib:
+
+$(TEST):
+	@echo "*** $@ ***"; perl run $@
+
+$(NFS):
+	@echo "NFS specific tests"; @echo "*** $@ ***"; perl run $@
+
+$(ROOT):
+	@echo "Note: Tests must run as root"; @echo "*** $@ ***"; perl run $@
+
+.PHONY: $(TEST) $(ROOT) $(NFS) default
+.NOTPARALLEL:
Makefile +5 -1
Index: acl-2.2.47/Makefile
===================================================================
@@ -17,7 +17,7 @@ LDIRT = config.log .dep config.status co
 	Logs/* built .census install.* install-dev.* install-lib.* *.gz
 
 SUBDIRS = include libmisc libacl getfacl setfacl chacl m4 man doc po \
-	  test examples build debian
+	  examples build debian
 
 default: $(CONFIGURE)
 ifeq ($(HAVE_BUILDDEFS), no)
@@ -65,3 +65,7 @@ install-lib: default
 realclean distclean: clean
 	rm -f $(LDIRT) $(CONFIGURE)
 	rm -rf autom4te.cache Logs
+
+.PHONY: test
+test: default
+	$(MAKE) -C test/

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#2 lore raw

Re: [patch 1/5] [PATCH] acl: add make test target and use make to run tests

Quoted 2 lines · On Thursday, 8 January 2009 2:53:56 [email protected] wrote:

The tests are difficult to run. So, this patch adds a Make target that sets up the path and runs *.test files in the test/ directory.

Makes sense in principle, except that the patch removes the makefile rules that cause the tests to get added to the tarball :-(

Would you mind to fix that?

Thanks,
Andreas

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#3 lore raw

PATCH 2/5 acl: various improvements for test/run

In reply to [email protected]

First move process_test to avoid a warning:

main::process_test() called too early to check prototype at ./run line 47. main::process_test() called too early to check prototype at ./run line 60.

Create two ENV variables TUSER and TGROUP to get the user/group running the test.

Add a | test line that is similar to > but is interpreted as a regular expression.

---
 test/run |   99 ++++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 51 insertions(+), 48 deletions(-)
test/run +49 -38
Index: acl-2.2.47/test/run
===================================================================
@@ -25,26 +25,69 @@ if (isatty(fileno(STDOUT))) {
 	$FAILED = "\033[31m\033[1m" . $FAILED . "\033[m";
 }
 
+$ENV{"TUSER"} = getpwuid($>);
+$ENV{"TGROUP"} = getgrgid($));
+
 sub exec_test($$);
 
-my ($prog, $in, $out) = ([], [], []);
+my ($prog, $in, $out, $outmatch) = ([], [], [], []);
 my $line_number = 0;
 my $prog_line;
 my ($tests, $failed) = (0,0);
 
+sub process_test($$$$$) {
+  my ($prog, $prog_line, $in, $out, $outmatch) = @_;
+
+  return unless @$prog;
+
+       my $p = [ @$prog ];
+       print "[$prog_line] \$ ", join(' ',
+             map { s/\s/\\$&/g; $_ } @$p), " -- ";
+       my $result = exec_test($prog, $in);
+       my $good = 1;
+       my $nmax = (@$outmatch > @$result) ? @$outmatch : @$result;
+       for (my $n=0; $n < $nmax; $n++) {
+	 if (!defined($outmatch->[$n]) || !defined($result->[$n]) ||
+	      $result->[$n] !~ /($outmatch->[$n])/) {
+		 $good = 0;
+	 }
+       }
+       $tests++;
+       $failed++ unless $good;
+       print $good ? $OK : $FAILED, "\n";
+       if (!$good) {
+         for (my $n=0; $n < $nmax; $n++) {
+	   my $l = defined($out->[$n]) ? $out->[$n] : "~";
+	   chomp $l;
+	   my $r = defined($result->[$n]) ? $result->[$n] : "~";
+	   chomp $r;
+	   print sprintf("%-37s %s %-39s\n", $l, $l eq $r ? "|" : "?", $r);
+         }
+       } elsif ($opt_v) {
+	 print join('', @$result);
+       }
+}
+
+
+
 for (;;) {
   my $line = <>; $line_number++;
   if (defined $line) {
     # Substitute %VAR and %{VAR} with environment variables.
-    $line =~ s[%(?:(\w+)|\{(\w+)\})][$ENV{"$1$2"}]eg;
+    $line =~ s[%\{(\w+)\}][$ENV{"$1"}]eg;
+    $line =~ s[%(\w+)][$ENV{"$1"}]eg;
   }
   if (defined $line) {
     if ($line =~ s/^\s*< ?//) {
       push @$in, $line;
-    } elsif ($line =~ s/^\s*> ?//) {
+    } elsif ($line =~ s/^\s*> ?//) { # explicit matching
+      push @$outmatch, "^(\Q$line\E)\$";
+      push @$out, $line;
+    } elsif ($line =~ s/^\s*\| ?//) { # regex case
+      push @$outmatch, $line;
       push @$out, $line;
     } else {
-      process_test($prog, $prog_line, $in, $out);
+      process_test($prog, $prog_line, $in, $out, $outmatch);
 
       $prog = [];
       $prog_line = 0;
@@ -55,9 +98,10 @@ for (;;) {
       $prog_line = $line_number;
       $in = [];
       $out = [];
+      $outmatch = [];
     }
   } else {
-    process_test($prog, $prog_line, $in, $out);
+    process_test($prog, $prog_line, $in, $out, $outmatch);
     last;
   }
 }
@@ -75,39 +119,6 @@ print $status, "\n";
 exit $failed ? 1 : 0;
 
 
-sub process_test($$$$) {
-  my ($prog, $prog_line, $in, $out) = @_;
-
-  return unless @$prog;
-
-       my $p = [ @$prog ];
-       print "[$prog_line] \$ ", join(' ',
-             map { s/\s/\\$&/g; $_ } @$p), " -- ";
-       my $result = exec_test($prog, $in);
-       my $good = 1;
-       my $nmax = (@$out > @$result) ? @$out : @$result;
-       for (my $n=0; $n < $nmax; $n++) {
-	 if (!defined($out->[$n]) || !defined($result->[$n]) ||
-	     $out->[$n] ne $result->[$n]) {
-		 $good = 0;
-	 }
-       }
-       $tests++;
-       $failed++ unless $good;
-       print $good ? $OK : $FAILED, "\n";
-       if (!$good) {
-         for (my $n=0; $n < $nmax; $n++) {
-	   my $l = defined($out->[$n]) ? $out->[$n] : "~";
-	   chomp $l;
-	   my $r = defined($result->[$n]) ? $result->[$n] : "~";
-	   chomp $r;
-	   print sprintf("%-37s %s %-39s\n", $l, $l eq $r ? "|" : "?", $r);
-         }
-       } elsif ($opt_v) {
-	 print join('', @$result);
-       }
-}
-
 
 sub su($) {
   my ($user) = @_;

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#4 lore raw

Re: [patch 2/5] [PATCH] acl: various improvements for test/run

Brandon,

the version of the run script in the attr and acl packages is somewhat dated; I have made a few improvements since. I'll move this out of {acl,attr}/test and put the latest version into the libmisc/ directory.

Note that I recently rewrote the run script from scratch. Unlike the old version, the new one runs the whole script inside the same shell. There are still a few problems to be solved; most importantly, user switching doesn't work, yet. Eventually I want to replace the old version, though.

http://savannah.nongnu.org/projects/shrun

Quoted 4 lines · On Thursday, 8 January 2009 2:53:57 [email protected] wrote:

First move process_test to avoid a warning:

main::process_test() called too early to check prototype at ./run line 47. main::process_test() called too early to check prototype at ./run line 60.

The new version had this fixed already.

Quoted 2 lines

Create two ENV variables TUSER and TGROUP to get the user/group running the test.

Good idea. Added.

(Stuff like this will be obsolete with shrun.)

Quoted 2 lines

Add a | test line that is similar to > but is interpreted as a regular expression.

I have been using ">~" instead of "|" for that. I'm still not sure that including regular expression matching was a good idea though, so shrun doesn't have any of that yet. We'll se how things develop.

Thanks,
Andreas

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#5 lore raw

Re: [patch 2/5] [PATCH] acl: various improvements for test/run

Quoted 10 lines · Andreas Gruenbacher

Brandon,

the version of the run script in the attr and acl packages is somewhat dated; I have made a few improvements since. I'll move this out of {acl,attr}/test and put the latest version into the libmisc/ directory.

Note that I recently rewrote the run script from scratch. Unlike the old version, the new one runs the whole script inside the same shell. There are still a few problems to be solved; most importantly, user switching doesn't work, yet.

I hope you get that feature done soon, and look forward to reviewing it. Let me just be Captain Obvious and say that user switching is a critical feature for code used to drive ACL tests ;-)

Quoted 7 lines

Eventually I want to replace the old version, though.

http://savannah.nongnu.org/projects/shrun

Quoted 10 lines
Quoted 3 lines

Add a | test line that is similar to > but is interpreted as a regular expression.

I have been using ">~" instead of "|" for that. I'm still not sure that including regular expression matching was a good idea though, so shrun doesn't have any of that yet. We'll se how things develop.

Regexp matching is the kind of thing that sounds like it could be quite useful, but it's a pain to implement. When I wrote a Python interpreter for the shrun language for use in Newpynfs, I didn't bother implementing the regexp feature.

Signature · 8 lines
Greg Banks, P.Engineer, SGI Australian Software Group.
the brightly coloured sporks of revolution.
I don't speak for SGI.

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#6 lore raw

PATCH 3/5 acl: move root tests to their own folder

In reply to [email protected]

Since these tests require root perms to run move them into a seperate folder so they don't run by default.

---
 test/permissions.test      |  279 ---------------------------------------------
 test/root/permissions.test |  279 +++++++++++++++++++++++++++++++++++++++++++++
 test/root/setfacl.test     |  144 +++++++++++++++++++++++
 test/setfacl.test          |  144 -----------------------
 4 files changed, 423 insertions(+), 423 deletions(-)
test/permissions.test deleted +0 -279
Index: acl-2.2.47/test/permissions.test
===================================================================
@@ -1,279 +0,0 @@
-This script tests if file permissions are properly checked with and
-without ACLs. The script must be run as root to allow switching users.
-The following users are required. They must be a member in the groups
-listed in parentheses.
-
-	bin (bin)
-	daemon (bin, daemon)
-
-
-Cry immediately if we are not running as root.
-
-	$ id -u
-	> 0
-
-
-First, set up a temporary directory and create a regular file with
-defined permissions.
-
-	$ mkdir d
-	$ cd d
-	$ umask 027
-	$ touch f
-	$ ls -l f | awk -- '{ print $1, $3, $4 }'
-	> -rw-r----- root root
-
-
-Make sure root has access to the file.  Verify that user daemon does not
-have access to the file owned by root.
-
-	$ echo root > f
-
-	$ su daemon
-	$ echo daemon >> f
-	> f: Permission denied
-
-	$ su
-
-
-Now, change the ownership of the file to bin:bin and verify that this
-gives user bin write access.
-
-	$ chown bin:bin f
-	$ ls -l f | awk -- '{ print $1, $3, $4 }'
-	> -rw-r----- bin bin
-	$ su bin
-	$ echo bin >> f
-
-
-User daemon is a member in the owning group, which has only read access.
-Verify this.
-
-	$ su daemon
-	$ cat f
-	> root
-	> bin
-
-	$ echo daemon >> f
-	> f: Permission denied
-
-
-Now, add an ACL entry for user daemon that grants him rw- access. File
-owners and users capable of CAP_FOWNER are allowed to change ACLs.
-
-	$ su bin
-	$ setfacl -m u:daemon:rw f
-	$ getfacl --omit-header f
-	> user::rw-
-	> user:daemon:rw-
-	> group::r--
-	> mask::rw-
-	> other::---
-	>
-
-
-Verify that the additional ACL entry grants user daemon write access.
-
-	$ su daemon
-	$ echo daemon >> f
-	$ cat f
-	> root
-	> bin
-	> daemon
-
-
-Remove write access from the group class permission bits, and
-verify that this masks daemon's write permission.
-
-	$ su bin
-	$ chmod g-w f
-	$ getfacl --omit-header f
-	> user::rw-
-	> user:daemon:rw-	#effective:r--
-	> group::r--
-	> mask::r--
-	> other::---
-	>
-
-	$ su daemon
-	$ echo daemon >> f
-	> f: Permission denied
-
-
-Add an entry for group daemon with rw- access, and change the
-permissions for user daemon to r--. Also change the others permissions t
-rw-. The user entry should take precedence, so daemon should be denied
-access.
-
-	$ su bin
-	$ setfacl -m u:daemon:r,g:daemon:rw-,o::rw- f
-
-	$ su daemon
-	$ echo daemon >> f
-	> f: Permission denied
-
-
-Remove the entry for user daemon. The group daemon permissions should
-now give user daemon rw- access.
-
-	$ su bin
-	$ setfacl -x u:daemon f
-
-	$ su daemon
-	$ echo daemon2 >> f
-	$ cat f
-	> root
-	> bin
-	> daemon
-	> daemon2
-
-
-Set the group daemon permissions to r-- and verify that after than, user
-daemon does not have write access anymore.
-
-	$ su bin
-	$ setfacl -m g:daemon:r f
-
-	$ su daemon
-	$ echo daemon3 >> f
-	> f: Permission denied
-
-
-Now, remove the group daemon entry. Because user daemon is a member in
-the owning group, he should still have no write access.
-
-	$ su bin
-	$ setfacl -x g:daemon f
-
-	$ su daemon
-	$ echo daemon4 >> f
-	> f: Permission denied
-
-
-Change the owning group. The other permissions should now grant user
-daemon write access.
-
-	$ su
-	$ chgrp root f
-
-	$ su daemon
-	$ echo daemon5 >> f
-	$ cat f
-	> root
-	> bin
-	> daemon
-	> daemon2
-	> daemon5
-
-
-Verify that permissions in separate matching ACL entries do not
-accumulate.
-
-	$ su
-	$ setfacl -m g:bin:r,g:daemon:w f
-
-	$ su daemon
-	$ : < f	 # open for reading
-	$ : > f  # open for writing
-	$ : <> f  # open for read-write
-	> f: Permission denied
-
-
-Test if directories can have ACLs.  We assume that only one access check
-algorithm is used for all file types the file system, so these tests
-only need to verify that ACL permissions make a difference.
-
-	$ su
-	$ mkdir -m 750 e
-	$ touch e/h
-
-	$ su bin
-	$ shopt -s nullglob ; echo e/*
-	>
-
-	$ echo i > e/i
-	> e/i: Permission denied
-
-	$ su
-	$ setfacl -m u:bin:rx e
-
-	$ su bin
-	$ echo e/*
-	> e/h
-	$ echo i > e/i
-	> e/i: Permission denied
-
-	$ su
-	$ setfacl -m u:bin:rwx e
-
-	$ su bin
-	$ echo i > e/i
-
-
-Test if symlinks are properly followed.
-
-	$ su
-	$ touch g
-	$ ln -s g l
-	$ setfacl -m u:bin:rw l
-	$ ls -l g | awk -- '{ print $1, $3, $4 }'
-	> -rw-rw----+ root root
-
-
-Test if ACLs are effective for block and character special files, fifos,
-sockets. This is done by creating special files locally. The devices do
-not need to exist: The access check is earlier in the code path than the
-test if the device exists.
-
-
-	$ mknod -m 0660 hdt b 91 64	# /dev/hdt
-	$ mknod -m 0660 null c 1 3	# /dev/null
-	$ mkfifo -m 0660 fifo
-
-	$ su bin
-	$ : < hdt
-	> hdt: Permission denied
-	$ : < null
-	> null: Permission denied
-	$ : < fifo
-	> fifo: Permission denied
-
-	$ su
-	$ setfacl -m u:bin:rw hdt null fifo
-
-	$ su bin
-	$ : < hdt
-	> hdt: No such device or address
-	$ : < null
-	$ ( echo blah > fifo & ) ; cat fifo
-	> blah
-
-
-Test if CAP_FOWNER is properly honored for directories. This addresses a
-specific bug in XFS 1.2, which does not grant root access to files in
-directories if the file has an ACL and only CAP_FOWNER would grant them.
-
-	$ su
-	$ mkdir -m 600 x
-	$ chown daemon:daemon x
-	$ echo j > x/j
-	$ ls -l x/j | awk -- '{ print $1, $3, $4 }'
-	> -rw-r----- root root
-
-	$ setfacl -m u:daemon:r x
-
-	$ ls -l x/j | awk -- '{ print $1, $3, $4 }'
-	> -rw-r----- root root
-	(With the bug this gives: `ls: x/j: Permission denied'.)
-
-	$ echo k > x/k
-	(With the bug this gives: `x/k: Permission denied'.)
-
-	$ chmod 750 x
-
-
-Clean up.
-
-	$ su
-	$ cd ..
-	$ rm -rf d
test/setfacl.test deleted +0 -144

144 lines not on this page · raw message

test/root/permissions.test new file +279 -0

279 lines not on this page · raw message

test/root/setfacl.test new file +144 -0

144 lines not on this page · raw message

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#8 lore raw

PATCH 4/5 acl: move nfs tests to their own folder

In reply to [email protected]

Since these tests require nfs mounts to run move them into a seperate folder so they don't run by default.

---
 test/nfs-dir.test     |   50 --------------------------------------------------
 test/nfs/nfs-dir.test |   50 ++++++++++++++++++++++++++++++++++++++++++++++++++
 test/nfs/nfsacl.test  |   42 ++++++++++++++++++++++++++++++++++++++++++
 test/nfsacl.test      |   42 ------------------------------------------
 4 files changed, 92 insertions(+), 92 deletions(-)
test/nfs-dir.test deleted +0 -50
Index: acl-2.2.47/test/nfs-dir.test
===================================================================
@@ -1,50 +0,0 @@
-This is a regression test for a bug in 2.4 kernels. The test must be run
-as root on a machine that has a loopback mounted NFS export. The mount
-must have root squashing enabled. The test must be run in the root of
-the nfs mount, and requires the following environment variable:
-
-EXPORT_PATH => the path that is mounted at the working directory.
-
-	Create a test directory and file.
-	
-	$ umask 022
-	$ mkdir %{EXPORT_PATH}/test
-	$ echo blah > %{EXPORT_PATH}/test/blah
-
-	Make sure the file can be accessed before.
-	
-	$ su bin
-	$ cat test/blah
-	> blah
-
-	Set up a situation that triggers the bug.
-
-	$ su
-	$ chmod go-rwx %{EXPORT_PATH}/test
-	$ setfacl -m u:bin:rx %{EXPORT_PATH}/test
-	$ ls -dl %{EXPORT_PATH}/test | awk '{print $1, $3, $4}'
-	> drwxr-x---+ root root
-	$ getfacl --omit-header %{EXPORT_PATH}/test 2> /dev/null
-	> user::rwx
-	> user:bin:r-x
-	> group::---
-	> mask::r-x
-	> other::---
-	>
-
-	This should also succeed. With the bug, reading the file would
-	fail with "Stale NFS file handle" or "Input/output error".
-
-	$ su bin
-	$ cat test/blah
-	> blah
-	$ sleep 3
-	$ cat test/blah
-	> blah
-	$ cat test/blah
-	> blah
-
-	Clean up.
-
-	$ su
-	$ rm -rf %{EXPORT_PATH}/test
test/nfs/nfs-dir.test new file +50 -0

50 lines not on this page · raw message

test/nfs/nfsacl.test new file +42 -0

42 lines not on this page · raw message

test/nfsacl.test deleted +0 -42

42 lines not on this page · raw message

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs

#10 lore raw

PATCH 5/5 acl: minor fix to cp.test

In reply to [email protected]

X -> x

---
 test/cp.test |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/cp.test +1 -1
Index: acl-2.2.47/test/cp.test
===================================================================
@@ -24,7 +24,7 @@ The cp utility should only copy ACLs if
 	> blubb
 
 	$ rm -r i
-	$ setfacl -R -m u:bin:rwX h
+	$ setfacl -R -m u:bin:rwx h
 	$ getfacl --omit-header h/x
 	> user::rw-
 	> user:bin:rwx

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs