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
sets up the path and runs *.test files in the test/ directory.
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>
---
Makefile | 6 +++++-
test/Makefile | 22 +++++++++++++---------
Makefile | 4 ++++
test/Makefile | 22 ++++++++++++++++++----
test/README | 4 ++++
3 files changed, 22 insertions(+), 10 deletions(-)
3 files changed, 26 insertions(+), 4 deletions(-)
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/test/Makefile
@@ -1,16 +1,20 @@
#
-# Copyright (c) 2001-2002 Silicon Graphics, Inc. All Rights Reserved.
+# Copyright (c) 2008 Novell, Inc.
#
@@ -5,12 +5,26 @@
TOPDIR = ..
include $(TOPDIR)/include/builddefs
-TOPDIR = ..
-include $(TOPDIR)/include/builddefs
+TEST = $(wildcard *.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
+PATH := $(abspath ../getfattr/):$(abspath ../setfattr):$(abspath ../chattr):$(PATH)
+LSRCFILES = $(TEST) $(EXT) run README
-default:
+all: $(TEST)
+ext: $(EXT)
+default install install-dev install-lib:
-include $(BUILDRULES)
+$(TEST):
+ @echo "*** $@ ***"; perl run $@
include $(BUILDRULES)
-install:
-install-dev install-lib:
+PATH := $(abspath ../getfattr/):$(abspath ../setfattr):$(abspath ../chattr):$(PATH)
+
+tests: $(TEST)
+ext-tests: $(EXT)
+
+$(TEST):
+ @echo "*** $@ ***"; perl run $@
+
+$(EXT):
+ @echo "EXT specific tests"; @echo "*** $@ ***"; perl run $@
+
+.PHONY: $(TEST) $(EXT) default
+.PHONY: $(TEST) $(EXT)
+.NOTPARALLEL:
Index: attr-2.4.43/Makefile
===================================================================
--- attr-2.4.43.orig/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
realclean distclean: clean
rm -f $(LDIRT) $(CONFIGURE)
rm -rf autom4te.cache Logs
+
+.PHONY: test
+test: default
+ $(MAKE) -C test/
+.PHONY: tests
+tests: default
+ $(MAKE) -C test/ tests

View File

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

View File

@ -14,14 +14,64 @@ expression.
Signed-off-by: Brandon Philips <bphilips@suse.de>
---
test/run | 99 ++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 51 insertions(+), 48 deletions(-)
test/run | 90 ++++++++++++++++++++++++++++++++++++++++++++++++++-------------
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
+++ acl-2.2.47/test/run
@@ -25,26 +25,69 @@ if (isatty(fileno(STDOUT))) {
--- attr-2.4.43.orig/test/run
+++ attr-2.4.43/test/run
@@ -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";
}
@ -29,121 +79,110 @@ Index: acl-2.2.47/test/run
+$ENV{"TGROUP"} = getgrgid($));
+
sub exec_test($$);
+sub process_test($$$$);
-my ($prog, $in, $out) = ([], [], []);
+my ($prog, $in, $out, $outmatch) = ([], [], [], []);
my $line_number = 0;
my $prog_line;
my ($prog, $in, $out) = ([], [], []);
-my $line_number = 0;
-my $prog_line;
+my $prog_line = 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 (;;) {
my $line = <>; $line_number++;
- my $line = <>; $line_number++;
+ my $line = <>; $lineno++;
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;
+ $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;
@@ -45,14 +79,14 @@ for (;;) {
push @$out, $line;
} else {
- process_test($prog, $prog_line, $in, $out);
+ process_test($prog, $prog_line, $in, $out, $outmatch);
process_test($prog, $prog_line, $in, $out);
+ last if $prog_line >= $opt_l;
$prog = [];
$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 = [];
$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);
@@ -84,27 +118,37 @@ sub process_test($$$$) {
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++) {
+ my @good = ();
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";
+ my $use_re;
+ if (defined $out->[$n] && $out->[$n] =~ /^~ /) {
+ $use_re = 1;
+ $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) {
- 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;
+ if (!$good || $opt_v) {
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);
- }
+ print sprintf("%-" . ($width-3) . "s %s %s\n",
+ $r, $good[$n], $l);
}
- } elsif ($opt_v) {
- print join('', @$result);
- }
-}
-
}
}
sub su($) {
my ($user) = @_;
@@ -191,11 +235,21 @@ sub exec_test($$) {
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

View File

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