public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: brandon@ifup.org
To: xfs@oss.sgi.com
Cc: Brandon Philips <bphilips@suse.de>
Subject: [patch 2/4] [PATCH] attr: various improvements for test/run
Date: Wed, 07 Jan 2009 18:19:49 -0800	[thread overview]
Message-ID: <20090108022108.928859181@ifup.org> (raw)
In-Reply-To: 20090108021947.404730068@ifup.org

[-- Attachment #1: attr-various-improvements-for-test-run.patch --]
[-- Type: text/plain, Size: 4328 bytes --]

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.

Signed-off-by: Brandon Philips <bphilips@suse.de>

---
 test/run |   99 ++++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 51 insertions(+), 48 deletions(-)

Index: acl-2.2.47/test/run
===================================================================
--- acl-2.2.47.orig/test/run
+++ 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
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2009-01-08  2:21 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-08  2:19 [patch 0/4] attr: test/ improvements and integrate with make brandon
2009-01-08  2:19 ` [patch 1/4] [PATCH] attr: move ext2/3 tests into seperate test file brandon
2009-01-08  2:19 ` brandon [this message]
2009-01-08  2:19 ` [patch 3/4] [PATCH] attr: add make test target and use make to run tests brandon
2009-01-08  2:19 ` [patch 4/4] [PATCH] attr: Tests for path recursion with -L -P -R brandon
2009-01-08 15:44 ` [patch 0/4] attr: test/ improvements and integrate with make Christoph Hellwig
2009-01-08 16:58   ` Brandon Philips
2009-02-07  9:10     ` Brandon Philips
2009-02-08 22:59       ` Andreas Gruenbacher
2009-02-08 23:38         ` Brandon Philips
2009-02-09  0:31           ` Andreas Gruenbacher
2009-02-09 18:12         ` Christoph Hellwig
2009-02-09 19:06           ` Andreas Gruenbacher
2009-02-09 19:09           ` merging acl-dev and attr-dev [was: Re: [patch 0/4] attr: test/ improvements and integrate with make] Brandon Philips
2009-02-10  7:57             ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090108022108.928859181@ifup.org \
    --to=brandon@ifup.org \
    --cc=bphilips@suse.de \
    --cc=xfs@oss.sgi.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox