Skip to contentSkip to conversation

Output selection

PATCH In review Jan Kara 4 participants 10 messages Nov 24, 2015 – Dec 21, 2015

lore
Share & tools
lore
author
#1 lore raw

PATCH v2 1/3 common: Factor out function to get OS name

In reply to Jan Kara
---
 common/rc | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)
common/rc +14 -8
index 4c2f42c8d0eb..81418280f163 100644
@@ -2188,6 +2188,18 @@ _full_platform_details()
      echo "$os/$platform $host $kernel"
 }
 
+_get_os_name()
+{
+	if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
+		echo 'irix'
+	elif [ "`uname`" == "Linux" ]; then
+		echo 'linux'
+	else
+		echo Unknown operating system: `uname`
+		exit
+	fi
+}
+
 _link_out_file()
 {
 	if [ -z "$1" -o -z "$2" ]; then
@@ -2195,14 +2207,8 @@ _link_out_file()
 		exit
 	fi
 	rm -f $2
-	if [ "`uname`" == "IRIX64" ] || [ "`uname`" == "IRIX" ]; then
-		ln -s $1.irix $2
-	elif [ "`uname`" == "Linux" ]; then
-		ln -s $1.linux $2
-	else
-		echo Error test $seq does not run on the operating system: `uname`
-		exit
-	fi
+	SUFFIX=$(_get_os_name())
+	ln -s $1.$SUFFIX $2
 }
 
 _die()
Signature · 1 line
2.1.4

Jan Kara

author
#0 lore raw

v2 cover Output selection

From: Jan Kara <[email protected]>

Hello,

the patch series below addresses some issues with test ext4/001. First two patches improve _link_out_file helper function to allow selection of output (or in general linking any file when using _link_out_file_named() variant) based on a feature string (usually mount options, fs features, operating system) passed to the function (if no feature string is passed, the function defaults to using "operating system name","mount options"). This feature is useful when e.g. different mount options change behavior of the filesystem and thus different output is generated but we want to have the test working for all mount options.

Patch 3 uses the output selection function in ext4/001 to select different output files based on mount options.

Comments welcome!

Honza
--

Changes since v1:
* rebased on the current head of xfstests
* integrated output selection with _link_out_file and converted all tests using it

author
#3 lore raw

PATCH v2 2/3 common: Improve _link_output_file to be more versatile

From: Jan Kara <[email protected]>

Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like:

feat1,feat2: suffix

The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected.

Update all tests using _link_out_file to the new calling convention.

---
 common/rc                   |  49 +++++++++--
 tests/generic/088           |   2 +-
 tests/generic/088.cfg       |   2 +
 tests/xfs/018               |   2 +-
 tests/xfs/018.cfg           |   2 +
 tests/xfs/022               |   2 +-
 tests/xfs/022.cfg           |   2 +
 tests/xfs/023               |   2 +-
 tests/xfs/023.cfg           |   2 +
 tests/xfs/030               |   2 +-
 tests/xfs/030.cfg           |   2 +
 tests/xfs/031               |   2 +-
 tests/xfs/031.cfg           |   2 +
 tests/xfs/033               |   6 +-
 tests/xfs/033.cfg           |   3 +
 tests/xfs/033.crc.out.linux | 197 --------------------------------------------
 tests/xfs/033.out.crc.linux | 197 ++++++++++++++++++++++++++++++++++++++++++++
 tests/xfs/035               |   2 +-
 tests/xfs/035.cfg           |   2 +
 tests/xfs/036               |   2 +-
 tests/xfs/036.cfg           |   2 +
 tests/xfs/039               |   2 +-
 tests/xfs/039.cfg           |   2 +
 tests/xfs/043               |   2 +-
 tests/xfs/043.cfg           |   2 +
 tests/xfs/055               |   2 +-
 tests/xfs/082               |   2 +-
 tests/xfs/082.cfg           |   2 +
 tests/xfs/146               |   2 +-
 tests/xfs/146.cfg           |   2 +
 30 files changed, 283 insertions(+), 219 deletions(-)
 create mode 100644 tests/generic/088.cfg
 create mode 100644 tests/xfs/018.cfg
 create mode 100644 tests/xfs/022.cfg
 create mode 100644 tests/xfs/023.cfg
 create mode 100644 tests/xfs/030.cfg
 create mode 100644 tests/xfs/031.cfg
 create mode 100644 tests/xfs/033.cfg
 delete mode 100644 tests/xfs/033.crc.out.linux
 create mode 100644 tests/xfs/033.out.crc.linux
 create mode 100644 tests/xfs/035.cfg
 create mode 100644 tests/xfs/036.cfg
 create mode 100644 tests/xfs/039.cfg
 create mode 100644 tests/xfs/043.cfg
 create mode 100644 tests/xfs/082.cfg
 create mode 100644 tests/xfs/146.cfg
