From: Dave Chinner <david@fromorbit.com>
To: fstests@vger.kernel.org
Cc: zlang@kernel.org
Subject: [PATCH 03/28] fstests: move test exit functions to common/exit
Date: Thu, 17 Apr 2025 13:00:44 +1000 [thread overview]
Message-ID: <20250417031208.1852171-4-david@fromorbit.com> (raw)
In-Reply-To: <20250417031208.1852171-1-david@fromorbit.com>
From: Dave Chinner <dchinner@redhat.com>
Functions like _fatal() and _exit() need to be called from
common/config as well as general common and test code. Having some
of these test exit functions defined in common/config requires all
contexts to source this file and run all the environment setup
just to gain access to these functions.
There is a catch-22 with these functions - they cannot be defined in
common/rc for all contexts to pick up automatically, because
common/config needs them and some functions in common/rc depend on
common/config being sourced first. And we can't define them all in
common/config, because there are contexts where that hasn't been
sourced that need a specific test exit function.
Solve this by move all the test exit functions to a new common/exit
file and source that explicitly in the contexts that need it, hence
removing the circular dependency between common/config and common/rc
for defining these functions...
Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
check | 2 ++
common/config | 16 +---------------
common/exit | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
common/preamble | 1 +
common/rc | 22 ----------------------
5 files changed, 52 insertions(+), 37 deletions(-)
create mode 100644 common/exit
diff --git a/check b/check
index d6bab8b5f..69866b14b 100755
--- a/check
+++ b/check
@@ -52,6 +52,8 @@ rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
SRC_GROUPS="generic"
export SRC_DIR="tests"
+. ./common/exit
+
usage()
{
echo "Usage: $0 [options] [testlist]"'
diff --git a/common/config b/common/config
index eada39717..5081c300a 100644
--- a/common/config
+++ b/common/config
@@ -40,6 +40,7 @@
#
. common/test_names
+. common/exit
# all tests should use a common language setting to prevent golden
# output mismatches.
@@ -96,15 +97,6 @@ export LOCAL_CONFIGURE_OPTIONS=${LOCAL_CONFIGURE_OPTIONS:=--enable-readline=yes}
export RECREATE_TEST_DEV=${RECREATE_TEST_DEV:=false}
-# This functions sets the exit code to status and then exits. Don't use
-# exit directly, as it might not set the value of "$status" correctly, which is
-# used as an exit code in the trap handler routine set up by the check script.
-_exit()
-{
- test -n "$1" && status="$1"
- exit "$status"
-}
-
# Handle mkfs.$fstyp which does (or does not) require -f to overwrite
set_mkfs_prog_path_with_opts()
{
@@ -121,12 +113,6 @@ set_mkfs_prog_path_with_opts()
fi
}
-_fatal()
-{
- echo "$*"
- _exit 1
-}
-
export MKFS_PROG="$(type -P mkfs)"
[ "$MKFS_PROG" = "" ] && _fatal "mkfs not found"
diff --git a/common/exit b/common/exit
new file mode 100644
index 000000000..16777507a
--- /dev/null
+++ b/common/exit
@@ -0,0 +1,48 @@
+##/bin/bash
+# SPDX-License-Identifier: GPL-2.0+
+# Copyright (c) 2000-2006 Silicon Graphics, Inc. All Rights Reserved.
+#
+# Test termination functions that need to be independent of the context that the
+# test is running in. This must not have any dependencies on common/config or
+# common/rc, as they both require these functions to be defined before they are
+# sourced.
+
+# Exit a context, setting up the test exit status if appropriate.
+#
+# "$status" is the exit code for the trap handler routine set up by the check
+# script, hence we cannot call exit directly from contexts that require $status
+# to be set.
+_exit()
+{
+ test -n "$1" && status="$1"
+ exit "$status"
+}
+
+# Bail out of a test context, setting up .notrun file. Need to kill the
+# filesystem check files here, otherwise they are set incorrectly for the next
+# test.
+_notrun()
+{
+ echo "$*" > $seqres.notrun
+ echo "$seq not run: $*"
+ rm -f ${RESULT_DIR}/require_test*
+ rm -f ${RESULT_DIR}/require_scratch*
+
+ _exit 0
+}
+
+# Exit a test immediately with a fatal error.
+_fail()
+{
+ echo "$*" | tee -a $seqres.full
+ echo "(see $seqres.full for details)"
+ _exit 1
+}
+
+# Exit any context with a fatal error.
+_fatal()
+{
+ echo "$*"
+ _exit 1
+}
+
diff --git a/common/preamble b/common/preamble
index ba029a347..0b684cc33 100644
--- a/common/preamble
+++ b/common/preamble
@@ -49,6 +49,7 @@ _begin_fstest()
_register_cleanup _cleanup
+ . ./common/exit
. ./common/rc
init_rc
diff --git a/common/rc b/common/rc
index 12a05cb96..94c00d890 100644
--- a/common/rc
+++ b/common/rc
@@ -1798,28 +1798,6 @@ _do()
return $ret
}
-# bail out, setting up .notrun file. Need to kill the filesystem check files
-# here, otherwise they are set incorrectly for the next test.
-#
-_notrun()
-{
- echo "$*" > $seqres.notrun
- echo "$seq not run: $*"
- rm -f ${RESULT_DIR}/require_test*
- rm -f ${RESULT_DIR}/require_scratch*
-
- _exit 0
-}
-
-# just plain bail out
-#
-_fail()
-{
- echo "$*" | tee -a $seqres.full
- echo "(see $seqres.full for details)"
- _exit 1
-}
-
#
# Tests whether $FSTYP should be exclude from this test.
#
--
2.45.2
next prev parent reply other threads:[~2025-04-17 3:12 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-17 3:00 [PATCH 00/28] check-parallel: Running tests without check Dave Chinner
2025-04-17 3:00 ` [PATCH 01/28] fstests: remove support for non-numeric test names Dave Chinner
2025-04-30 9:17 ` Nirjhar Roy (IBM)
2025-05-21 2:39 ` Dave Chinner
2025-05-26 5:14 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 02/28] _scratch_mkfs_sized: obey USE_EXTERNAL for XFS filesystems Dave Chinner
2025-05-05 6:14 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` Dave Chinner [this message]
2025-04-17 3:00 ` [PATCH 04/28] check-parallel: report how many tests were _notrun Dave Chinner
2025-05-05 9:58 ` Nirjhar Roy (IBM)
2025-05-21 2:53 ` Dave Chinner
2025-05-26 6:09 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 05/28] check: factor out test list building code Dave Chinner
2025-05-06 11:32 ` Nirjhar Roy (IBM)
2025-05-21 3:55 ` Dave Chinner
2025-05-26 6:48 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 06/28] check-parallel: use common group list parsing code Dave Chinner
2025-05-06 15:56 ` Nirjhar Roy (IBM)
2025-05-21 4:13 ` Dave Chinner
2025-05-26 6:58 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 07/28] check-parallel: adjust concurrency according to CPU count Dave Chinner
2025-05-07 6:45 ` Nirjhar Roy (IBM)
2025-05-21 4:32 ` Dave Chinner
2025-05-26 8:50 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 08/28] check-parallel: add logwrite device support Dave Chinner
2025-05-07 8:18 ` Nirjhar Roy (IBM)
2025-05-21 10:07 ` Dave Chinner
2025-05-26 8:59 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 09/28] check-parallel: allow FSTYP selection from the CLI Dave Chinner
2025-05-07 8:49 ` Nirjhar Roy (IBM)
2025-05-21 10:17 ` Dave Chinner
2025-05-26 9:00 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 10/28] check-parallel: use PID namespaces for runner process isolation Dave Chinner
2025-05-07 9:02 ` Nirjhar Roy (IBM)
2025-05-21 10:19 ` Dave Chinner
2025-05-26 9:04 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 11/28] check-parallel: initial support for specifying device sizes Dave Chinner
2025-05-07 10:05 ` Nirjhar Roy (IBM)
2025-05-21 11:11 ` Dave Chinner
2025-04-17 3:00 ` [PATCH 12/28] config: move config section code to it's own file Dave Chinner
2025-05-09 6:09 ` Nirjhar Roy
2025-05-21 11:28 ` Dave Chinner
2025-04-17 3:00 ` [PATCH 13/28] check-parallel: introduce config file support Dave Chinner
2025-05-09 12:01 ` Nirjhar Roy
2025-05-21 12:23 ` Dave Chinner
2025-04-17 3:00 ` [PATCH 14/28] fstests: further separate sourcing common/rc and common/config from initialisation Dave Chinner
2025-05-10 14:08 ` Nirjhar Roy (IBM)
2025-04-17 3:00 ` [PATCH 15/28] check-parallel: de-batch test execution Dave Chinner
2025-05-09 13:16 ` Nirjhar Roy
2025-04-17 3:00 ` [PATCH 16/28] check-parallel: run sections directly Dave Chinner
2025-05-09 14:03 ` Nirjhar Roy
2025-04-17 3:00 ` [PATCH 17/28] check-parallel: rebuild test list when FSTYP changes Dave Chinner
2025-05-09 16:00 ` Nirjhar Roy
2025-04-17 3:00 ` [PATCH 18/28] check-parallel: create a "results-latest" symlink Dave Chinner
2025-05-10 13:12 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 19/28] check: factor test running Dave Chinner
2025-05-12 13:57 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 20/28] [RFC] check-parallel: run tests directly without using check Dave Chinner
2025-05-13 14:48 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 21/28] generic/531: limit max files per CPU Dave Chinner
2025-05-10 13:15 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 22/28] fsync-tester.c: use syncfs() rather than sync() Dave Chinner
2025-04-30 9:08 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 23/28] open-by-handle.c: " Dave Chinner
2025-04-30 9:02 ` Nirjhar Roy (IBM)
2025-05-21 2:32 ` Dave Chinner
2025-05-26 5:11 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 24/28] " Dave Chinner
2025-04-30 8:56 ` Nirjhar Roy (IBM)
2025-05-21 2:30 ` Dave Chinner
2025-05-26 4:56 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 25/28] bulkstat_unlink_test_modified.c: remove unused test code Dave Chinner
2025-04-30 8:47 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 26/28] stale-handle.c: use syncfs() rather than sync() Dave Chinner
2025-04-30 8:34 ` Nirjhar Roy (IBM)
2025-05-21 2:24 ` Dave Chinner
2025-04-17 3:01 ` [PATCH 27/28] scaleread: remove dead test code Dave Chinner
2025-04-30 8:10 ` Nirjhar Roy (IBM)
2025-04-17 3:01 ` [PATCH 28/28] xfs/259: no need to call sync Dave Chinner
2025-04-30 7:56 ` Nirjhar Roy (IBM)
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250417031208.1852171-4-david@fromorbit.com \
--to=david@fromorbit.com \
--cc=fstests@vger.kernel.org \
--cc=zlang@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox