Skip to contentSkip to conversation

fstests: move test group lists into test files

PATCH New Darrick J. Wong 1 participant 14 messages Jun 21, 2021

lore
Share & tools
lore
#0 lore raw

v3 cover fstests: move test group lists into test files

Hi all,

Test group files (e.g. tests/generic/group) are a pain to keep up. Every week I rebase on Eryu's latest upstream, and every week I have to slog through dozens of trivial merge conflicts because of the groupfiles. Moving tests is annoying because we have to maintain all this code to move the group associations from one /group file to another.

It doesn't need to be this way -- we could move each test's group information into the test itself, and automatically generate the group files as part of the make process. This series does exactly that.

The first few patches add some convenient anchors for the new per-testfile group tagging and a conversion script to migrate existing test files. Next there's a huge patch that is the results of running the conversion script, followed by cleanup of the golden outputs. After that comes the build infrastructure to generate group files and other tweaks to the existing maintainer scripts to use the new infrastructure. Finally, remove the group files themselves and the (now unnecessary) code that maintained them.

v1: promote from rfc, use group.list for autogenerated group files, fix
odd build warts, rename preamble function, update readme
v2: add reviews, remove _cleanup functions that mirror the standard one,
use rm -rf to clean $tmp.*
v3: fix a few documentation nits, rearrange some of the cleanups, tidy
some unused variables

If you're going to start using this mess, you probably ought to just pull from my git trees, which are linked below.

This is an extraordinary way to destroy everything. Enjoy! Comments and questions are, as always, welcome.

--D

fstests git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfstests-dev.git/log/?h=autogenerate-groupfiles-5.14

---
 .gitignore             |    3 
 README                 |   23 +-
 check                  |    6 
 common/preamble        |   63 +++++
 include/buildgrouplist |    8 +
 new                    |  217 +++++-----------
 tests/Makefile         |    4 
 tests/btrfs/001        |   19 -
 tests/btrfs/002        |   19 -
 tests/btrfs/003        |   15 -
 tests/btrfs/004        |   15 -
 tests/btrfs/005        |   21 --
 tests/btrfs/006        |   21 --
 tests/btrfs/006.out    |    2 
 tests/btrfs/012        |    2 
 tests/btrfs/012.out    |    2 
 tests/btrfs/Makefile   |    6 
 tests/btrfs/group      |  246 ------------------
 tests/ceph/Makefile    |    6 
 tests/ceph/group       |    4 
 tests/cifs/Makefile    |    6 
 tests/cifs/group       |    6 
 tests/ext4/Makefile    |    6 
 tests/ext4/group       |   64 -----
 tests/f2fs/Makefile    |    6 
 tests/f2fs/group       |    7 -
 tests/generic/068      |    3 
 tests/generic/184      |    2 
 tests/generic/184.out  |    2 
 tests/generic/Makefile |    6 
 tests/generic/group    |  643 ------------------------------------------------
 tests/nfs/Makefile     |    6 
 tests/nfs/group        |    6 
 tests/ocfs2/Makefile   |    6 
 tests/ocfs2/group      |    1 
 tests/overlay/Makefile |    6 
 tests/overlay/group    |  100 -------
 tests/perf/Makefile    |    6 
 tests/perf/group       |    1 
 tests/shared/Makefile  |    6 
 tests/shared/group     |    8 -
 tests/udf/Makefile     |    6 
 tests/udf/group        |    6 
 tests/xfs/004          |    3 
 tests/xfs/Makefile     |    6 
 tests/xfs/group        |  534 ----------------------------------------
 tools/convert-group    |  138 ++++++++++
 tools/mkgroupfile      |   42 +++
 tools/mvtest           |   15 -
 tools/nextid           |    1 
 tools/nextid           |   31 ++
 tools/sort-group       |  112 --------
 52 files changed, 471 insertions(+), 2022 deletions(-)
 create mode 100644 common/preamble
 create mode 100644 include/buildgrouplist
 delete mode 100644 tests/btrfs/group
 delete mode 100644 tests/ceph/group
 delete mode 100644 tests/cifs/group
 delete mode 100644 tests/ext4/group
 delete mode 100644 tests/f2fs/group
 delete mode 100644 tests/generic/group
 delete mode 100644 tests/nfs/group
 delete mode 100644 tests/ocfs2/group
 delete mode 100644 tests/overlay/group
 delete mode 100644 tests/perf/group
 delete mode 100644 tests/shared/group
 delete mode 100644 tests/udf/group
 delete mode 100644 tests/xfs/group
 create mode 100755 tools/convert-group
 create mode 100755 tools/mkgroupfile
 delete mode 120000 tools/nextid
 create mode 100755 tools/nextid
 delete mode 100755 tools/sort-group
#1 lore raw

PATCH v3 1/13 fstests: fix group check in new script

From: Darrick J. Wong <[email protected]>

