fstests: automatically generate group files
authorDarrick J. Wong <djwong@kernel.org>
Mon, 21 Jun 2021 15:55:09 +0000 (08:55 -0700)
committerEryu Guan <guaneryu@gmail.com>
Sun, 27 Jun 2021 14:50:06 +0000 (22:50 +0800)
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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
Reviewed-by: Chandan Babu R <chandanrlinux@gmail.com>
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
18 files changed:
.gitignore
common/preamble
include/buildgrouplist [new file with mode: 0644]
tests/Makefile
tests/btrfs/Makefile
tests/ceph/Makefile
tests/cifs/Makefile
tests/ext4/Makefile
tests/f2fs/Makefile
tests/generic/Makefile
tests/nfs/Makefile
tests/ocfs2/Makefile
tests/overlay/Makefile
tests/perf/Makefile
tests/shared/Makefile
tests/udf/Makefile
tests/xfs/Makefile
tools/mkgroupfile [new file with mode: 0755]

index d3194e7..2d72b06 100644 (file)
@@ -11,6 +11,9 @@ tags
 /local.config
 /results
 
+# autogenerated group files
+/tests/*/group.list
+
 # autoconf generated files
 /aclocal.m4
 /autom4te.cache
index fba766d..66b0ed0 100644 (file)
@@ -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"
 
diff --git a/include/buildgrouplist b/include/buildgrouplist
new file mode 100644 (file)
index 0000000..d898efa
--- /dev/null
@@ -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 $@
index 8ce8f20..5c8f0b1 100644 (file)
@@ -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))
index 2d93642..1b72a1a 100644 (file)
@@ -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.
index 55e35d7..2761e1e 100644 (file)
@@ -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.
index 0c5cf3b..62c4893 100644 (file)
@@ -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.
index beb1541..a2a0d56 100644 (file)
@@ -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.
index d13bca3..9d1ed3c 100644 (file)
@@ -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.
index 3878d05..b464b22 100644 (file)
@@ -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.
index 754f2b2..128d2a3 100644 (file)
@@ -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.
index e133790..260ad31 100644 (file)
@@ -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.
index b07f892..de3203c 100644 (file)
@@ -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.
index 620f1db..0c74ba3 100644 (file)
@@ -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.
index 8a83278..f312871 100644 (file)
@@ -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.
index c9c9f1b..ed4434f 100644 (file)
@@ -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.
index d64800e..5f413e6 100644 (file)
@@ -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.
diff --git a/tools/mkgroupfile b/tools/mkgroupfile
new file mode 100755 (executable)
index 0000000..0681e5d
--- /dev/null
@@ -0,0 +1,42 @@
+#!/bin/bash
+
+# Generate a group file from the _begin_fstest call in each test.
+
+if [ "$1" = "--help" ]; then
+       echo "Usage: (cd tests/XXX/ ; ../../tools/mkgroupfile [output])"
+       exit 1
+fi
+
+test_dir="$PWD"
+groupfile="$1"
+
+if [ ! -x ../../check ]; then
+       echo "$0: Run this from tests/XXX/."
+       exit 1
+fi
+
+generate_groupfile() {
+       cat << ENDL
+# QA groups control file, automatically generated.
+# See _begin_fstest in each test for details.
+
+ENDL
+       cd ../../
+       export GENERATE_GROUPS=yes
+       grep -R -l "^_begin_fstest" "$test_dir/" 2>/dev/null | while read testfile; do
+               test -x "$testfile" && "$testfile"
+       done | sort -g
+       cd "$test_dir"
+}
+
+if [ -z "$groupfile" ] || [ "$groupfile" = "-" ]; then
+       # Dump the group file to stdout and exit
+       generate_groupfile
+       exit 0
+fi
+
+# Otherwise, write the group file to disk somewhere.
+ngroupfile="${groupfile}.new"
+rm -f "$ngroupfile"
+generate_groupfile >> "$ngroupfile"
+mv "$ngroupfile" "$groupfile"