Skip to contentSkip to conversation

xfstests: A few updates to non-test code

PATCH In review David Sterba 3 participants 12 messages Jan 16, 2014 – Jan 20, 2014 Kbuild

lore
Share & tools
lore
#0 lore raw

cover xfstests: A few updates to non-test code

Minor bugfixes or enhancements.

David Sterba (5):
xfstests: fix minor build warning
xfstests: use value of FSTYP if defined externally
xfstests: don't suggest to run full diff when DIFF_LENGTH is 0
xfstests: accept tests/ prefix for test name on commandline
xfstests: update lsqa.pl for new tests layout

 Makefile |  3 +--
 README   |  3 +++
 check    | 16 +++++++++-------
 lsqa.pl  | 32 ++++++++++++++++++++++++--------
 4 files changed, 37 insertions(+), 17 deletions(-)
Signature · 6 lines
1.8.5

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

PATCH 1/5 xfstests: fix minor build warning

Make in the toplevel directory tries to process the 'group' file that existed in the previous file layout

$ make
 sed: can't read group: No such file or directory
 sed: can't read group: No such file or directory
 ...
---
 Makefile | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
Makefile +1 -2
index a7f6f9d374ca..30d8747d1f79 100644
@@ -41,7 +41,6 @@ endif
 
 SRCTAR = $(PKG_NAME)-$(PKG_VERSION).tar.gz
 
-TESTS = $(shell sed -n -e '/^[0-9][0-9][0-9]*/s/ .*//p' group)
 CONFIGURE = configure include/builddefs include/config.h
 LSRCFILES = configure configure.ac aclocal.m4 README VERSION
 LDIRT = config.log .ltdep .dep config.status config.cache confdefs.h \
@@ -60,7 +59,7 @@ endif
 export TESTS_DIR = tests
 SUBDIRS = $(LIB_SUBDIRS) $(TOOL_SUBDIRS) $(TESTS_DIR)
 
-default: include/builddefs $(DMAPI_MAKEFILE) $(TESTS)
+default: include/builddefs $(DMAPI_MAKEFILE)
 ifeq ($(HAVE_BUILDDEFS), no)
 	$(Q)$(MAKE) $(MAKEOPTS) $@
 else
Signature · 6 lines
1.8.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
Reviewed-by on v1 1/5
#2 lore raw

Re: [PATCH 1/5] xfstests: fix minor build warning

Quoted 9 lines · David Sterba

Make in the toplevel directory tries to process the 'group' file that existed in the previous file layout

$ make
 sed: can't read group: No such file or directory
 sed: can't read group: No such file or directory
 ...

Looks good.

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

#3 lore raw

PATCH 2/5 xfstests: use value of FSTYP if defined externally

In reply to David Sterba

The initial value of FSTYP is unconditionally set to 'xfs' and the filesystem type is taken from the TEST_DEV. This could lead to confusion if the device hasn't been formatted yet, eg. an empty image in VM, or a different test setup took place before.

Now one can specify the desired FSTYP in advance and be safe. If unset, the fallback to TEST_DEV type continues to work.

---
 README | 3 +++
 check  | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
README +3 -0
index a49ca7c3ff15..62974ef87b89 100644
@@ -65,6 +65,9 @@ Preparing system for tests (IRIX and Linux):
                environment variable set to "yes" will enable their use.
              - setenv DIFF_LENGTH "number of diff lines to print from a failed test",
                by default 10, set to 0 to print the full diff
+             - setenv FSTYP "the filesystem you want to test", the filesystem
+               type is devised from the TEST_DEV device, but you may want to
+               override it
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
           machine
check +4 -3
index 320ad26b7c2c..9e4275b1fa37 100755
@@ -33,7 +33,7 @@ showme=false
 have_test_arg=false
 randomize=false
 here=`pwd`
-FSTYP=xfs
+FSTYP=${FSTYP:-xfs}
 xfile=""
 
 # start the initialisation work now
@@ -57,8 +57,9 @@ then
     exit 1
 fi
 