In the tests/*/group files, group names are found in the Nth columns of the file, where N > 1. The grep expression to warn about unknown groups is not correct (since it currently checks column 1), so fix this.

---
 new |    5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
new +1 -4
index bb427f0d..357983d9 100755
@@ -243,10 +243,7 @@ else
     #
     for g in $*
     do
-	if grep "^$g[ 	]" $tdir/group >/dev/null
-	then
-	    :
-	else
+	if ! grep -q "[[:space:]]$g" "$tdir/group"; then
 	    echo "Warning: group \"$g\" not defined in $tdir/group"
 	fi
     done
#2 lore raw

PATCH v3 2/13 misc: move exit status into trap handler

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Move the "exit $status" clause of the _cleanup function into the argument to the "trap" command so that we can standardize the registration of the atexit cleanup code in the next few patches.

---
 tests/generic/068 |    3 +--
 tests/xfs/004     |    3 +--
 2 files changed, 2 insertions(+), 4 deletions(-)
tests/generic/068 +1 -2
index 932a8560..573fbd45 100755
@@ -22,10 +22,9 @@ _cleanup()
     cd /
 
     trap 0 1 2 3 15
-    exit $status
 }
 
-trap "_cleanup" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # get standard environment, filters and checks
 . ./common/rc
tests/xfs/004 +1 -2
index d3fb9c95..4d92a08e 100755
@@ -18,9 +18,8 @@ _cleanup()
 {
 	_scratch_unmount
 	rm -f $tmp.*
-	exit $status
 }
-trap "_cleanup" 0 1 2 3 15
+trap "_cleanup; exit \$status" 0 1 2 3 15
 
 _populate_scratch()
 {
#3 lore raw

PATCH v3 3/13 fstests: refactor test boilerplate code

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Create two new helper functions to deal with boilerplate test code:

A helper function to set the seq and seqnum variables. We will expand on this in the next patch so that fstests can autogenerate group files from now on.

A helper function to register cleanup code that will run if the test exits or trips over a standard range of signals.

---
 common/preamble |   55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 new             |   33 ++++++++++++---------------------
 2 files changed, 67 insertions(+), 21 deletions(-)
 create mode 100644 common/preamble
common/preamble new file +55 -0
new file mode 100644
index 00000000..fba766de
@@ -0,0 +1,55 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+
+# Boilerplate fstests functionality
+
+# Standard cleanup function.  Individual tests can override this.
+_cleanup()
+{
+	cd /
+	rm -r -f $tmp.*
+}
+
+# Install the supplied cleanup code as a signal handler for HUP, INT, QUIT,
+# TERM, or when the test exits.  Extra signals can be specified as subsequent
+# parameters.
+_register_cleanup()
+{
+	local cleanup="$1"
+	shift
+
+	test -n "$cleanup" && cleanup="${cleanup}; "
+	trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
+}
+
+# Prepare to run a fstest by initializing the required global variables to
+# their defaults, sourcing common functions, registering a cleanup function,
+# and removing the $seqres.full file.
+#
+# The list of group memberships for this test (e.g. auto quick rw) must be
+# passed as arguments to this helper.  It is not necessary to name this test
+# explicitly as a member of the 'all' group.
+_begin_fstest()
+{
+	if [ -n "$seq" ]; then
+		echo "_begin_fstest can only be called once!"
+		exit 1
+	fi
+
+	seq=`basename $0`
+	seqres=$RESULT_DIR/$seq
+	echo "QA output created by $seq"
+
+	here=`pwd`
+	tmp=/tmp/$$
+	status=1	# failure is the default!
+
+	_register_cleanup _cleanup
+
+	. ./common/rc
+
+	# remove previous $seqres.full before test
+	rm -f $seqres.full
+
+}
new +12 -21
index 357983d9..531fd123 100755
@@ -153,27 +153,18 @@ cat <<End-of-File >$tdir/$id
 #
 # what am I here for?
 #
-seq=\`basename \$0\`
-seqres=\$RESULT_DIR/\$seq
-echo "QA output created by \$seq"
-
-here=\`pwd\`
-tmp=/tmp/\$\$
-status=1	# failure is the default!
-trap "_cleanup; exit \\\$status" 0 1 2 3 15
-
-_cleanup()
-{
-	cd /
-	rm -f \$tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
-. ./common/filter
-
-# remove previous \$seqres.full before test
-rm -f \$seqres.full
+. ./common/preamble
+_begin_fstest group list here
+
+# Override the default cleanup function.
+# _cleanup()
+# {
+# 	cd /
+# 	rm -r -f \$tmp.*
+# }
+
+# Import common functions.
+# . ./common/filter
 
 # real QA test starts here
 
#4 lore raw

PATCH v3 4/13 fstests: add tool migrate group membership data to test files

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Create a tool to migrate the mapping of tests <-> groups out of the group file and into the individual test file as a _begin_fstest call. In the next patches we'll rewrite all the test files and auto generate the group files from the tests.

---
 tools/convert-group |  138 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 138 insertions(+)
 create mode 100755 tools/convert-group
tools/convert-group new file +138 -0
new file mode 100755
index 00000000..81ad9934
@@ -0,0 +1,138 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+
+# Move group tags from the groups file into the test files themselves.
+
+if [ -z "$1" ] || [ "$1" = "--help" ]; then
+	echo "Usage: $0 test_dir [test_dirs...]"
+	exit 1
+fi
+
+obliterate_group_file() {
+	sed -e 's/^#.*$//g' < group | while read test groups; do
+		if [ -z "$test" ]; then
+			continue;
+		elif [ ! -e "$test" ]; then
+			echo "Ignoring unknown test file \"$test\"."
+			continue
+		fi
+
+		# Replace all the open-coded test preparation code with a
+		# single call to _begin_fstest.
+		sed -e '/^seqres=\$RESULT_DIR\/\$seq$/d' \
+		    -e '/^seqres=\"\$RESULT_DIR\/\$seq\"$/d' \
+		    -e '/^echo "QA output created by \$seq"$/d' \
+		    -e '/^here=`pwd`$/d' \
+		    -e '/^here=\$(pwd)$/d' \
+		    -e '/^here=\$PWD$/d' \
+		    -e '/^here=\"`pwd`\"$/d' \
+		    -e '/^tmp=\/tmp\/\$\$$/d' \
+		    -e '/^status=1.*failure.*is.*the.*default/d' \
+		    -e '/^status=1.*FAILure.*is.*the.*default/d' \
+		    -e '/^status=1.*success.*is.*the.*default/d' \
+		    -e '/^status=1.*default.*failure/d' \
+		    -e '/^echo.*QA output created by.*seq/d' \
+		    -e '/^# remove previous \$seqres.full before test/d' \
+		    -e '/^rm -f \$seqres.full/d' \
+		    -e 's|^# get standard environment, filters and checks|# Import common functions.|g' \
+		    -e '/^\. \.\/common\/rc/d' \
+		    -e '/^\. common\/rc/d' \
+		    -e 's|^seq=.*$|. ./common/preamble\n_begin_fstest '"$groups"'|g' \
+		    -i "$test"
+
+		# Replace the open-coded trap calls that register cleanup code
+		# with a call to _register_cleanup.
+		#
+		# For tests that registered empty-string cleanups or open-coded
+		# calls to remove $tmp files, remove the _register_cleanup
+		# calls entirely because the default _cleanup does that for us.
+		#
+		# For tests that now have a _register_cleanup call for the
+		# _cleanup function, remove the explicit call because
+		# _begin_fstest already registers that for us.
+		#
+		# For tests that override _cleanup, insert a comment noting
+		# that it is overriding the default, to match the ./new
+		# template.
+		sed -e 's|^trap "exit \\\$status" 0 1 2 3 15|_register_cleanup ""|g' \
+		    -e 's|^trap "\(.*\)[[:space:]]*; exit \\\$status" 0 1 2 3 15|_register_cleanup "\1"|g' \
+		    -e 's|^trap "\(.*\)[[:space:]]*; exit \\\$status" 1 2 3 15|_register_cleanup "\1"|g' \
+		    -e 's|^trap '"'"'\(.*\)[[:space:]]*; exit \$status'"'"' 0 1 2 3 15|_register_cleanup "\1"|g' \
+		    -e 's|^trap "\(.*\)[[:space:]]*; exit \\\$status" 0 1 2 3 7 15|_register_cleanup "\1" BUS|g' \
+		    -e 's|^_register_cleanup "[[:space:]]*\([^[:space:]]*\)[[:space:]]*"|_register_cleanup "\1"|g' \
+		    -e '/^_register_cleanup ""$/d' \
+		    -e '/^_register_cleanup "rm -f \$tmp.*"$/d' \
+		    -e '/^_register_cleanup "_cleanup"$/d' \
+		    -e 's|^_cleanup()|# Override the default cleanup function.\n_cleanup()|g' \
+		    -i "$test"
+
+		# If the test doesn't import any common functionality,
+		# get rid of the pointless comment.
+		if ! grep -q '^\. .*common' "$test"; then
+			sed -e '/^# Import common functions.$/d' -i "$test"
+		fi
+
+		# Replace the "status=1" lines that don't have the usual
+		# "failure is the default" message if there's no other code
+		# between _begin_fstest and status=1.
+		if grep -q '^status=1$' "$test"; then
+			awk '
+BEGIN {
+	saw_groupinfo = 0;
+}
+{
+	if ($0 ~ /^_begin_fstest/) {
+		saw_groupinfo = 1;
+		printf("%s\n", $0);
+	} else if ($0 ~ /^status=1$/) {
+		if (saw_groupinfo == 0) {
+			printf("%s\n", $0);
+		}
+	} else if ($0 == "") {
+		printf("\n");
+	} else {
+		saw_groupinfo = 0;
+		printf("%s\n", $0);
+	}
+}
+' < "$test" > "$test.new"
+			cat "$test.new" > "$test"
+			rm -f "$test.new"
+		fi
+
+		# Get rid of _cleanup functions that match the standard one.
+		# Thanks to Eric Biggers for providing this.
+		sed -z -E \
+			-e 's/(#[^#\n]*\n)*_cleanup\(\)\n\{\n(\s+cd \/\n)?\s+rm -r?f "?\$tmp"?\.\*\n\}\n\n?//' \
+			-e 's/(#[^#\n]*\n)*_cleanup\(\)\n\{\n(\s+cd \/\n)?\s+rm -fr "?\$tmp"?\.\*\n\}\n\n?//' \
+			-i "$test"
+
+		# Collapse sequences of blank lines to a single blank line.
+		awk '
+BEGIN {
+	saw_blank = 0;
+}
+{
+	if ($0 ~ /^$/) {
+		if (saw_blank == 0) {
+			printf("\n");
+			saw_blank = 1;
+		}
+	} else {
+		printf("%s\n", $0);
+		saw_blank = 0;
+	}
+}
+' < "$test" > "$test.new"
+		cat "$test.new" > "$test"
+		rm -f "$test.new"
+	done
+}
+
+curr_dir="$PWD"
+for tdir in "$@"; do
+	cd "tests/$tdir"
+	obliterate_group_file
+	cd "$curr_dir"
+done
#5 lore raw

PATCH v3 5/13 fstests: clean up open-coded golden output

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Fix the handful of tests that open-coded 'QA output created by XXX'.

---
 tests/btrfs/006       |    2 +-
 tests/btrfs/006.out   |    2 +-
 tests/btrfs/012       |    2 +-
 tests/btrfs/012.out   |    2 +-
 tests/generic/184     |    2 +-
 tests/generic/184.out |    2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
tests/btrfs/006 +1 -1
index 67f1fcd8..8168992f 100755
@@ -9,7 +9,7 @@
 #
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
-echo "== QA output created by $seq"
+echo "QA output created by $seq"
 
 here=`pwd`
 tmp=/tmp/$$
tests/btrfs/006.out +1 -1
index a9769721..b7f29f96 100644
@@ -1,4 +1,4 @@
-== QA output created by 006
+QA output created by 006
 == Set filesystem label to TestLabel.006
 == Get filesystem label
 TestLabel.006
tests/btrfs/012 +1 -1
index 2d4cece5..0feca7d9 100755
@@ -15,7 +15,7 @@
 #
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
-echo "== QA output created by $seq"
+echo "QA output created by $seq"
 
 here=`pwd`
 tmp=/tmp/$$
tests/btrfs/012.out +1 -1
index 2a41e7e4..7aa5ae94 100644
@@ -1 +1 @@
-== QA output created by 012
+QA output created by 012
tests/generic/184 +1 -1
index c80d5967..e9169244 100755
@@ -8,7 +8,7 @@
 #
 seq=`basename $0`
 seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq - silence is golden"
+echo "QA output created by $seq"
 
 here=`pwd`
 tmp=/tmp/$$
tests/generic/184.out +1 -1
index 2d19691d..4c300543 100644
@@ -1 +1 @@
-QA output created by 184 - silence is golden
+QA output created by 184
#6 lore raw

PATCH v3 6/13 fstests: move test group info to test files

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Refactor every test in the entire test suite to use the new boilerplate functions. This also migrates all the test group information into the test files. This patch has been autogenerated via the command:

./tools/convert-group btrfs ceph cifs ext4 f2fs generic nfs ocfs2 overlay perf shared udf xfs

NOTE: This patch submission only contains diffs of the first seven btrfs tests because vger rejects 1.5MB patches. The full conversion is in the git branch linked from the cover letter.

---
 tests/btrfs/001 |   19 +++----------------
 tests/btrfs/002 |   19 +++----------------
 tests/btrfs/003 |   15 ++++-----------
 tests/btrfs/004 |   15 ++++-----------
 tests/btrfs/005 |   21 +++------------------
 tests/btrfs/006 |   21 +++------------------
 6 files changed, 20 insertions(+), 90 deletions(-)
tests/btrfs/001 +3 -16
index fb051e8a..000aeb34 100755
@@ -6,23 +6,10 @@
 #
 # Test btrfs's subvolume and snapshot support
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. ./common/preamble
+_begin_fstest auto quick subvol snapshot
 
-here=`pwd`
-tmp=/tmp/$$
-status=1	# failure is the default!
-
-_cleanup()
-{
-    rm -f $tmp.*
-}
-
-trap "_cleanup ; exit \$status" 0 1 2 3 15
-
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter
 . ./common/filter.btrfs
 
tests/btrfs/002 +3 -16
index 66775562..58f0cdcd 100755
@@ -6,23 +6,10 @@
 #
 # Extented btrfs snapshot test cases
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. ./common/preamble
+_begin_fstest auto snapshot
 
-here=`pwd`
-tmp=/tmp/$$
-status=1	# failure is the default!
-
-_cleanup()
-{
-    rm -f $tmp.*
-}
-
-trap "_cleanup ; exit \$status" 0 1 2 3 15
-
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter
 
 _supported_fs btrfs
tests/btrfs/003 +4 -11
index fbb313fb..d241ec6e 100755
@@ -6,16 +6,11 @@
 #
 # btrfs vol tests
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. ./common/preamble
+_begin_fstest auto replace volume balance
 
-here=`pwd`
-tmp=/tmp/$$
-status=1	# failure is the default!
 dev_removed=0
 removed_dev_htl=""
-trap "_cleanup; exit \$status" 0 1 2 3 15
 
 # Check if all scratch dev pools are deletable
 deletable_scratch_dev_pool()
@@ -32,6 +27,7 @@ deletable_scratch_dev_pool()
 	return 0
 }
 
+# Override the default cleanup function.
 _cleanup()
 {
     cd /
@@ -42,8 +38,7 @@ _cleanup()
     fi
 }
 
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter
 
 _supported_fs btrfs
@@ -51,8 +46,6 @@ _require_scratch
 _require_scratch_dev_pool 4
 _require_command "$WIPEFS_PROG" wipefs
 
-rm -f $seqres.full
-
 # Test cases related to raid in btrfs
 _test_raid0()
 {
tests/btrfs/004 +4 -11
index 0458d2b6..4e767a2f 100755
@@ -9,25 +9,20 @@
 # run filefrag to get the extent mapping and follow the backrefs.
 # We check to end up back at the original file with the correct offset.
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. ./common/preamble
+_begin_fstest auto rw metadata
 
-here=`pwd`
-tmp=/tmp/$$
-status=1
 noise_pid=0
 
+# Override the default cleanup function.
 _cleanup()
 {
 	rm $tmp.running
 	wait
 	rm -f $tmp.*
 }
-trap "_cleanup; exit \$status" 0 1 2 3 15
 
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter
 
 # real QA test starts here
@@ -38,8 +33,6 @@ _require_btrfs_command inspect-internal logical-resolve
 _require_btrfs_command inspect-internal inode-resolve
 _require_command "$FILEFRAG_PROG" filefrag
 
-rm -f $seqres.full
-
 FILEFRAG_FILTER='
 	if (/blocks? of (\d+) bytes/) {
 		$blocksize = $1;
tests/btrfs/005 +3 -18
index ff20a638..878a8c7c 100755
@@ -6,23 +6,11 @@
 #
 # Btrfs Online defragmentation tests
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
-here="`pwd`"
-tmp=/tmp/$$
+. ./common/preamble
+_begin_fstest auto defrag
 cnt=119
 filesize=48000
 
-status=1	# failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-}
-
 _create_file()
 {
 	if [ $1 -ne 2 ]; then
@@ -111,8 +99,7 @@ _rundefrag()
 	_check_scratch_fs
 }
 
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter
 . ./common/defrag
 
@@ -120,8 +107,6 @@ _rundefrag()
 _supported_fs btrfs
 _require_scratch
 
-rm -f $seqres.full
-
 _scratch_mkfs >/dev/null 2>&1
 _scratch_mount
 _require_defrag
tests/btrfs/006 +3 -18
index 8168992f..fd0f89e2 100755
@@ -7,23 +7,10 @@
 # run basic btrfs information commands in various ways
 # sanity tests: filesystem show, label, sync, and device stats
 #
-seq=`basename $0`
-seqres=$RESULT_DIR/$seq
-echo "QA output created by $seq"
+. ./common/preamble
+_begin_fstest auto quick volume
 
-here=`pwd`
-tmp=/tmp/$$
-status=1	# failure is the default!
-trap "_cleanup; exit \$status" 0 1 2 3 15
-
-_cleanup()
-{
-    cd /
-    rm -f $tmp.*
-}
-
-# get standard environment, filters and checks
-. ./common/rc
+# Import common functions.
 . ./common/filter.btrfs
 
 # real QA test starts here
@@ -33,8 +20,6 @@ _supported_fs btrfs
 _require_scratch
 _require_scratch_dev_pool
 
-rm -f $seqres.full
-
 FIRST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $1}'`
 LAST_POOL_DEV=`echo $SCRATCH_DEV_POOL | awk '{print $NF}'`
 TOTAL_DEVS=`echo $SCRATCH_DEV_POOL | wc -w`
#7 lore raw

PATCH v3 7/13 fstests: automatically generate group files

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Now that we've moved the group membership details into the test case files themselves, automatically generate the group files during build. The autogenerated files are named "group.list" instead of "group" to avoid conflicts between generated and (stale) SCM files as everyone rebases.

---
 .gitignore             |    3 +++
 common/preamble        |    8 ++++++++
 include/buildgrouplist |    8 ++++++++
 tests/Makefile         |    4 ++++
 tests/btrfs/Makefile   |    6 +++++-
 tests/ceph/Makefile    |    6 +++++-
 tests/cifs/Makefile    |    6 +++++-
 tests/ext4/Makefile    |    6 +++++-
 tests/f2fs/Makefile    |    6 +++++-
 tests/generic/Makefile |    6 +++++-
 tests/nfs/Makefile     |    6 +++++-
 tests/ocfs2/Makefile   |    6 +++++-
 tests/overlay/Makefile |    6 +++++-
 tests/perf/Makefile    |    6 +++++-
 tests/shared/Makefile  |    6 +++++-
 tests/udf/Makefile     |    6 +++++-
 tests/xfs/Makefile     |    6 +++++-
 tools/mkgroupfile      |   42 ++++++++++++++++++++++++++++++++++++++++++
 18 files changed, 130 insertions(+), 13 deletions(-)
 create mode 100644 include/buildgrouplist
 create mode 100755 tools/mkgroupfile
.gitignore +3 -0
index d3194e76..2d72b064 100644
@@ -11,6 +11,9 @@ tags
 /local.config
 /results
 
+# autogenerated group files
+/tests/*/group.list
+
 # autoconf generated files
 /aclocal.m4
 /autom4te.cache
