Skip to contentSkip to conversation

fstests: document all test groups

PATCH New Darrick J. Wong 1 participant 9 messages Sep 17, 2021

lore
Share & tools
lore
#0 lore raw

v4 cover fstests: document all test groups

Hi all,

I've noticed that fstests doesn't document what the test groups mean. I attempted to document what each group seems to symbolize, to reduce the amount of confusion for new contributors. While doing so, I noticed that there were a handful of tests that aren't in the right group. The first three patches dix that problem. The next test adds a build-time check to ensure that all groups are listed in the documentation file so that we don't lose track of things. The last patch updates ./new to use the documentation file instead of having to build group.list files.

v2: fix the 'subvolume' group tests, tweak some of the wordings of the
group description file, add missing license declarations, remove the one-off overlay group
v2.1: move the group name documentation checks into the preamble code so
we don't have to have a second script
v3: cleanup cleanups to mkgroupfile and don't allow new 'other' group
tests
v4: split the ./new script cleanups into a separate series; add review
tags; no other changes

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=document-test-groups

---
 common/preamble     |   21 ++++++++
 doc/group-names.txt |  135 +++++++++++++++++++++++++++++++++++++++++++++++++++
 new                 |   24 ++++-----
 tests/btrfs/233     |    2 -
 tests/btrfs/245     |    2 -
 tests/ceph/001      |    2 -
 tests/ceph/002      |    2 -
 tests/ceph/003      |    2 -
 tests/generic/631   |    2 -
 tests/xfs/491       |    2 -
 tests/xfs/492       |    2 -
 tests/xfs/493       |    2 -
 tests/xfs/519       |    2 -
 tests/xfs/520       |    2 -
 tests/xfs/535       |    2 -
 tests/xfs/536       |    2 -
 tools/mkgroupfile   |   37 +++++++++++---
 tools/mvtest        |    5 ++
 tools/nextid        |    4 +-
 19 files changed, 215 insertions(+), 37 deletions(-)
 create mode 100644 doc/group-names.txt
#1 lore raw

PATCH v4 1/8 ceph: re-tag copy_file_range as being in the copy_range group

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

copy_range is the group name for copy_file_range tests, so reclassify these tests.

---
 tests/ceph/001 |    2 +-
 tests/ceph/002 |    2 +-
 tests/ceph/003 |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/ceph/001 +1 -1
index aca77168..c00de308 100755
@@ -11,7 +11,7 @@
 # file and 3) the middle of the dst file.
 #
 . ./common/preamble
-_begin_fstest auto quick copy
+_begin_fstest auto quick copy_range
 
 # get standard environment
 . common/filter
tests/ceph/002 +1 -1
index 428f23a9..9bc728fd 100755
@@ -20,7 +20,7 @@
 #   linux kernel: 78beb0ff2fec ("ceph: use copy-from2 op in copy_file_range")
 #
 . ./common/preamble
-_begin_fstest auto quick copy
+_begin_fstest auto quick copy_range
 
 # get standard environment
 . common/filter
tests/ceph/003 +1 -1
index 9f8c6068..faedb48c 100755
@@ -7,7 +7,7 @@
 # Test copy_file_range with infile = outfile
 #
 . ./common/preamble
-_begin_fstest auto quick copy
+_begin_fstest auto quick copy_range
 
 # get standard environment
 . common/filter
#2 lore raw

PATCH v4 2/8 xfs: move reflink tests into the clone group

In reply to Darrick J. Wong

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

"clone" is the group for tests that exercise FICLONERANGE, so move these tests.

---
 tests/xfs/519 |    2 +-
 tests/xfs/520 |    2 +-
 tests/xfs/535 |    2 +-
 tests/xfs/536 |    2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)
tests/xfs/519 +1 -1
index 675ec07e..49c62b56 100755
@@ -9,7 +9,7 @@
 # flushing the log and then remounting to check file contents.
 
 . ./common/preamble
-_begin_fstest auto quick reflink
+_begin_fstest auto quick clone
 
 # Import common functions.
 . ./common/filter
tests/xfs/520 +1 -1
index 8410f2ba..2fceb07c 100755
@@ -12,7 +12,7 @@
 # is included in the current kernel.
 #
 . ./common/preamble
-_begin_fstest auto quick reflink
+_begin_fstest auto quick clone
 
 # Override the default cleanup function.
 _cleanup()
tests/xfs/535 +1 -1
index 4c883675..1a5da61b 100755
@@ -7,7 +7,7 @@
 # Verify that XFS does not cause inode fork's extent count to overflow when
 # writing to a shared extent.
 . ./common/preamble
-_begin_fstest auto quick reflink
+_begin_fstest auto quick clone
 
 # Import common functions.
 . ./common/filter
tests/xfs/536 +1 -1
index e5f904f5..64fa4fbf 100755
@@ -7,7 +7,7 @@
 # Verify that XFS does not cause inode fork's extent count to overflow when
 # remapping extents from one file's inode fork to another.
 . ./common/preamble