-# Autodetect fs type based on what's on $TEST_DEV
-if [ "$HOSTOS" == "Linux" ]; then
+# Autodetect fs type based on what's on $TEST_DEV unless it's been set
+# externally
+if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then
     FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
 fi
 export FSTYP
Signature · 6 lines
1.8.5

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

Re: [PATCH 2/5] xfstests: use value of FSTYP if defined externally

Quoted 33 lines · David Sterba

The initial value of FSTYP is unconditionally set to 'xfs' and the filesystem type is taken from the TEST_DEV. This could lead to confusion if the device hasn't been formatted yet, eg. an empty image in VM, or a different test setup took place before.

Now one can specify the desired FSTYP in advance and be safe. If unset, the fallback to TEST_DEV type continues to work.

---
 README | 3 +++
 check  | 7 ++++---
 2 files changed, 7 insertions(+), 3 deletions(-)
README +3 -0
index a49ca7c3ff15..62974ef87b89 100644
@@ -65,6 +65,9 @@ Preparing system for tests (IRIX and Linux):
                environment variable set to "yes" will enable their use.
              - setenv DIFF_LENGTH "number of diff lines to print from a failed test",
                by default 10, set to 0 to print the full diff
+             - setenv FSTYP "the filesystem you want to test", the filesystem
+               type is devised from the TEST_DEV device, but you may want to
+               override it
         - or add a case to the switch in common/config assigning
           these variables based on the hostname of your test
           machine
check +0 -0
index 320ad26b7c2c..9e4275b1fa37 100755

check showme=false · line 36

Quoted 5 lines
check +1 -1
@@ -33,7 +33,7 @@ showme=false
 have_test_arg=false
 randomize=false
 here=`pwd`
-FSTYP=xfs
+FSTYP=${FSTYP:-xfs}

":-xfs" means assign the value of $xfs if $FTYPE is null. xfs is not a variable....

check then · line 62

Quoted 12 lines
check +3 -2
 xfile=""
 
 # start the initialisation work now
@@ -57,8 +57,9 @@ then
     exit 1
 fi
 
-# Autodetect fs type based on what's on $TEST_DEV
-if [ "$HOSTOS" == "Linux" ]; then
+# Autodetect fs type based on what's on $TEST_DEV unless it's been set
+# externally
+if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then

If the default value expansion is fixed, FSTYP will always have a value here Hence it will never, ever probe.

check then · line 65

Quoted 3 lines
check +0 -0
     FSTYP=`blkid -c /dev/null -s TYPE -o value $TEST_DEV`
 fi
 export FSTYP

I suspect what you want is:

-FSTYP=xfs

.....

if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then
FSTYP=blkid -c /dev/null -s TYPE -o value $TEST_DEV
fi
FSTYP=${FSTYP:=xfs}
export FSTYP

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

Re: [PATCH 2/5] xfstests: use value of FSTYP if defined externally

Quoted 12 lines · Dave Chinner

check showme=false · line 36

Quoted 8 lines · David Sterba
check +1 -1
@@ -33,7 +33,7 @@ showme=false
 have_test_arg=false
 randomize=false
 here=`pwd`
-FSTYP=xfs
+FSTYP=${FSTYP:-xfs}

":-xfs" means assign the value of $xfs if $FTYPE is null. xfs is not a variable....

Docs say that

