[PATCH 02/10] fstests: refactor setting test sequence number variables

Darrick J. Wong
2021-05-26T01:46:55Z

Create 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.

Signed-off-by: Darrick J. Wong <djwong@kernel.org>
---
common/test_names | 13 +++++++++++++
new | 8 ++------
2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/common/test_names b/common/test_names
index 98af40cd..3b0b889a 100644
--- a/common/test_names
+++ b/common/test_names
@@ -10,3 +10,16 @@
#
VALID_TEST_ID="[0-9]\{3\}"
VALID_TEST_NAME="$VALID_TEST_ID-\?[[:alnum:]-]*"
+
+# Initialize the global seq, seqres, here, tmp, and status variables to their
+# defaults. Group memberships are the only arguments to this helper.
+_set_seq_and_groups()
+{
+ seq=`basename $0`
+ seqres=$RESULT_DIR/$seq
+ echo "QA output created by $seq"
+
+ here=`pwd`
+ tmp=/tmp/$$
+ status=1 # failure is the default!
+}
diff --git a/new b/new
index 357983d9..59e53d08 100755
--- a/new
+++ b/new
@@ -153,13 +153,9 @@ cat <<End-of-File >$tdir/$id
#
# what am I here for?
#
-seq=\`basename \$0\`
-seqres=\$RESULT_DIR/\$seq
-echo "QA output created by \$seq"
+. ./common/test_names
+_set_seq_and_groups other

-here=\`pwd\`
-tmp=/tmp/\$\$
-status=1 # failure is the default!
trap "_cleanup; exit \\\$status" 0 1 2 3 15

_cleanup()