-_begin_fstest auto quick reflink
+_begin_fstest auto quick clone
 
 # Import common functions.
 . ./common/filter
#3 lore raw

PATCH v4 3/8 xfs: fix incorrect fuzz test group name

In reply to Darrick J. Wong

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

The group name for fuzz tests is 'fuzzers'.

---
 tests/xfs/491 |    2 +-
 tests/xfs/492 |    2 +-
 tests/xfs/493 |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
tests/xfs/491 +1 -1
index 5c7c5d1f..7402b09a 100755
@@ -7,7 +7,7 @@
 # Test detection & fixing of bad summary block counts at mount time.
 #
 . ./common/preamble
-_begin_fstest auto quick fuzz
+_begin_fstest auto quick fuzzers
 
 # Import common functions.
 . ./common/filter
tests/xfs/492 +1 -1
index 8258e5d8..514ac1e4 100755
@@ -7,7 +7,7 @@
 # Test detection & fixing of bad summary inode counts at mount time.
 #
 . ./common/preamble
-_begin_fstest auto quick fuzz
+_begin_fstest auto quick fuzzers
 
 # Import common functions.
 . ./common/filter
tests/xfs/493 +1 -1
index 58fd9c99..58091ad7 100755
@@ -8,7 +8,7 @@
 # Corrupt the AGFs to test mount failure when mount-fixing fails.
 #
 . ./common/preamble
-_begin_fstest auto quick fuzz
+_begin_fstest auto quick fuzzers
 
 # Import common functions.
 . ./common/filter
#4 lore raw

PATCH v4 4/8 btrfs: fix incorrect subvolume test group name

In reply to Darrick J. Wong

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

The group for testing subvolume functionality is 'subvol', not 'subvolume'.

---
 tests/btrfs/233 |    2 +-
 tests/btrfs/245 |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
tests/btrfs/233 +1 -1
index f3e3762c..6a414443 100755
@@ -9,7 +9,7 @@
 # performed.
 #
 . ./common/preamble
-_begin_fstest auto quick subvolume
+_begin_fstest auto quick subvol
 
 # Override the default cleanup function.
 _cleanup()
tests/btrfs/245 +1 -1
index 2b9c63c7..f3380ac2 100755
@@ -8,7 +8,7 @@
 # as subvolume and snapshot creation and deletion.
 #
 . ./common/preamble
-_begin_fstest auto quick idmapped subvolume
+_begin_fstest auto quick idmapped subvol
 
 # get standard environment, filters and checks
 . ./common/rc
#5 lore raw

PATCH v4 5/8 generic/631: change this test to use the 'whiteout' group

In reply to Darrick J. Wong

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

This test isn't really an overlay test; it's a regression test for a bug that someone found in xfs handling of whiteout files. Since the 'overlay' group has one member, let's move it to 'whiteout'.

---
 tests/generic/631 |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tests/generic/631 +1 -1
index a1acdedb..aae181dd 100755
@@ -22,7 +22,7 @@
 # in xfs_rename").
 
 . ./common/preamble
-_begin_fstest auto rw overlay rename
+_begin_fstest auto rw whiteout rename
 
 # Override the default cleanup function.
 _cleanup()
#6 lore raw

PATCH v4 6/8 tools: make sure that test groups are described in the documentation

In reply to Darrick J. Wong

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

Create a file to document the purpose of each test group that is currently defined in fstests, and change mkgroupfile to check that every group mentioned in the tests is also mentioned in the documentation.

---
 common/preamble     |   21 ++++++++
 doc/group-names.txt |  135 +++++++++++++++++++++++++++++++++++++++++++++++++++
 tools/mkgroupfile   |   33 +++++++++---
 3 files changed, 181 insertions(+), 8 deletions(-)
 create mode 100644 doc/group-names.txt
common/preamble +21 -0
index 66b0ed05..64d79385 100644
@@ -23,6 +23,26 @@ _register_cleanup()
 	trap "${cleanup}exit \$status" EXIT HUP INT QUIT TERM $*
 }
 
+# Make sure each group is in the documentation file.
+_check_groups() {
+	test -n "$GROUPNAME_DOC_FILE" || return 0
+
+	local testname="$(echo "$0" | sed -e 's/^.*tests\///g')"
+	declare -a missing=()
+
+	for group in "$@"; do
+		if ! grep -q "^${group}[[:space:]]" "$GROUPNAME_DOC_FILE"; then
+			missing+=("\"${group}\"")
+		fi
+	done
+	test "${#missing}" -eq 0 && return 0
+
+	local suffix=
+	test "${#missing}" -gt 1 && suffix="s"
+	echo "$testname: group$suffix ${missing[@]} not mentioned in documentation." 1>&2
+	return 1
+}
+
 # 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.
@@ -42,6 +62,7 @@ _begin_fstest()
 	# 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
+		_check_groups "$@" || exit 1
 		echo "$seq $@"
 		exit 0
 	fi
doc/group-names.txt new file +135 -0