${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

so 'xfs' will expand to itself. And I did test this one with:

$ cat default.sh << EOF
FSTYP=${FSTYP:-xfs}
echo $FSTYP
EOF
$ cat external.sh << EOF
FSTYP=btrfs
source default.sh
EOF
$ sh default.sh
xfs
$ sh external.sh
btrfs
Quoted 17 lines

check then · line 62

Quoted 5 lines
check +3 -2
-# Autodetect fs type based on what's on $TEST_DEV
-if [ "$HOSTOS" == "Linux" ]; then
+# Autodetect fs type based on what's on $TEST_DEV unless it's been set
+# externally
+if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then

If the default value expansion is fixed, FSTYP will always have a value here Hence it will never, ever probe.

Quoted 3 lines

FSTYP=blkid -c /dev/null -s TYPE -o value $TEST_DEV
fi
export FSTYP

I suspect what you want is:

-FSTYP=xfs

Quoted 7 lines

.....

if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then
FSTYP=blkid -c /dev/null -s TYPE -o value $TEST_DEV
fi
FSTYP=${FSTYP:=xfs}
export FSTYP

Right, the default assignment has to be last. I'll use the := form to be consistent with what's used in the file, though :- works here as well, just does not assign the variable within the ${...} expression. The result is the same.

thanks,
david

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

#6 lore raw

Re: [PATCH 2/5] xfstests: use value of FSTYP if defined externally

Quoted 32 lines · David Sterba
Quoted 12 lines · Dave Chinner

check showme=false · line 36

Quoted 8 lines · David Sterba
check +1 -1
@@ -33,7 +33,7 @@ showme=false
 have_test_arg=false
 randomize=false
 here=`pwd`
-FSTYP=xfs
+FSTYP=${FSTYP:-xfs}

":-xfs" means assign the value of $xfs if $FTYPE is null. xfs is not a variable....

Docs say that

${parameter:-word}
If parameter is unset or null, the expansion of word is substituted. Otherwise, the value of parameter is substituted.

so 'xfs' will expand to itself. And I did test this one with:

$ cat default.sh << EOF
FSTYP=${FSTYP:-xfs}
echo $FSTYP
EOF
$ cat external.sh << EOF
FSTYP=btrfs
source default.sh
EOF
Quoted 5 lines
$ sh default.sh
xfs
$ sh external.sh
btrfs

Funny, I did the same tests to check and kept getting no output instead of the "xfs" result. Changing it to := made it work just fine. Oh well... :/

Quoted 25 lines
Quoted 17 lines

check then · line 62

Quoted 5 lines
check +3 -2
-# Autodetect fs type based on what's on $TEST_DEV
-if [ "$HOSTOS" == "Linux" ]; then
+# Autodetect fs type based on what's on $TEST_DEV unless it's been set
+# externally
+if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then

If the default value expansion is fixed, FSTYP will always have a value here Hence it will never, ever probe.

Quoted 3 lines

FSTYP=blkid -c /dev/null -s TYPE -o value $TEST_DEV
fi
export FSTYP

I suspect what you want is:

-FSTYP=xfs

Quoted 7 lines

.....

if [ -z "$FSTYP" -a "$HOSTOS" == "Linux" ]; then
FSTYP=blkid -c /dev/null -s TYPE -o value $TEST_DEV
fi
FSTYP=${FSTYP:=xfs}
export FSTYP

Quoted 4 lines

Right, the default assignment has to be last. I'll use the := form to be consistent with what's used in the file, though :- works here as well, just does not assign the variable within the ${...} expression. The result is the same.

Thanks.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

PATCH 3/5 xfstests: don't suggest to run full diff when DIFF_LENGTH is 0

In reply to David Sterba

If DIFF_LENGTH is set to 0, the full output is available and the message does not make sense.

---
 check | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
check +3 -3
index 9e4275b1fa37..d578e49b78d4 100755
@@ -510,11 +510,11 @@ do
 				cat
 			else
 				head -n "$DIFF_LENGTH"
+				echo "..."
+				echo "(Run '$diff $seq.out $seqres.out.bad'"
+					" to see the entire diff)"
 			fi; } | \
 			sed -e 's/^\(.\)/    \1/'
-		    echo "     ..."
-		    echo "     (Run '$diff $seq.out $seqres.out.bad' to see the" \
-			 "entire diff)"
 		    err=true
 		fi
 	    fi
Signature · 6 lines
1.8.5

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

Re: [PATCH 3/5] xfstests: don't suggest to run full diff when DIFF_LENGTH is 0

Quoted 13 lines · David Sterba

If DIFF_LENGTH is set to 0, the full output is available and the message does not make sense.

---
 check | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
check +0 -0
index 9e4275b1fa37..d578e49b78d4 100755

check do · line 515

Quoted 6 lines
check +3 -0
@@ -510,11 +510,11 @@ do
 				cat
 			else
 				head -n "$DIFF_LENGTH"
