SHA256
1
0
forked from pool/attr
OBS User unknown 2009-02-19 16:40:06 +00:00 committed by Git OBS Bridge
parent 18db48f664
commit e8d9fe69a1
5 changed files with 171 additions and 133 deletions

View File

@ -1,18 +1,18 @@
Subject: [PATCH] attr: add make test target and use make to run tests Subject: [PATCH] attr: add make tests target and use make to run tests
The tests are difficult to run. So, this patch adds a Make target that 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. sets up the path and runs *.test files in the test/ directory.
ext specific tests can be ran from the test directory by running ext specific tests can be ran from the test directory by running
`make ext` `make ext-tests`
Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Brandon Philips <bphilips@suse.de>
--- ---
Makefile | 6 +++++- Makefile | 4 ++++
test/Makefile | 22 +++++++++++++--------- test/Makefile | 22 ++++++++++++++++++----
test/README | 4 ++++ test/README | 4 ++++
3 files changed, 22 insertions(+), 10 deletions(-) 3 files changed, 26 insertions(+), 4 deletions(-)
Index: attr-2.4.43/test/README Index: attr-2.4.43/test/README
=================================================================== ===================================================================
@ -30,54 +30,46 @@ Index: attr-2.4.43/test/Makefile
=================================================================== ===================================================================
--- attr-2.4.43.orig/test/Makefile --- attr-2.4.43.orig/test/Makefile
+++ attr-2.4.43/test/Makefile +++ attr-2.4.43/test/Makefile
@@ -1,16 +1,20 @@ @@ -5,12 +5,26 @@
# TOPDIR = ..
-# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved. include $(TOPDIR)/include/builddefs
+# Copyright (c) 2008 Novell, Inc.
#
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
+TEST = $(wildcard *.test) +TEST = $(wildcard *.test)
+EXT = $(wildcard ext/*.test) +EXT = $(wildcard ext/*.test)
+
-# ensure we pick these up in the source tarball # ensure we pick these up in the source tarball
-LSRCFILES = attr.test run README -LSRCFILES = attr.test run README
+PATH := $(abspath ../getfattr/):$(abspath ../setfattr):$(abspath ../chattr):$(PATH) +LSRCFILES = $(TEST) $(EXT) run README
-default: -default:
+all: $(TEST) +default install install-dev install-lib:
+ext: $(EXT)
-include $(BUILDRULES) include $(BUILDRULES)
+$(TEST):
+ @echo "*** $@ ***"; perl run $@
-install: -install:
-install-dev install-lib: -install-dev install-lib:
+PATH := $(abspath ../getfattr/):$(abspath ../setfattr):$(abspath ../chattr):$(PATH)
+
+tests: $(TEST)
+ext-tests: $(EXT)
+
+$(TEST):
+ @echo "*** $@ ***"; perl run $@
+
+$(EXT): +$(EXT):
+ @echo "EXT specific tests"; @echo "*** $@ ***"; perl run $@ + @echo "EXT specific tests"; @echo "*** $@ ***"; perl run $@
+ +
+.PHONY: $(TEST) $(EXT) default +.PHONY: $(TEST) $(EXT)
+.NOTPARALLEL: +.NOTPARALLEL:
Index: attr-2.4.43/Makefile Index: attr-2.4.43/Makefile
=================================================================== ===================================================================
--- attr-2.4.43.orig/Makefile --- attr-2.4.43.orig/Makefile
+++ attr-2.4.43/Makefile +++ attr-2.4.43/Makefile
@@ -17,7 +17,7 @@ LDIRT = config.log .dep config.status co
Logs/* built .census install.* install-dev.* install-lib.* *.gz
SUBDIRS = include libmisc libattr attr getfattr setfattr \
- examples test m4 man doc po debian build
+ examples m4 man doc po debian build
default: $(CONFIGURE)
ifeq ($(HAVE_BUILDDEFS), no)
@@ -62,3 +62,7 @@ install-dev install-lib: default @@ -62,3 +62,7 @@ install-dev install-lib: default
realclean distclean: clean realclean distclean: clean
rm -f $(LDIRT) $(CONFIGURE) rm -f $(LDIRT) $(CONFIGURE)
rm -rf autom4te.cache Logs rm -rf autom4te.cache Logs
+ +
+.PHONY: test +.PHONY: tests
+test: default +tests: default
+ $(MAKE) -C test/ + $(MAKE) -C test/ tests

View File

@ -55,10 +55,10 @@ Signed-off-by: Brandon Philips <bphilips@suse.de>
libmisc/walk_tree.c | 9 ++++++++- libmisc/walk_tree.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-) 1 file changed, 8 insertions(+), 1 deletion(-)
Index: acl-2.2.47/libmisc/walk_tree.c Index: attr-2.4.43/libmisc/walk_tree.c
=================================================================== ===================================================================
--- acl-2.2.47.orig/libmisc/walk_tree.c --- attr-2.4.43.orig/libmisc/walk_tree.c
+++ acl-2.2.47/libmisc/walk_tree.c +++ attr-2.4.43/libmisc/walk_tree.c
@@ -93,8 +93,15 @@ static int walk_tree_rec(const char *pat @@ -93,8 +93,15 @@ static int walk_tree_rec(const char *pat
have_dir_stat = 1; have_dir_stat = 1;
} }

View File

@ -14,14 +14,64 @@ expression.
Signed-off-by: Brandon Philips <bphilips@suse.de> Signed-off-by: Brandon Philips <bphilips@suse.de>
--- ---
test/run | 99 ++++++++++++++++++++++++++++++++------------------------------- test/run | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
1 file changed, 51 insertions(+), 48 deletions(-) 1 file changed, 72 insertions(+), 18 deletions(-)
Index: acl-2.2.47/test/run Index: attr-2.4.43/test/run
=================================================================== ===================================================================
--- acl-2.2.47.orig/test/run --- attr-2.4.43.orig/test/run
+++ acl-2.2.47/test/run +++ attr-2.4.43/test/run
@@ -25,26 +25,69 @@ if (isatty(fileno(STDOUT))) { @@ -1,5 +1,32 @@
#!/usr/bin/perl -w -U
+# Copyright (c) 2007, 2008 Andreas Gruenbacher.
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions, and the following disclaimer,
+# without modification, immediately at the beginning of the file.
+# 2. The name of the author may not be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# Alternatively, this software may be distributed under the terms of the
+# GNU Public License ("GPL").
+#
+# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
+# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
+# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+# SUCH DAMAGE.
+
#
# Possible improvements:
#
@@ -12,12 +39,13 @@
use strict;
use FileHandle;
use Getopt::Std;
-use POSIX qw(isatty setuid);
-use vars qw($opt_v);
+use POSIX qw(isatty setuid getcwd);
+use vars qw($opt_l $opt_v);
no warnings qw(taint);
-getopts('v');
+$opt_l = ~0; # a really huge number
+getopts('l:v');
my ($OK, $FAILED) = ("ok", "failed");
if (isatty(fileno(STDOUT))) {
@@ -25,18 +53,24 @@ if (isatty(fileno(STDOUT))) {
$FAILED = "\033[31m\033[1m" . $FAILED . "\033[m"; $FAILED = "\033[31m\033[1m" . $FAILED . "\033[m";
} }
@ -29,121 +79,110 @@ Index: acl-2.2.47/test/run
+$ENV{"TGROUP"} = getgrgid($)); +$ENV{"TGROUP"} = getgrgid($));
+ +
sub exec_test($$); sub exec_test($$);
+sub process_test($$$$);
-my ($prog, $in, $out) = ([], [], []); my ($prog, $in, $out) = ([], [], []);
+my ($prog, $in, $out, $outmatch) = ([], [], [], []); -my $line_number = 0;
my $line_number = 0; -my $prog_line;
my $prog_line; +my $prog_line = 0;
my ($tests, $failed) = (0,0); my ($tests, $failed) = (0,0);
+my $lineno;
+my $width = ($ENV{COLUMNS} || 80) >> 1;
+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 (;;) { for (;;) {
my $line = <>; $line_number++; - my $line = <>; $line_number++;
+ my $line = <>; $lineno++;
if (defined $line) { if (defined $line) {
# Substitute %VAR and %{VAR} with environment variables. # Substitute %VAR and %{VAR} with environment variables.
- $line =~ s[%(?:(\w+)|\{(\w+)\})][$ENV{"$1$2"}]eg; - $line =~ s[%(?:(\w+)|\{(\w+)\})][$ENV{"$1$2"}]eg;
+ $line =~ s[%\{(\w+)\}][$ENV{"$1"}]eg; + $line =~ s[%(\w+)][$ENV{$1}]eg;
+ $line =~ s[%(\w+)][$ENV{"$1"}]eg; + $line =~ s[%{(\w+)}][$ENV{$1}]eg;
} }
if (defined $line) { if (defined $line) {
if ($line =~ s/^\s*< ?//) { if ($line =~ s/^\s*< ?//) {
push @$in, $line; @@ -45,14 +79,14 @@ for (;;) {
- } 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; push @$out, $line;
} else { } else {
- process_test($prog, $prog_line, $in, $out); process_test($prog, $prog_line, $in, $out);
+ process_test($prog, $prog_line, $in, $out, $outmatch); + last if $prog_line >= $opt_l;
$prog = []; $prog = [];
$prog_line = 0; $prog_line = 0;
@@ -55,9 +98,10 @@ for (;;) { }
$prog_line = $line_number; if ($line =~ s/^\s*\$ ?//) {
- $line =~ s/\s+#.*//; # remove comments here...
$prog = [ map { s/\\(.)/$1/g; $_ } split /(?<!\\)\s+/, $line ];
- $prog_line = $line_number;
+ $prog_line = $lineno;
$in = []; $in = [];
$out = []; $out = [];
+ $outmatch = [];
} }
} else { @@ -84,27 +118,37 @@ sub process_test($$$$) {
- process_test($prog, $prog_line, $in, $out); print "[$prog_line] \$ ", join(' ',
+ process_test($prog, $prog_line, $in, $out, $outmatch); map { s/\s/\\$&/g; $_ } @$p), " -- ";
last; my $result = exec_test($prog, $in);
}
}
@@ -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 $good = 1;
- my $nmax = (@$out > @$result) ? @$out : @$result; + my @good = ();
- for (my $n=0; $n < $nmax; $n++) { my $nmax = (@$out > @$result) ? @$out : @$result;
for (my $n=0; $n < $nmax; $n++) {
- if (!defined($out->[$n]) || !defined($result->[$n]) || - if (!defined($out->[$n]) || !defined($result->[$n]) ||
- $out->[$n] ne $result->[$n]) { - $out->[$n] ne $result->[$n]) {
- $good = 0; - $good = 0;
- } - }
- } + my $use_re;
- $tests++; + if (defined $out->[$n] && $out->[$n] =~ /^~ /) {
- $failed++ unless $good; + $use_re = 1;
- print $good ? $OK : $FAILED, "\n"; + $out->[$n] =~ s/^~ //g;
+ }
+
+ if (!defined($out->[$n]) || !defined($result->[$n]) ||
+ (!$use_re && $result->[$n] ne $out->[$n]) ||
+ ( $use_re && $result->[$n] !~ /^$out->[$n]/)) {
+ push @good, ($use_re ? '!~' : '!=');
+ }
+ else {
+ push @good, ($use_re ? '=~' : '==');
+ }
}
+ my $good = !(grep /!/, @good);
$tests++;
$failed++ unless $good;
print $good ? $OK : $FAILED, "\n";
- if (!$good) { - if (!$good) {
- for (my $n=0; $n < $nmax; $n++) { + if (!$good || $opt_v) {
- my $l = defined($out->[$n]) ? $out->[$n] : "~"; for (my $n=0; $n < $nmax; $n++) {
- chomp $l; my $l = defined($out->[$n]) ? $out->[$n] : "~";
- my $r = defined($result->[$n]) ? $result->[$n] : "~"; chomp $l;
- chomp $r; my $r = defined($result->[$n]) ? $result->[$n] : "~";
chomp $r;
- print sprintf("%-37s %s %-39s\n", $l, $l eq $r ? "|" : "?", $r); - print sprintf("%-37s %s %-39s\n", $l, $l eq $r ? "|" : "?", $r);
- } + print sprintf("%-" . ($width-3) . "s %s %s\n",
+ $r, $good[$n], $l);
}
- } elsif ($opt_v) { - } elsif ($opt_v) {
- print join('', @$result); - print join('', @$result);
- } }
-} }
-
sub su($) { @@ -191,11 +235,21 @@ sub exec_test($$) {
my ($user) = @_; if (!chdir $prog->[1]) {
return [ "chdir: $prog->[1]: $!\n" ];
}
+ $ENV{PWD} = getcwd;
return [];
} elsif ($prog->[0] eq "su") {
return su($prog->[1]);
} elsif ($prog->[0] eq "sg") {
return sg($prog->[1]);
+ } elsif ($prog->[0] eq "export") {
+ my ($name, $value) = split /=/, $prog->[1];
+ # FIXME: need to evaluate $value, so that things like this will work:
+ # export dir=$PWD/dir
+ $ENV{$name} = $value;
+ return [];
+ } elsif ($prog->[0] eq "unset") {
+ delete $ENV{$prog->[1]};
+ return [];
}
pipe *IN2, *OUT

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Feb 12 23:25:28 PST 2009 - bphilips@suse.de
- Improve unit test harness
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Jan 6 14:09:13 PST 2009 - bphilips@suse.de Tue Jan 6 14:09:13 PST 2009 - bphilips@suse.de

View File

@ -23,7 +23,7 @@ Group: System/Filesystems
AutoReqProv: on AutoReqProv: on
Summary: Commands for Manipulating Extended Attributes Summary: Commands for Manipulating Extended Attributes
Version: 2.4.43 Version: 2.4.43
Release: 1 Release: 3
Source: %{name}_%{version}-1.tar.gz Source: %{name}_%{version}-1.tar.gz
Source1: xattr.conf Source1: xattr.conf
Patch0: builddefs.in.diff Patch0: builddefs.in.diff
@ -190,6 +190,8 @@ rm -rf $RPM_BUILD_ROOT
%config %{_sysconfdir}/xattr.conf %config %{_sysconfdir}/xattr.conf
%changelog %changelog
* Thu Feb 12 2009 bphilips@suse.de
- Improve unit test harness
* Tue Jan 06 2009 bphilips@suse.de * Tue Jan 06 2009 bphilips@suse.de
- Fix tests and add make target - Fix tests and add make target
- Version bump to get fix for getfattr -P bnc#457660 - Version bump to get fix for getfattr -P bnc#457660