common/preamble +8 -0
index fba766de..66b0ed05 100644
@@ -38,6 +38,14 @@ _begin_fstest()
 	fi
 
 	seq=`basename $0`
+
+	# If we're only running the test to generate a group.list file,
+	# spit out the group data and exit.
+	if [ -n "$GENERATE_GROUPS" ]; then
+		echo "$seq $@"
+		exit 0
+	fi
+
 	seqres=$RESULT_DIR/$seq
 	echo "QA output created by $seq"
 
include/buildgrouplist new file +8 -0
new file mode 100644
index 00000000..d898efa3
@@ -0,0 +1,8 @@
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Oracle, Inc.  All Rights Reserved.
+#
+.PHONY: group.list
+
+group.list:
+	@echo " [GROUP] $$PWD/$@"
+	$(Q)$(TOPDIR)/tools/mkgroupfile $@
tests/Makefile +4 -0
index 8ce8f209..5c8f0b10 100644
@@ -7,6 +7,10 @@ include $(TOPDIR)/include/builddefs
 
 TESTS_SUBDIRS = $(sort $(dir $(wildcard $(CURDIR)/[[:lower:]]*/)))
 
+SUBDIRS = $(wildcard [[:lower:]]*)
+
+default: $(SUBDIRS)
+
 include $(BUILDRULES)
 
 install: $(addsuffix -install,$(TESTS_SUBDIRS))