135 lines not on this page · raw message

tools/mkgroupfile +25 -8
index 0681e5d2..e4244507 100755
@@ -9,12 +9,28 @@ fi
 
 test_dir="$PWD"
 groupfile="$1"
+GROUPNAME_DOC_FILE="$(readlink -m ../../doc/group-names.txt)"
+export GROUPNAME_DOC_FILE
 
 if [ ! -x ../../check ]; then
 	echo "$0: Run this from tests/XXX/."
 	exit 1
 fi
 
+cleanup() {
+	test -z "$groupfile" && return
+	test -z "$ngroupfile" && return
+
+	if [ $ret -eq 0 ]; then
+		mv "$ngroupfile" "$groupfile"
+	else
+		rm -f "$ngroupfile"
+	fi
+}
+
+ret=1	# trigger cleanup of temporary files unless we succeed
+trap 'cleanup; exit $ret' EXIT INT TERM QUIT
+
 generate_groupfile() {
 	cat << ENDL
 # QA groups control file, automatically generated.
@@ -24,19 +40,20 @@ ENDL
 	cd ../../
 	export GENERATE_GROUPS=yes
 	grep -R -l "^_begin_fstest" "$test_dir/" 2>/dev/null | while read testfile; do
-		test -x "$testfile" && "$testfile"
+		test -x "$testfile" && "$testfile" || return 1
 	done | sort -g
+	ret="${PIPESTATUS[1]}"
 	cd "$test_dir"
 }
 
 if [ -z "$groupfile" ] || [ "$groupfile" = "-" ]; then
 	# Dump the group file to stdout and exit
+	unset groupfile
 	generate_groupfile
-	exit 0
+else
+	# Otherwise, write the group file to disk somewhere.
+	ngroupfile="${groupfile}.new"
+	rm -f "$ngroupfile"
+	generate_groupfile >> "$ngroupfile"
+	# let cleanup rename or delete ngroupfile
 fi
-
-# Otherwise, write the group file to disk somewhere.
-ngroupfile="${groupfile}.new"
-rm -f "$ngroupfile"
-generate_groupfile >> "$ngroupfile"
-mv "$ngroupfile" "$groupfile"
#7 lore raw

PATCH v4 7/8 tools: add missing license tags to my scripts

In reply to Darrick J. Wong

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

I forgot to add spdx license tags and copyright statements to some of the tools that I've contributed to fstests. Fix this to be explicit.

---
 tools/mkgroupfile |    4 +++-
 tools/mvtest      |    5 ++++-
 tools/nextid      |    4 +++-
 3 files changed, 10 insertions(+), 3 deletions(-)
tools/mkgroupfile +3 -1
index e4244507..634ec92c 100755
@@ -1,5 +1,7 @@
 #!/bin/bash
-
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2021 Oracle.  All Rights Reserved.
+#
 # Generate a group file from the _begin_fstest call in each test.
 
 if [ "$1" = "--help" ]; then
tools/mvtest +4 -1
index 5088b45f..99b15414 100755
@@ -1,6 +1,9 @@
 #!/bin/sh
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2015 Oracle.  All Rights Reserved.
+#
+# Move a test and update the golden output file.
 
-# Renumber a test
 dir="$(dirname "$0")"
 
 if [ -z "$1" ] || [ "$1" = "--help" ]; then
tools/nextid +3 -1
index 9507de29..9e31718c 100755
@@ -1,5 +1,7 @@
 #!/bin/bash
-
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2015 Oracle.  All Rights Reserved.
+#
 # Compute the next available test id in a given test directory.
 
 if [ $# != 1 ] || [ "$1" = "--help" ] || [ ! -d "tests/$1/" ]; then
#8 lore raw

PATCH v4 8/8 new: only allow documented test group names

In reply to Darrick J. Wong

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

Now that we require all group names to be listed in doc/group-names.txt, we can use that (instead of running mkgroupfile) to check if the group name(s) supplied by the user actually exist. This has the secondary effect of being a second nudge towards keeping the description of groups up to date.

---
 new |   24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)
new +11 -13
index 2097a883..6b7dc5d4 100755
@@ -83,6 +83,14 @@ then
     exit 1
 fi
 
+# Extract group names from the documentation.
+group_names() {
+	awk '/^[[:lower:][:digit:]_]/ {
+		if ($1 != "" && $1 != "Group" && $2 != "Name:" && $1 != "all")
+			printf("%s\n", $1);
+	}' doc/group-names.txt
+}
+
 if [ $# -eq 0 ]
 then
 
@@ -93,16 +101,7 @@ then
 	[ -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
+	    echo $(group_names)
 	else
 	    # only allow lower cases, spaces, digits and underscore in group
 	    inval=`echo $ans | tr -d '[:lower:][:space:][:digit:]_'`
@@ -120,11 +119,10 @@ then
 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"
+	if ! grep -q "^$g" doc/group-names.txt; then
+	    echo "Warning: group \"$g\" not defined in documentation"
 	fi
     done
     ans="$*"