common/rc +43 -6
index 81418280f163..8256a15050dc 100644
@@ -2200,15 +2200,52 @@ _get_os_name()
 	fi
 }
 
+_link_out_file_named()
+{
+	export FEATURES=$2
+	SUFFIX=$(perl -e '
+		my %feathash;
+		my $feature, $result, $suffix, $opts;
+
+		foreach $feature (split(/,/, $ENV{"FEATURES"})) {
+			$feathash{$feature} = 1;
+		}
+		$result = "default";
+		while (<>) {
+			my $found = 1;
+
+			chomp;
+			($opts, $suffix) = split(/ *: */);
+			foreach my $opt (split(/,/, $opts)) {
+				if (!exists($feathash{$opt})) {
+					$found = 0;
+					last;
+				}
+			}
+			if ($found == 1) {
+				$result = $suffix;
+				last;
+			}
+		}
+		print $result
+		' <$seqfull.cfg)
+	rm -f $1
+	SRC=$(basename $1)
+	ln -fs $SRC.$SUFFIX $1
+}
+
 _link_out_file()
 {
-	if [ -z "$1" -o -z "$2" ]; then
-		echo Error must pass src and dst.
-		exit
+	if [ $# -eq 0 ]; then
+		FEATURES="$(_get_os_name)"
+		if [ -n "$MOUNT_OPTIONS" ]; then
+			FEATURES=$FEATURES,${MOUNT_OPTIONS##"-o "}
+		fi
+	else
+		FEATURES=$1
 	fi
-	rm -f $2
-	SUFFIX=$(_get_os_name())
-	ln -s $1.$SUFFIX $2
+
+	_link_out_file_named $seqfull.out "$FEATURES"
 }
 
 _die()
tests/generic/088 +1 -1
index 983de983c059..46ce6ae4e25d 100755
@@ -43,7 +43,7 @@ _filter()
 }
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs generic
tests/generic/088.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/018 +1 -1
index f097b283207e..848981f87ff4 100755
@@ -54,7 +54,7 @@ _require_scratch
 _require_v2log
 
 # link correct .out file
-_link_out_file $seq.op $seqfull.op
+_link_out_file_named $seqfull.op $(_get_os_name)
 
 echo "*** init FS"
 umount $SCRATCH_DEV >/dev/null 2>&1
tests/xfs/018.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/022 +1 -1
index cd9b9ec18c5e..b2b6142cb285 100755
@@ -39,7 +39,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/022.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/023 +1 -1
index 120be64e432d..9a899a86268d 100755
@@ -38,7 +38,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/023.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/030 +1 -1
index a43455f595ba..d2f5ed1917db 100755
@@ -46,7 +46,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common/repair
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
 #
tests/xfs/030.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/031 +1 -1
index 48a97e1d5f4f..59d68c31f9a1 100755
@@ -39,7 +39,7 @@ rm -f $seqres.full
 . ./common/filter
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 _check_repair()
 {
tests/xfs/031.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/033 +3 -3
index 576d437e33ff..dab111aa00f4 100755
@@ -84,11 +84,11 @@ _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
 	_scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1
 
 # link correct .out file
+FEATURES=$(_get_os_name)
 if [ $_fs_has_crcs -eq 1 ]; then
-	_link_out_file $seq.crc.out $seqfull.out
-else
-	_link_out_file $seq.out $seqfull.out
+	FEATURES=$FEATURES,crc
 fi
+_link_out_file_named $seqfull.out "$FEATURES"
 
 `xfs_db -r -c sb -c p $SCRATCH_DEV | grep 'ino = ' | \
 	sed -e 's/ //g' -e 's/^/export /'`
tests/xfs/033.cfg new file +3 -0
new file mode 100644
index 000000000000..88e90e575804
@@ -0,0 +1,3 @@
+irix: irix
+linux,crc: crc.linux
+linux: linux
tests/xfs/033.crc.out.linux deleted +0 -197

197 lines not on this page · raw message

tests/xfs/033.out.crc.linux new file +197 -0

197 lines not on this page · raw message

tests/xfs/035 +1 -1
index 70eac93eff29..25f2f6972f9a 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/035.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/036 +1 -1
index 32b8c87c175f..280d03665ba9 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/036.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/039 +1 -1
index 974792300e8b..2f765b825b9d 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/039.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/043 +1 -1
index 55a52257a7d8..59eeff6e7777 100755
@@ -39,7 +39,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/043.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/055 +1 -1
index cc747d3018a1..920ba2886cc0 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/082 +1 -1
index fff1d6b48dc2..f1178fdc9311 100755
@@ -55,7 +55,7 @@ _require_scratch
 _require_v2log 
 
 # link correct .out file
-_link_out_file $seq.op $seqfull.op
+_link_out_file_named $seqfull.op $(_get_os_name)
 
 echo "*** init FS"
 umount $SCRATCH_DEV >/dev/null 2>&1
tests/xfs/082.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
tests/xfs/146 +1 -1
index c6343f86f73a..f6cd3f30215a 100755
@@ -48,7 +48,7 @@ _supported_fs xfs
 _supported_os Linux IRIX
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 _require_scratch
 _scratch_mkfs_xfs >/dev/null 2>&1
tests/xfs/146.cfg new file +2 -0
new file mode 100644
index 000000000000..7ffdfc078230
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
Signature · 1 line
2.1.4
author
#8 lore raw

PATCH v2 3/3 ext4/001: Select different output based on mount options

In reply to Jan Kara

From: Jan Kara <[email protected]>

Depending on mount options, we handle unwritten extents somewhat differently. So sometimes we end up zeroing out unwritten extent and converting it to written one and sometimes we just split it. Choose expected output based on mount options.

---
 tests/ext4/001             |   4 +
 tests/ext4/001.cfg         |   2 +
 tests/ext4/001.out         | 333 ---------------------------------------------
 tests/ext4/001.out.default | 333 +++++++++++++++++++++++++++++++++++++++++++++
 tests/ext4/001.out.nozero  | 333 +++++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 672 insertions(+), 333 deletions(-)
 create mode 100644 tests/ext4/001.cfg
 delete mode 100644 tests/ext4/001.out
 create mode 100644 tests/ext4/001.out.default
 create mode 100644 tests/ext4/001.out.nozero
tests/ext4/001 +4 -0
index 5409f488dd54..c22a5e1ed520 100755
@@ -22,6 +22,7 @@
 #-----------------------------------------------------------------------
 #
 
+seqfull=$0
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
 echo "QA output created by $seq"
@@ -48,6 +49,9 @@ _supported_os Linux
 _require_xfs_io_command "fzero"
 _require_test
 
+# Select appropriate golden output based on mount options
+_link_out_file
+
 testfile=$TEST_DIR/001.$$
 
 # Standard zero range tests
tests/ext4/001.cfg new file +2 -0
new file mode 100644
index 000000000000..1942203f91ea
@@ -0,0 +1,2 @@
+dax: nozero
+dioread_nolock: nozero
tests/ext4/001.out deleted +0 -333

333 lines not on this page · raw message

tests/ext4/001.out.default new file +333 -0

333 lines not on this page · raw message

tests/ext4/001.out.nozero new file +333 -0

333 lines not on this page · raw message

Signature · 1 line
2.1.4
#4 lore raw

Re: [PATCH 2/3] common: Improve _link_output_file to be more versatile

In reply to Jan Kara
Quoted 9 lines · Jan Kara

From: Jan Kara <[email protected]>

Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like:

feat1,feat2: suffix

Quoted 8 lines

The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected.

Update all tests using _link_out_file to the new calling convention.

I made a slight change so that if $seqfull.cfg doesn't exist, we use ./common/default.cfg instead. This avoids the need to create a large number of identical files:

Quoted 4 lines
 tests/generic/088.cfg       |   2 +
 tests/xfs/018.cfg           |   2 +
 tests/xfs/022.cfg           |   2 +
 tests/xfs/023.cfg           |   2 +
Quoted 8 lines
 tests/xfs/030.cfg           |   2 +
 tests/xfs/031.cfg           |   2 +
 tests/xfs/035.cfg           |   2 +
 tests/xfs/036.cfg           |   2 +
 tests/xfs/039.cfg           |   2 +
 tests/xfs/043.cfg           |   2 +
 tests/xfs/082.cfg           |   2 +
 tests/xfs/146.cfg           |   2 +

What do you think?

- Ted

commit 37c2d44b6cc6772f0daa10761fb532b5662dc6fc

Author: Jan Kara <[email protected]>
Date:   Tue Nov 24 11:39:57 2015 +0100

common: Improve _link_output_file to be more versatile

Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like:

feat1,feat2: suffix

The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected.

Update all tests using _link_out_file to the new calling convention.

common/default.cfg new file +2 -0
new file mode 100644
index 0000000..7ffdfc0
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
common/rc +51 -6

66 lines not on this page · raw message

tests/generic/088 +1 -1
index 983de98..46ce6ae 100755
@@ -43,7 +43,7 @@ _filter()
 }
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs generic
tests/xfs/018 +1 -1
index f097b28..848981f 100755
@@ -54,7 +54,7 @@ _require_scratch
 _require_v2log
 
 # link correct .out file
-_link_out_file $seq.op $seqfull.op
+_link_out_file_named $seqfull.op $(_get_os_name)
 
 echo "*** init FS"
 umount $SCRATCH_DEV >/dev/null 2>&1
tests/xfs/022 +1 -1
index cd9b9ec..b2b6142 100755
@@ -39,7 +39,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/023 +1 -1
index 120be64..9a899a8 100755
@@ -38,7 +38,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/030 +1 -1
index a43455f..d2f5ed1 100755
@@ -46,7 +46,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common/repair
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
 #
tests/xfs/031 +1 -1
index 48a97e1..59d68c3 100755
@@ -39,7 +39,7 @@ rm -f $seqres.full
 . ./common/filter
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 _check_repair()
 {
tests/xfs/033 +3 -3
index 576d437..dab111a 100755
@@ -84,11 +84,11 @@ _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
 	_scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1
 
 # link correct .out file
+FEATURES=$(_get_os_name)
 if [ $_fs_has_crcs -eq 1 ]; then
-	_link_out_file $seq.crc.out $seqfull.out
-else
-	_link_out_file $seq.out $seqfull.out
+	FEATURES=$FEATURES,crc
 fi
+_link_out_file_named $seqfull.out "$FEATURES"
 
 `xfs_db -r -c sb -c p $SCRATCH_DEV | grep 'ino = ' | \
 	sed -e 's/ //g' -e 's/^/export /'`
tests/xfs/033.cfg new file +3 -0
new file mode 100644
index 0000000..88e90e5
@@ -0,0 +1,3 @@
+irix: irix
+linux,crc: crc.linux
+linux: linux
tests/xfs/033.out.crc.linux renamed from tests/xfs/033.crc.out.linux +0 -0
similarity index 100%
rename from tests/xfs/033.crc.out.linux
rename to tests/xfs/033.out.crc.linux
tests/xfs/035 +1 -1
index 70eac93..25f2f69 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/036 +1 -1
index 32b8c87..280d036 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/039 +1 -1
index 9747923..2f765b8 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/043 +1 -1
index 55a5225..59eeff6 100755
@@ -39,7 +39,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/055 +1 -1
index cc747d3..920ba28 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/082 +1 -1
index fff1d6b..f1178fd 100755
@@ -55,7 +55,7 @@ _require_scratch
 _require_v2log 
 
 # link correct .out file
-_link_out_file $seq.op $seqfull.op
+_link_out_file_named $seqfull.op $(_get_os_name)
 
 echo "*** init FS"
 umount $SCRATCH_DEV >/dev/null 2>&1
tests/xfs/146 +1 -1
index c6343f8..f6cd3f3 100755
@@ -48,7 +48,7 @@ _supported_fs xfs
 _supported_os Linux IRIX
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 _require_scratch
 _scratch_mkfs_xfs >/dev/null 2>&1
Reviewed-by on v2 3/3
#9 lore raw

Re: [PATCH 3/3] ext4/001: Select different output based on mount options

In reply to Jan Kara
Quoted 8 lines · Jan Kara

From: Jan Kara <[email protected]>

Depending on mount options, we handle unwritten extents somewhat differently. So sometimes we end up zeroing out unwritten extent and converting it to written one and sometimes we just split it. Choose expected output based on mount options.

- Ted

author
#5 lore raw

Re: [PATCH 2/3] common: Improve _link_output_file to be more versatile

In reply to Theodore Ts'o
Quoted 36 lines · Ted Tso
Quoted 9 lines · Jan Kara

From: Jan Kara <[email protected]>

Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like:

feat1,feat2: suffix

Quoted 8 lines

The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected.

Update all tests using _link_out_file to the new calling convention.

I made a slight change so that if $seqfull.cfg doesn't exist, we use ./common/default.cfg instead. This avoids the need to create a large number of identical files:

Quoted 4 lines
 tests/generic/088.cfg       |   2 +
 tests/xfs/018.cfg           |   2 +
 tests/xfs/022.cfg           |   2 +
 tests/xfs/023.cfg           |   2 +
Quoted 8 lines
 tests/xfs/030.cfg           |   2 +
 tests/xfs/031.cfg           |   2 +
 tests/xfs/035.cfg           |   2 +
 tests/xfs/036.cfg           |   2 +
 tests/xfs/039.cfg           |   2 +
 tests/xfs/043.cfg           |   2 +
 tests/xfs/082.cfg           |   2 +
 tests/xfs/146.cfg           |   2 +
Quoted 1 line

What do you think?

So I'm somewhat undecided whether this is better or not ;). It certainly saves us some churn with identical .cfg files for linux vs irix configs but OTOH I don't expect there to be much more .cfg files selecting between irix and linux so this is mostly one-time issue. So I guess I'll leave it upto Dave and his taste to decide what he finds better.

Honza

Quoted 303 lines

commit 37c2d44b6cc6772f0daa10761fb532b5662dc6fc

Author: Jan Kara <[email protected]>
Date:   Tue Nov 24 11:39:57 2015 +0100

common: Improve _link_output_file to be more versatile

Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like:

feat1,feat2: suffix

The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected.

Update all tests using _link_out_file to the new calling convention.

common/default.cfg new file +2 -0
new file mode 100644
index 0000000..7ffdfc0
@@ -0,0 +1,2 @@
+irix: irix
+linux: linux
common/rc +51 -6
index 62216f4..3b4cbe0 100644
@@ -2205,15 +2205,60 @@ _get_os_name()
 	fi
 }
 
+_link_out_file_named()
+{
+	local cfg_file
+	export FEATURES=$2
+
+	if test -f $seqfull.cfg; then
+		cfg_file=$seqfull.cfg
+	else
+		cfg_file=./common/default.cfg
+	fi
+
+	SUFFIX=$(perl -e '
+		my %feathash;
+		my $feature, $result, $suffix, $opts;
+
+		foreach $feature (split(/,/, $ENV{"FEATURES"})) {
+			$feathash{$feature} = 1;
+		}
+		$result = "default";
+		while (<>) {
+			my $found = 1;
+
+			chomp;
+			($opts, $suffix) = split(/ *: */);
+			foreach my $opt (split(/,/, $opts)) {
+				if (!exists($feathash{$opt})) {
+					$found = 0;
+					last;
+				}
+			}
+			if ($found == 1) {
+				$result = $suffix;
+				last;
+			}
+		}
+		print $result
+		' <$cfg_file)
+	rm -f $1
+	SRC=$(basename $1)
+	ln -fs $SRC.$SUFFIX $1
+}
+
 _link_out_file()
 {
-	if [ -z "$1" -o -z "$2" ]; then
-		echo Error must pass src and dst.
-		exit
+	if [ $# -eq 0 ]; then
+		FEATURES="$(_get_os_name)"
+		if [ -n "$MOUNT_OPTIONS" ]; then
+			FEATURES=$FEATURES,${MOUNT_OPTIONS##"-o "}
+		fi
+	else
+		FEATURES=$1
 	fi
-	rm -f $2
-	SUFFIX=$(_get_os_name())
-	ln -s $1.$SUFFIX $2
+
+	_link_out_file_named $seqfull.out "$FEATURES"
 }
 
 _die()
tests/generic/088 +1 -1
index 983de98..46ce6ae 100755
@@ -43,7 +43,7 @@ _filter()
 }
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs generic
tests/xfs/018 +1 -1
index f097b28..848981f 100755
@@ -54,7 +54,7 @@ _require_scratch
 _require_v2log
 
 # link correct .out file
-_link_out_file $seq.op $seqfull.op
+_link_out_file_named $seqfull.op $(_get_os_name)
 
 echo "*** init FS"
 umount $SCRATCH_DEV >/dev/null 2>&1
tests/xfs/022 +1 -1
index cd9b9ec..b2b6142 100755
@@ -39,7 +39,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/023 +1 -1
index 120be64..9a899a8 100755
@@ -38,7 +38,7 @@ trap "rm -rf $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/030 +1 -1
index a43455f..d2f5ed1 100755
@@ -46,7 +46,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
 . ./common/repair
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # nuke the superblock, AGI, AGF, AGFL; then try repair the damage
 #
tests/xfs/031 +1 -1
index 48a97e1..59d68c3 100755
@@ -39,7 +39,7 @@ rm -f $seqres.full
 . ./common/filter
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 _check_repair()
 {
tests/xfs/033 +3 -3
index 576d437..dab111a 100755
@@ -84,11 +84,11 @@ _scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
 	_scratch_mkfs_xfs -isize=512 | _filter_mkfs >/dev/null 2>&1
 
 # link correct .out file
+FEATURES=$(_get_os_name)
 if [ $_fs_has_crcs -eq 1 ]; then
-	_link_out_file $seq.crc.out $seqfull.out
-else
-	_link_out_file $seq.out $seqfull.out
+	FEATURES=$FEATURES,crc
 fi
+_link_out_file_named $seqfull.out "$FEATURES"
 
 `xfs_db -r -c sb -c p $SCRATCH_DEV | grep 'ino = ' | \
 	sed -e 's/ //g' -e 's/^/export /'`
tests/xfs/033.cfg new file +3 -0
new file mode 100644
index 0000000..88e90e5
@@ -0,0 +1,3 @@
+irix: irix
+linux,crc: crc.linux
+linux: linux
tests/xfs/033.out.crc.linux renamed from tests/xfs/033.crc.out.linux +0 -0
similarity index 100%
rename from tests/xfs/033.crc.out.linux
rename to tests/xfs/033.out.crc.linux
tests/xfs/035 +1 -1
index 70eac93..25f2f69 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/036 +1 -1
index 32b8c87..280d036 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/039 +1 -1
index 9747923..2f765b8 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/043 +1 -1
index 55a5225..59eeff6 100755
@@ -39,7 +39,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/055 +1 -1
index cc747d3..920ba28 100755
@@ -37,7 +37,7 @@ trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
 . ./common/dump
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 # real QA test starts here
 _supported_fs xfs
tests/xfs/082 +1 -1
index fff1d6b..f1178fd 100755
@@ -55,7 +55,7 @@ _require_scratch
 _require_v2log 
 
 # link correct .out file
-_link_out_file $seq.op $seqfull.op
+_link_out_file_named $seqfull.op $(_get_os_name)
 
 echo "*** init FS"
 umount $SCRATCH_DEV >/dev/null 2>&1
tests/xfs/146 +1 -1
index c6343f8..f6cd3f3 100755
@@ -48,7 +48,7 @@ _supported_fs xfs
 _supported_os Linux IRIX
 
 # link correct .out file
-_link_out_file $seq.out $seqfull.out
+_link_out_file
 
 _require_scratch
 _scratch_mkfs_xfs >/dev/null 2>&1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
#6 lore raw

Re: [PATCH 2/3] common: Improve _link_output_file to be more versatile

Maybe it's time to drop IRIX support? I'm pretty sure it hasn't worked for a long time..

#7 lore raw

Re: [PATCH 2/3] common: Improve _link_output_file to be more versatile

In reply to Jan Kara
Quoted 37 lines · Jan Kara
Quoted 36 lines · Ted Tso
Quoted 9 lines · Jan Kara

From: Jan Kara <[email protected]>

Currently _link_output_file() selects output file suffix based on the current operating system. Make it more versatile by allowing selection of output file suffix based on any feature string. The idea is that in config file ($seq.cfg) there are several lines like:

feat1,feat2: suffix

Quoted 8 lines

The function is passed a feature string (or uses os_name,MOUNT_OPTIONS if no argument is passed) and selects output file with a suffix for which all features are present in the feature string. If there is no matching line, output with 'default' suffix is selected.

Update all tests using _link_out_file to the new calling convention.

I made a slight change so that if $seqfull.cfg doesn't exist, we use ./common/default.cfg instead. This avoids the need to create a large number of identical files:

Quoted 12 lines
 tests/generic/088.cfg       |   2 +
 tests/xfs/018.cfg           |   2 +
 tests/xfs/022.cfg           |   2 +
 tests/xfs/023.cfg           |   2 +
 tests/xfs/030.cfg           |   2 +
 tests/xfs/031.cfg           |   2 +
 tests/xfs/035.cfg           |   2 +
 tests/xfs/036.cfg           |   2 +
 tests/xfs/039.cfg           |   2 +
 tests/xfs/043.cfg           |   2 +
 tests/xfs/082.cfg           |   2 +
 tests/xfs/146.cfg           |   2 +
Quoted 7 lines
Quoted 1 line

What do you think?

So I'm somewhat undecided whether this is better or not ;). It certainly saves us some churn with identical .cfg files for linux vs irix configs but OTOH I don't expect there to be much more .cfg files selecting between irix and linux so this is mostly one-time issue. So I guess I'll leave it upto Dave and his taste to decide what he finds better.

I'll take the one-time change here, but as Christoph suggested it really is getting to the point where we should stop considering xfstests to be a cross-platform test suite. Just another cleanup to be done...

Cheers,

Dave.

Signature · 2 lines
Dave Chinner
[email protected]