+				echo "..."
+				echo "(Run '$diff $seq.out $seqres.out.bad'"
+					" to see the entire diff)"

You're missing a trailing "\" there. Even simple patches need testing. ;)

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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

PATCH 4/5 xfstests: accept tests/ prefix for test name on commandline

In reply to David Sterba

Just for convenience to let tab completion or shell globs work (files that are not in the group file are ignored).

---
 check | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
check +2 -1
index d578e49b78d4..a787c4a9f69f 100755
@@ -263,12 +263,13 @@ if $have_test_arg; then
 			exit $status
 			;;
 		*)	test_dir=`dirname $1`
+			test_dir=${test_dir#$SRC_DIR/*}
 			test_name=`basename $1`
 			group_file=$SRC_DIR/$test_dir/group
 
 			if egrep "^$test_name" $group_file >/dev/null ; then
 				# in group file ... OK
-				echo $SRC_DIR/$1 >>$tmp.arglist
+				echo $SRC_DIR/$test_dir/$test_name >>$tmp.arglist
 			else
 				# oops
 				echo "$1 - unknown test, ignored"
Signature · 6 lines
1.8.5

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

PATCH 5/5 xfstests: update lsqa.pl for new tests layout

In reply to David Sterba

Accepted parameter types:
- nothing - list all tests from all subdirectories in tests/*
- tests/DIR - list all tests from DIR
- tests/DIR/123 - show header from single test

---
 lsqa.pl | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)
lsqa.pl +24 -8
index 040196f70120..b4fc83f43f99 100755
@@ -15,13 +15,20 @@
 # along with this program; if not, write the Free Software Foundation,
 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #
+
+# Print headers of given tests
+# Accepted parameter types:
+# - nothing - list all tests from all subdirectories in tests/*
+# - tests/DIR - list all tests from DIR
+# - tests/DIR/123 - show header from single test
+
 use strict;
 
 use Getopt::Long;
 
 sub help();
 sub get_qa_header($);
-sub get_qa_tests();
+sub get_qa_tests;
 
 my %opt;
 
@@ -43,8 +50,19 @@ if ($opt{'help'}) {
     die help();
 }
 
-my @qatests = map {sprintf("%03d", $_)} @ARGV;
-@qatests = get_qa_tests() unless (@qatests);
+my @qatests;
+
+if (!@ARGV) {
+    my $d="tests";
+    opendir(DIR, $d);
+    map { push @qatests,get_qa_tests("$d/$_") if -d "$d/$_" } readdir(DIR);
+    closedir(DIR);
+}
+
+foreach (@ARGV) {
+    push @qatests,$_ if -f && /\d{3}$/;
+    push @qatests,get_qa_tests($_) if -d;
+}
 
 foreach (@qatests) {
     my @h = get_qa_header($_);
@@ -103,13 +121,11 @@ sub get_qa_header($) {
     return @l;
 }
 
-sub get_qa_tests() {
+sub get_qa_tests {
     my $d = shift || $ENV{'PWD'};
 
     opendir(my $DIR, $d) || die "can't opendir $d: $!";
-    my @qa = grep {m/^\d\d\d$/ && -f "$d/$_" } readdir($DIR);
+    my @qa = sort grep { m/^\d\d\d$/ && -f "$d/$_" } readdir($DIR);
     closedir($DIR);
-
-    return @qa;
+    return map { $_ = "$d/$_" } @qa;
 }
-
Signature · 6 lines
1.8.5

_______________________________________________
xfs mailing list
[email protected]
http://oss.sgi.com/mailman/listinfo/xfs
#11 lore raw
In reply to David Sterba
Quoted 8 lines · David Sterba

Minor bugfixes or enhancements.

David Sterba (5):
xfstests: fix minor build warning
xfstests: use value of FSTYP if defined externally
xfstests: don't suggest to run full diff when DIFF_LENGTH is 0
xfstests: accept tests/ prefix for test name on commandline
xfstests: update lsqa.pl for new tests layout

Hi David, I committed the three patches that were OK, so if you can fix up the other two and resubmit them, that'd be great.

Cheers,

Dave.

Signature · 7 lines
Dave Chinner
[email protected]

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