All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zorro Lang <zlang@kernel.org>
To: fstests@vger.kernel.org
Cc: Andrey Albershteyn <aalbersh@redhat.com>,
	cem@kernel.org, Dave Chinner <david@fromorbit.com>,
	linux-xfs@vger.kernel.org, linux-btrfs@vger.kernel.org,
	linux-ext4@vger.kernel.org
Subject: [PATCH 3/6] check: introduce pre-test hook and CLI option
Date: Thu, 26 Nov 2026 05:28:20 +0800	[thread overview]
Message-ID: <20261125212823.3389430-4-zlang@kernel.org> (raw)
In-Reply-To: <20261125212823.3389430-1-zlang@kernel.org>

Add the --hook-pre-test option and run matching hooks right before
each test is executed. Hooks are validated during option parsing,
before any tests run.

Signed-off-by: Zorro Lang <zlang@kernel.org>
---
 check | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/check b/check
index afe855bc..a90b2d6d 100755
--- a/check
+++ b/check
@@ -48,6 +48,7 @@ export DIFF_LENGTH=${DIFF_LENGTH:=10}
 timestamp=${TIMESTAMP:=false}
 . common/exit
 . common/test_names
+. common/hooks
 
 rm -f $tmp.list $tmp.tmp $tmp.grep $here/$iam.out $tmp.report.* $tmp.arglist
 
@@ -75,6 +76,9 @@ General options:
     -T                      output timestamps
     -R fmt[,fmt]            generate report in formats specified. Supported
                               formats: xunit, xunit-quiet
+    --hook-pre-test path=script[,mode=in|out][,match=glob]...
+                            run a hook before each matching test; may be
+                              given multiple times
     --exact-order           run tests in the exact order specified
     --extra-space <size>    require minimum free space on scratch device
     --fs <type>             test the given FSTYP; valid types include:
@@ -388,7 +392,7 @@ process_remain_tests()
 parse_check_args()
 {
 	local short_opts="g:x:X:e:E:s:S:lnri:I:TdbR:L:h"
-	local long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help"
+	local long_opts="fs:,exact-order,large-fs,extra-space:,udiff,help,hook-pre-test:"
 
 	compat_old_option "$@"
 
@@ -489,6 +493,10 @@ parse_check_args()
 			do_report=true
 			shift
 			;;
+		--hook-pre-test)
+			_hook_parse_args pre-test "$2"
+			shift
+			;;
 		--large-fs)
 			export LARGE_SCRATCH_DEV=yes
 			;;
@@ -1054,7 +1062,7 @@ function run_section()
 		mkdir -p $RESULT_DIR
 		rm -f ${RESULT_DIR}/require_scratch*
 		rm -f ${RESULT_DIR}/require_test*
-		rm -f $seqres.out.bad $seqres.hints $seqres.out.good
+		rm -f $seqres.out.bad $seqres.hints $seqres.out.good $seqres.hooks
 
 		# check if we really should run it
 		if _expunge_test $seqnum; then
@@ -1092,6 +1100,7 @@ function run_section()
 		(echo 1 > $DEBUGFS_MNT/clear_warn_once) > /dev/null 2>&1
 
 		test_start_time="$(date +"%F %T")"
+		_hook_run_event pre-test "$seqnum"
 		if [ "$DUMP_OUTPUT" = true ]; then
 			_run_seq 2>&1 | tee $tmp.out
 			# Because $? would get tee's return code
-- 
2.56.0


  parent reply	other threads:[~2026-11-25 21:28 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 21:28 [PATCH 0/6] Add test hook infrastructure Zorro Lang
2026-11-25 21:28 ` [PATCH 1/6] common: add builtin " Zorro Lang
2026-11-25 21:28 ` [PATCH 2/6] common: add out-of-process hook mode Zorro Lang
2026-11-25 21:28 ` Zorro Lang [this message]
2026-11-25 21:28 ` [PATCH 4/6] check: introduce post-test hook and CLI option Zorro Lang
2026-11-25 21:28 ` [PATCH 5/6] check: introduce post-result " Zorro Lang
2026-11-25 21:28 ` [PATCH 6/6] doc: document the test hooks Zorro Lang

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=20261125212823.3389430-4-zlang@kernel.org \
    --to=zlang@kernel.org \
    --cc=aalbersh@redhat.com \
    --cc=cem@kernel.org \
    --cc=david@fromorbit.com \
    --cc=fstests@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-xfs@vger.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.