tests/btrfs/Makefile +5 -1
index 2d936421..1b72a1a1 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 BTRFS_DIR = btrfs
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(BTRFS_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/ceph/Makefile +5 -1
index 55e35d77..2761e1e9 100644
@@ -2,16 +2,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 CEPH_DIR = ceph
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(CEPH_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/cifs/Makefile +5 -1
index 0c5cf3be..62c48935 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 CIFS_DIR = cifs
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(CIFS_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/ext4/Makefile +5 -1
index beb1541f..a2a0d561 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 EXT4_DIR = ext4
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(EXT4_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/f2fs/Makefile +5 -1
index d13bca3f..9d1ed3c6 100644
@@ -5,16 +5,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 F2FS_DIR = f2fs
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(F2FS_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/generic/Makefile +5 -1
index 3878d05c..b464b22b 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 GENERIC_DIR = generic
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(GENERIC_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/nfs/Makefile +5 -1
index 754f2b25..128d2a3a 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 NFS_DIR = nfs
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(NFS_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/ocfs2/Makefile +5 -1
index e1337908..260ad31b 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 OCFS2_DIR = ocfs2
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(OCFS2_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/overlay/Makefile +5 -1
index b07f8925..de3203c2 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 TEST_DIR = overlay
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(TEST_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/perf/Makefile +5 -1
index 620f1dbf..0c74ba39 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 PERF_DIR = perf
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(PERF_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/shared/Makefile +5 -1
index 8a832782..f3128714 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 SHARED_DIR = shared
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(SHARED_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/udf/Makefile +5 -1
index c9c9f1bd..ed4434f0 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 UDF_DIR = udf
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(UDF_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tests/xfs/Makefile +5 -1
index d64800ea..5f413e67 100644
@@ -4,16 +4,20 @@
 
 TOPDIR = ../..
 include $(TOPDIR)/include/builddefs
+include $(TOPDIR)/include/buildgrouplist
 
 XFS_DIR = xfs
 TARGET_DIR = $(PKG_LIB_DIR)/$(TESTS_DIR)/$(XFS_DIR)
+DIRT = group.list
+
+default: $(DIRT)
 
 include $(BUILDRULES)
 
 install:
 	$(INSTALL) -m 755 -d $(TARGET_DIR)
 	$(INSTALL) -m 755 $(TESTS) $(TARGET_DIR)
-	$(INSTALL) -m 644 group $(TARGET_DIR)
+	$(INSTALL) -m 644 group.list $(TARGET_DIR)
 	$(INSTALL) -m 644 $(OUTFILES) $(TARGET_DIR)
 
 # Nothing.
tools/mkgroupfile new file +42 -0

42 lines not on this page · raw message

#8 lore raw

PATCH v3 8/13 fstests: convert nextid to use automatic group generation

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Convert the nextid script to use the automatic group file generation to figure out the next available test id.

---
 tools/nextid |    1 -
 tools/nextid |   31 +++++++++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 1 deletion(-)
 delete mode 120000 tools/nextid
 create mode 100755 tools/nextid
tools/nextid deleted +0 -1
deleted file mode 120000
index 5c31d602..00000000
@@ -1 +0,0 @@
-sort-group
\ No newline at end of file
tools/nextid new file +31 -0
new file mode 100755
index 00000000..9507de29
@@ -0,0 +1,31 @@
+#!/bin/bash
+
+# Compute the next available test id in a given test directory.
+
+if [ $# != 1 ] || [ "$1" = "--help" ] || [ ! -d "tests/$1/" ]; then
+	echo "Usage: $0 test_dir"
+	exit 1
+fi
+
+. ./common/test_names
+
+i=0
+eof=1
+
+while read found other_junk;
+do
+	i=$((i+1))
+	id=`printf "%03d" $i`
+	if [ "$id" != "$found" ]; then
+		eof=0
+		break
+	fi
+done < <(cd "tests/$1/" ; ../../tools/mkgroupfile | \
+	 grep "^$VALID_TEST_NAME\>" | tr - ' ')
+
+if [ $eof -eq 1 ]; then
+   i=$((i+1))
+   id=`printf "%03d" $i`
+fi
+
+echo "$1/$id"
#9 lore raw

PATCH v3 9/13 fstests: adapt the new test script to our new group tagging scheme

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Now that we autogenerate group files, adapt the new test creation script to use autogenerated group files and to set the group data in the new test.

---
 new |  179 ++++++++++++++++++++-----------------------------------------------
 1 file changed, 54 insertions(+), 125 deletions(-)
new +54 -125
index 531fd123..07144399 100755
@@ -9,7 +9,8 @@
 iam=new
 . ./common/test_names
 
-trap "rm -f /tmp/$$.; exit" 0 1 2 3 15
+tmpfile="/tmp/$$."
+trap "rm -f $tmpfile; exit" 0 1 2 3 15
 
 _cleanup()
 {
@@ -26,71 +27,18 @@ usage()
 
 [ $# -eq 0 ] && usage
 tdir=tests/$1
-shift
-
-if [ ! -f $tdir/group ]
-then
-    echo "Creating the $tdir/group index ..."
-    cat <<'End-of-File' >$tdir/group
-# QA groups control
-#
-# define groups and default group owners
-# do not start group name with a digit
-#
-
-# catch-all
-#
-other		some-user-login
-
-# test-group association ... one line per test
-#
-End-of-File
-fi
-
-if [ ! -w $tdir/group ]
-then
-    chmod u+w $tdir/group
-    echo "Warning: making the index file \"$tdir/group\" writeable"
-fi
-
-if make
-then
-    :
-else
-    echo "Warning: make failed -- some tests may be missing"
-fi
 
 i=0
 line=0
 eof=1
-[ -f "$tdir/group" ] || usage
+[ -d "$tdir/" ] || usage
 
 export AWK_PROG="$(type -P awk)"
 [ "$AWK_PROG" = "" ] && { echo "awk not found"; exit; }
 
-for found in `cat $tdir/group | tr - ' ' | $AWK_PROG '{ print $1 }'`
-do
-    line=$((line+1))
-    if [ -z "$found" ] || [ "$found" == "#" ]; then
-        continue
-    elif ! echo "$found" | grep -q "^$VALID_TEST_NAME$"; then
-        # this one is for tests not named by a number
-        continue
-    fi
-    i=$((i+1))
-    id=`printf "%03d" $i`
-    if [ "$id" != "$found" ];then
-	eof=0
-	break
-    fi
-done
-if [ $eof -eq 1 ]; then
-   line=$((line+1))
-   i=$((i+1))
-   id=`printf "%03d" $i`
-fi
-
+id="$(basename "$(./tools/nextid "$1")")"
 echo "Next test id is $id"
+shift
 
 read -p "Append a name to the ID? Test name will be $id-\$name. y,[n]: " -r
 if [[ $REPLY = [Yy] ]]; then
@@ -113,24 +61,9 @@ if [[ $REPLY = [Yy] ]]; then
 		fi
 	done
 
-	# now find where to insert this name
-	eof=1
-	for found in `tail -n +$line $tdir/group | $AWK_PROG '{ print $1 }'`; do
-		found_id=$(echo "$found" | cut -d "-" -f 1 - )
-		line=$((line+1))
-		if [ -z "$found" ] || [ "$found" == "#" ]; then
-			continue
-		elif [ $found_id -gt $id ]; then
-			eof=0
-			break
-		fi
-	done
-	if [ $eof -eq 0 ]; then
-		# If place wasn't found, let $line be the end of the file
-		line=$((line-1))
-	fi
 	id="$id-$name"
 fi
+
 echo "Creating test file '$id'"
 
 if [ -f $tdir/$id ]
@@ -140,6 +73,53 @@ then
     exit 1
 fi
 
+if [ $# -eq 0 ]
+then
+
+    while true
+    do
+	echo -n "Add to group(s) [other] (separate by space, ? for list): "
+	read ans
+	[ -z "$ans" ] && ans=other
+	if [ "X$ans" = "X?" ]
+	then
+	    for d in $SRC_GROUPS; do
+		(cd "tests/$d/" ; ../../tools/mkgroupfile "$tmpfile")
+		l=$(sed -n < "$tmpfile" \
+		    -e 's/#.*//' \
+		    -e 's/$/ /' \
+		    -e 's;\(^[0-9][0-9][0-9]\)\(.*$\);\2;p')
+		grpl="$grpl $l"
+	    done
+	    lst=`for word in $grpl; do echo $word; done | sort| uniq `
+	    echo $lst
+	else
+	    # only allow lower cases, spaces, digits and underscore in group
+	    inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
+	    if [ "$inval" != "" ]; then
+		echo "Invalid characters in group(s): $inval"
+		echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
+		continue
+	    else
+		# remove redundant spaces/tabs
+		ans=`echo "$ans" | sed 's/\s\+/ /g'`
+		break
+	    fi
+	fi
+    done
+else
+    # expert mode, groups are on the command line
+    #
+    (cd "$tdir" ; ../../tools/mkgroupfile "$tmpfile")
+    for g in $*
+    do
+	if ! grep -q "[[:space:]]$g" "$tmpfile"; then
+	    echo "Warning: group \"$g\" not defined in $tdir tests"
+	fi
+    done
+    ans="$*"
+fi
+
 echo -n "Creating skeletal script for you to edit ..."
 
 year=`date +%Y`
@@ -154,7 +134,7 @@ cat <<End-of-File >$tdir/$id
 # what am I here for?
 #
 . ./common/preamble
-_begin_fstest group list here
+_begin_fstest $ans
 
 # Override the default cleanup function.
 # _cleanup()
@@ -196,56 +176,5 @@ QA output created by $id
 Silence is golden
 End-of-File
 
-if [ $# -eq 0 ]
-then
-
-    while true
-    do
-	echo -n "Add to group(s) [other] (separate by space, ? for list): "
-	read ans
-	[ -z "$ans" ] && ans=other
-	if [ "X$ans" = "X?" ]
-	then
-	    for d in $SRC_GROUPS; do
-		l=$(sed -n < tests/$d/group \
-		    -e 's/#.*//' \
-		    -e 's/$/ /' \
-		    -e 's;\(^[0-9][0-9][0-9]\)\(.*$\);\2;p')
-		grpl="$grpl $l"
-	    done
-	    lst=`for word in $grpl; do echo $word; done | sort| uniq `
-	    echo $lst
-	else
-	    # only allow lower cases, spaces, digits and underscore in group
-	    inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
-	    if [ "$inval" != "" ]; then
-		echo "Invalid characters in group(s): $inval"
-		echo "Only lower cases, digits and underscore are allowed in groups, separated by space"
-		continue
-	    else
-		# remove redundant spaces/tabs
-		ans=`echo "$ans" | sed 's/\s\+/ /g'`
-		break
-	    fi
-	fi
-    done
-else
-    # expert mode, groups are on the command line
-    #
-    for g in $*
-    do
-	if ! grep -q "[[:space:]]$g" "$tdir/group"; then
-	    echo "Warning: group \"$g\" not defined in $tdir/group"
-	fi
-    done
-    ans="$*"
-fi
-
-echo -n "Adding $id to group index ..."
-head -n $(($line-1)) $tdir/group > /tmp/$$.group
-echo "$id $ans" >> /tmp/$$.group
-tail -n +$((line)) $tdir/group >> /tmp/$$.group
-mv /tmp/$$.group $tdir/group
 echo " done."
-
 exit 0
#10 lore raw

PATCH v3 10/13 check: use generated group files

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Convert the ./check script to use the automatically generated group list membership files, as the transition is now complete.

---
 check |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
check +3 -3
index ba192042..3dab7630 100755
@@ -124,9 +124,9 @@ get_sub_group_list()
 	local d=$1
 	local grp=$2
 
-	test -s "$SRC_DIR/$d/group" || return 1
+	test -s "$SRC_DIR/$d/group.list" || return 1
 
-	local grpl=$(sed -n < $SRC_DIR/$d/group \
+	local grpl=$(sed -n < $SRC_DIR/$d/group.list \
 		-e 's/#.*//' \
 		-e 's/$/ /' \
 		-e "s;^\($VALID_TEST_NAME\).* $grp .*;$SRC_DIR/$d/\1;p")
@@ -384,7 +384,7 @@ if $have_test_arg; then
 				test_dir=`dirname $t`
 				test_dir=${test_dir#$SRC_DIR/*}
 				test_name=`basename $t`
-				group_file=$SRC_DIR/$test_dir/group
+				group_file=$SRC_DIR/$test_dir/group.list
 
 				if egrep -q "^$test_name" $group_file; then
 					# in group file ... OK
#11 lore raw

PATCH v3 11/13 fstests: remove group files

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

From: Darrick J. Wong <[email protected]>

Now that we autogenerate group files, get rid of them in the source tree.

---
 tests/btrfs/group   |  246 --------------------
 tests/ceph/group    |    4 
 tests/cifs/group    |    6 
 tests/ext4/group    |   64 -----
 tests/f2fs/group    |    7 -
 tests/generic/group |  643 ---------------------------------------------------
 tests/nfs/group     |    6 
 tests/ocfs2/group   |    1 
 tests/overlay/group |  100 --------
 tests/perf/group    |    1 
 tests/shared/group  |    8 -
 tests/udf/group     |    6 
 tests/xfs/group     |  534 ------------------------------------------
 13 files changed, 1626 deletions(-)
 delete mode 100644 tests/btrfs/group
 delete mode 100644 tests/ceph/group
 delete mode 100644 tests/cifs/group
 delete mode 100644 tests/ext4/group
 delete mode 100644 tests/f2fs/group
 delete mode 100644 tests/generic/group
 delete mode 100644 tests/nfs/group
 delete mode 100644 tests/ocfs2/group
 delete mode 100644 tests/overlay/group
 delete mode 100644 tests/perf/group
 delete mode 100644 tests/shared/group
 delete mode 100644 tests/udf/group
 delete mode 100644 tests/xfs/group
tests/btrfs/group deleted +0 -246
deleted file mode 100644
index 4fdd4d44..00000000
@@ -1,246 +0,0 @@
-# QA groups control file
-# Defines test groups and nominal group owners
-# - do not start group names with a digit
-# - comment line before each group is "new" description
-#
-001 auto quick subvol snapshot
-002 auto snapshot
-003 auto replace volume balance
-004 auto rw metadata
-005 auto defrag
-006 auto quick volume
-007 auto quick rw metadata send seek
-008 auto quick send
-009 auto quick subvol
-010 auto
-011 auto replace volume
-012 auto convert
-013 auto quick balance
-014 auto balance
-015 auto quick snapshot
-016 auto quick send
-017 auto quick qgroup
-018 auto quick subvol
-019 auto quick send
-020 auto quick replace volume
-021 auto quick balance defrag
-022 auto qgroup limit
-023 auto
-024 auto quick compress
-025 auto quick send clone
-026 auto quick compress prealloc
-027 auto replace volume
-028 auto qgroup balance
-029 auto quick clone
-030 auto quick send
-031 auto quick subvol clone
-032 auto quick remount
-033 auto quick send snapshot
-034 auto quick send
-035 auto quick clone
-036 auto quick send snapshot
-037 auto quick compress
-038 auto quick compress send
-039 auto quick send
-040 auto quick send
-041 auto quick compress
-042 auto quick qgroup limit
-043 auto quick send
-044 auto quick send
-045 auto quick send
-046 auto quick send
-047 auto quick snapshot attr
-048 auto quick
-049 auto quick
-050 auto quick send
-051 auto quick send
-052 auto quick clone
-053 auto quick send
-054 auto quick send
-055 auto quick clone
-056 auto quick clone log
-057 auto quick
-058 auto quick send snapshot
-059 auto quick
-060 auto balance subvol
-061 auto balance scrub
-062 auto balance defrag compress
-063 auto balance remount compress
-064 auto balance replace volume
-065 auto subvol replace volume
-066 auto subvol scrub
-067 auto subvol defrag compress
-068 auto subvol remount compress
-069 auto replace scrub volume
-070 auto replace defrag compress volume
-071 auto replace remount compress volume
-072 auto scrub defrag compress
-073 auto scrub remount compress
-074 auto defrag remount compress
-075 auto quick subvol
-076 auto quick compress
-077 auto quick send snapshot
-078 auto snapshot
-079 auto rw metadata
-080 auto snapshot
-081 auto quick clone
-082 auto quick remount
-083 auto quick send
-084 auto quick send
-085 auto quick metadata subvol
-086 auto quick clone
-087 auto quick send
-088 auto quick metadata
-089 auto quick subvol
-090 auto quick metadata
-091 auto quick qgroup
-092 auto quick send
-093 auto quick clone
-094 auto quick send
-095 auto quick metadata log
-096 auto quick clone
-097 auto quick send clone
-098 auto quick metadata clone log
-099 auto quick qgroup limit
-100 auto replace volume eio
-101 auto replace volume eio
-102 auto quick metadata enospc balance
-103 auto quick clone compress
-104 auto qgroup
-105 auto quick send
-106 auto quick clone compress
-107 auto quick prealloc
-108 auto quick send clone punch
-109 auto quick send clone compress
-110 auto quick send
-111 auto quick send
-112 auto quick clone
-113 auto quick compress clone
-114 auto qgroup
-115 auto qgroup
-116 auto quick metadata
-117 auto quick send clone
-118 auto quick snapshot metadata log
-119 auto quick snapshot metadata qgroup log
-120 auto quick snapshot metadata log
-121 auto quick snapshot qgroup
-122 auto quick snapshot qgroup
-123 auto quick qgroup balance
-124 auto replace volume balance
-125 replace volume balance
-126 auto quick qgroup limit
-127 auto quick send
-128 auto quick send
-129 auto quick send
-130 auto quick clone send
-131 auto quick
-132 auto enospc
-133 auto quick send
-134 auto quick send
-135 auto quick send
-136 auto convert
-137 auto quick send
-138 auto compress
-139 auto qgroup limit
-140 auto quick
-141 auto quick
-142 auto quick
-143 auto quick
-144 auto quick send
-145 auto quick send
-146 auto quick eio
-147 auto quick send
-148 auto quick rw
-149 auto quick send compress
-150 auto quick dangerous
-151 auto quick volume
-152 auto quick metadata qgroup send
-153 auto quick qgroup limit
-154 auto quick
-155 auto quick send
-156 auto quick trim balance
-157 auto quick raid
-158 auto quick raid scrub
-159 auto quick punch log
-160 auto quick eio
-161 auto quick volume seed
-162 auto quick volume seed
-163 auto quick volume seed
-164 auto quick volume
-165 auto quick subvol
-166 auto quick qgroup
-167 auto quick replace volume
-168 auto quick send
-169 auto quick send
-170 auto quick snapshot
-171 auto quick qgroup
-172 auto quick log replay
-173 auto quick swap
-174 auto quick swap
-175 auto quick swap volume
-176 auto quick swap volume
-177 auto quick swap balance
-178 auto quick send
-179 auto qgroup dangerous
-180 auto quick qgroup limit
-181 auto quick balance
-182 auto quick balance
-183 auto quick clone compress punch
-184 auto quick volume
-185 volume
-186 auto quick send volume
-187 auto send dedupe clone balance
-188 auto quick send prealloc punch
-189 auto quick send clone
-190 auto quick replay balance qgroup
-191 auto quick send dedupe
-192 auto replay snapshot stress
-193 auto quick qgroup enospc limit
-194 auto volume
-195 auto volume balance
-196 auto metadata log volume
-197 auto quick volume
-198 quick volume
-199 auto quick trim
-200 auto quick send clone
-201 auto quick punch log
-202 auto quick subvol snapshot
-203 auto quick send clone
-204 auto quick punch
-205 auto quick clone compress
-206 auto quick log replay
-207 auto rw raid
-208 auto quick subvol
-209 auto quick log
-210 auto quick qgroup snapshot
-211 auto quick log prealloc
-212 auto balance dangerous
-213 auto balance dangerous
-214 auto quick send snapshot
-215 auto quick
-216 auto quick seed
-217 auto quick trim dangerous
-218 auto quick volume
-219 auto quick volume
-220 auto quick
-221 auto quick send
-222 auto quick send
-223 auto quick replace trim
-224 auto quick qgroup
-225 auto quick volume seed
-226 auto quick rw snapshot clone prealloc punch
-227 auto quick send
-228 auto quick volume
-229 auto quick send clone
-230 auto quick qgroup limit
-231 auto quick clone log replay
-232 auto quick qgroup limit
-233 auto quick subvolume
-234 auto quick compress rw
-235 auto quick send
-236 auto quick log
-237 auto quick zone balance
-238 auto quick seed trim
-239 auto quick log
-240 auto quick prealloc log
-241 auto quick send
tests/ceph/group deleted +0 -4
deleted file mode 100644
index 47903d21..00000000
@@ -1,4 +0,0 @@
-001 auto quick copy
-002 auto quick copy
-003 auto quick copy
-004 auto quick quota
tests/cifs/group deleted +0 -6
deleted file mode 100644
index 6d07b1c4..00000000
@@ -1,6 +0,0 @@
-# QA groups control file
-# Defines test groups and nominal group owners
-# - do not start group names with a digit
-# - comment line before each group is "new" description
-#
-001 auto quick
tests/ext4/group deleted +0 -64

64 lines not on this page · raw message

tests/f2fs/group deleted +0 -7
deleted file mode 100644
index 7cd42fe4..00000000
@@ -1,7 +0,0 @@
-# QA groups control file
-# Defines test groups and nominal group owners
-# - do not start group names with a digit
-# - comment line before each group is "new" description
-#
-001 auto quick rw
-002 auto quick rw encrypt compress
tests/generic/group deleted +0 -643

643 lines not on this page · raw message

tests/nfs/group deleted +0 -6
deleted file mode 100644
index 2619eaee..00000000
@@ -1,6 +0,0 @@
-# QA groups control file
-# Defines test groups and nominal group owners
-# - do not start group names with a digit
-# - comment line before each group is "new" description
-#
-001 auto quick nfs4_acl acl
tests/ocfs2/group deleted +0 -1
deleted file mode 100644
index 28e68072..00000000
@@ -1 +0,0 @@
-001 auto quick clone
tests/overlay/group deleted +0 -100

100 lines not on this page · raw message

tests/perf/group deleted +0 -1
deleted file mode 100644
index d3ed4349..00000000
@@ -1 +0,0 @@
-001 auto
tests/shared/group deleted +0 -8
deleted file mode 100644
index a8b926d8..00000000
@@ -1,8 +0,0 @@
-# QA groups control file
-# Defines test groups and nominal group owners
-# - do not start group names with a digit
-# - comment line before each group is "new" description
-#
-002 auto metadata quick log
-032 mkfs auto quick
-298 auto trim
tests/udf/group deleted +0 -6
deleted file mode 100644
index 6680da44..00000000
@@ -1,6 +0,0 @@
-# QA groups control file
-# Defines test groups and nominal group owners
-# - do not start group names with a digit
-# - comment line before each group is "new" description
-#
-102 udf
tests/xfs/group deleted +0 -534

534 lines not on this page · raw message

#12 lore raw

PATCH v3 12/13 fstests: remove test group management code

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Remove all the code that manages group files, since we now generate them at build time.

---
 tools/mvtest     |   15 -------
 tools/sort-group |  112 ------------------------------------------------------
 2 files changed, 127 deletions(-)
 delete mode 100755 tools/sort-group
tools/mvtest +0 -15
index 572ae14e..5088b45f 100755
@@ -29,27 +29,12 @@ test ! -e "tests/${dest}" || die "Test \"${src}\" already exists."
 sid="$(basename "${src}")"
 did="$(basename "${dest}")"
 
-sgroup="$(basename "$(dirname "tests/${src}")")"
-dgroup="$(basename "$(dirname "tests/${dest}")")"
-
-sgroupfile="tests/${sgroup}/group"
-dgroupfile="tests/${dgroup}/group"
-
 git mv "tests/${src}" "tests/${dest}"
 git mv "tests/${src}.out" "tests/${dest}.out"
 sed -e "s/^# FS[[:space:]]*QA.*Test.*[0-9]\+$/# FS QA Test No. ${did}/g" -i "tests/${dest}"
 sed -e "s/^QA output created by ${sid}$/QA output created by ${did}/g" -i "tests/${dest}.out"
 sed -e "s/test-${sid}/test-${did}/g" -i "tests/${dest}.out"
 
-grpline="$(grep "^${sid} " "${sgroupfile}")"
-newgrpline="$(echo "${grpline}" | sed -e "s/^${sid} /${did} /g")"
-
-sed -e "/^${sid} .*$/d" -i "${sgroupfile}"
-cp "${dgroupfile}" "${dgroupfile}.new"
-append "${dgroupfile}.new" "${newgrpline}"
-"${dir}/sort-group" "${dgroupfile}.new"
-mv "${dgroupfile}.new" "${dgroupfile}"
-
 echo "Moved \"${src}\" to \"${dest}\"."
 
 exit 0
tools/sort-group deleted +0 -112

112 lines not on this page · raw message

#13 lore raw

PATCH v3 13/13 misc: update documentation to reflect auto-generated group files

In reply to Darrick J. Wong

From: Darrick J. Wong <[email protected]>

Update the documentation to outline the new requirements for test files so that we can generate group files during build.

---
 README |   23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)
README +20 -3
index 048491a6..18f7a6bc 100644
@@ -140,7 +140,8 @@ Running tests:
     - ./check '*/001' '*/002' '*/003'
     - ./check '*/06?'
     - Groups of tests maybe ran by: ./check -g [group(s)]
-      See the 'group' file for details on groups
+      See the tests/*/group.list files after building xfstests to learn about
+      each test's group memberships.
     - If you want to run all tests regardless of what group they are in
       (including dangerous tests), use the "all" group: ./check -g all
     - To randomize test order: ./check -r [test(s)]
@@ -174,8 +175,8 @@ Test script environment:
 
     When developing a new test script keep the following things in
     mind.  All of the environment variables and shell procedures are
-    available to the script once the "common/rc" file has been
-    sourced.
+    available to the script once the "common/preamble" file has been
+    sourced and the "_begin_fstest" function has been called.
 
      1. The tests are run from an arbitrary directory.  If you want to
 	do operations on an XFS filesystem (good idea, eh?), then do
@@ -249,6 +250,22 @@ Test script environment:
 	  in the ./new script. It can contain only alphanumeric characters
 	  and dash. Note the "NNN-" part is added automatically.
 
+     6. Test group membership: Each test can be associated with any number
+	of groups for convenient selection of subsets of tests.  Group names
+	can be any sequence of non-whitespace characters.  Test authors
+	associate a test with groups by passing the names of those groups as
+	arguments to the _begin_fstest function.  For example, the code:
+
+	_begin_fstest auto quick subvol snapshot
+
+	associates the current test with the "auto", "quick", "subvol", and
+	"snapshot" groups.  It is not necessary to specify the "all" group
+	in the list because that group is computed at run time.
+
+	The build process scans test files for _begin_fstest invocations and
+	compiles the group list from that information.  In other words, test
+	files must call _begin_fstest or they will not be run.
+
 Verified output:
 
     Each test script has a name, e.g. 007, and an associated