public inbox for fstests@vger.kernel.org
 help / color / mirror / Atom feed
From: "Darrick J. Wong" <djwong@kernel.org>
To: Christoph Hellwig <hch@lst.de>
Cc: Zorro Lang <zlang@kernel.org>, Anand Jain <anand.jain@oracle.com>,
	Filipe Manana <fdmanana@suse.com>,
	fstests@vger.kernel.org, linux-ext4@vger.kernel.org,
	linux-xfs@vger.kernel.org
Subject: Re: [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV
Date: Wed, 10 Dec 2025 12:05:50 -0800	[thread overview]
Message-ID: <20251210200550.GH94594@frogsfrogsfrogs> (raw)
In-Reply-To: <20251210054831.3469261-7-hch@lst.de>

On Wed, Dec 10, 2025 at 06:46:52AM +0100, Christoph Hellwig wrote:
> This tests wants to test various difference device configurations,
> and does so by overriding SCRATCH_{,LOG,RT}DEV.  This has two downside:
> 
>  1) the actual SCRATCH_{,LOG,RT}DEV configuration is still injected by
>     default, thus making the test dependent on that configuration
>  2) the MKFS_OPTIONS might not actually be compatible with the
>     configuration created
> 
> Fix this by open coding the mkfs, db, admin and repair calls and always
> run them on the specific configuration.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Interesting solution to that...
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>

--D

> ---
>  tests/xfs/157 | 104 +++++++++++++++++++++++++++++++++++++-------------
>  1 file changed, 78 insertions(+), 26 deletions(-)
> 
> diff --git a/tests/xfs/157 b/tests/xfs/157
> index e102a5a10abe..31f05db25724 100755
> --- a/tests/xfs/157
> +++ b/tests/xfs/157
> @@ -50,53 +50,105 @@ fake_rtfile=$TEST_DIR/$seq.scratch.rt
>  rm -f $fake_rtfile
>  truncate -s $fs_size $fake_rtfile
>  
> -# Save the original variables
> -orig_ddev=$SCRATCH_DEV
> -orig_external=$USE_EXTERNAL
> -orig_logdev=$SCRATCH_LOGDEV
> -orig_rtdev=$SCRATCH_RTDEV
> -
>  scenario() {
>  	echo "$@" | tee -a $seqres.full
>  
> -	SCRATCH_DEV=$orig_ddev
> -	USE_EXTERNAL=$orig_external
> -	SCRATCH_LOGDEV=$orig_logdev
> -	SCRATCH_RTDEV=$orig_rtdev
> +	dev=$SCRATCH_DEV
> +	logdev=
> +	rtdev=
> +}
> +
> +_fake_mkfs()
> +{
> +	OPTIONS="$*"
> +	if [ -n "$logdev" ]; then
> +		OPTIONS="$OPTIONS -l logdev=$logdev"
> +	fi
> +	if [ -n "$rtdev" ]; then
> +		OPTIONS="$OPTIONS -r rtdev=$rtdev"
> +	fi
> +	$MKFS_XFS_PROG -f $OPTIONS $dev || _fail "mkfs failed"
> +}
> +
> +_fake_xfs_db_options()
> +{
> +	OPTIONS=""
> +	if [ ! -z "$logdev" ]; then
> +		OPTIONS="-l $logdev"
> +	fi
> +	if [ ! -z "$rtdev" ]; then
> +		if [ $XFS_DB_PROG --help 2>&1 | grep -q -- '-R rtdev']; then
> +			OPTIONS="$OPTIONS -R $rtdev"
> +		fi
> +	fi
> +	echo $OPTIONS $* $dev
> +}
> +
> +_fake_xfs_db()
> +{
> +	$XFS_DB_PROG "$@" $(_fake_xfs_db_options)
> +}
> +
> +_fake_xfs_admin()
> +{
> +	local options=("$dev")
> +	local rt_opts=()
> +	if [ -n "$logdev" ]; then
> +		options+=("$logdev")
> +	fi
> +	if [ -n "$rtdev" ]; then
> +		$XFS_ADMIN_PROG --help 2>&1 | grep -q 'rtdev' || \
> +			_notrun 'xfs_admin does not support rt devices'
> +		rt_opts+=(-r "$rtdev")
> +	fi
> +
> +	# xfs_admin in xfsprogs 5.11 has a bug where an external log device
> +	# forces xfs_db to be invoked, potentially with zero command arguments.
> +	# When this happens, xfs_db will wait for input on stdin, which causes
> +	# fstests to hang.  Since xfs_admin is not an interactive tool, we
> +	# can redirect stdin from /dev/null to prevent this issue.
> +	$XFS_ADMIN_PROG "${rt_opts[@]}" "$@" "${options[@]}" < /dev/null
> +}
> +
> +
> +_fake_xfs_repair()
> +{
> +	OPTIONS=""
> +	if [ -n "$logdev" ]; then
> +		OPTIONS="-l $logdev"
> +	fi
> +	if [ -n "$rtdev" ]; then
> +		OPTIONS="$OPTIONS -r $rtdev"
> +	fi
> +	$XFS_REPAIR_PROG $OPTIONS $* $dev
>  }
>  
>  check_label() {
> -	_scratch_mkfs_sized "$fs_size" "" -L oldlabel >> $seqres.full 2>&1
> -	_scratch_xfs_db -c label
> -	_scratch_xfs_admin -L newlabel "$@" >> $seqres.full
> -	_scratch_xfs_db -c label
> -	_scratch_xfs_repair -n &>> $seqres.full || echo "Check failed?"
> +	_fake_mkfs -L oldlabel >> $seqres.full 2>&1
> +	_fake_xfs_db -c label
> +	_fake_xfs_admin -L newlabel "$@" >> $seqres.full
> +	_fake_xfs_db -c label
> +	_fake_xfs_repair -n &>> $seqres.full || echo "Check failed?"
>  }
>  
>  scenario "S1: Check that label setting with file image"
> -SCRATCH_DEV=$fake_datafile
> +dev=$fake_datafile
>  check_label -f
>  
>  scenario "S2: Check that setting with logdev works"
> -USE_EXTERNAL=yes
> -SCRATCH_LOGDEV=$fake_logfile
> +logdev=$fake_logfile
>  check_label
>  
>  scenario "S3: Check that setting with rtdev works"
> -USE_EXTERNAL=yes
> -SCRATCH_RTDEV=$fake_rtfile
> +rtdev=$fake_rtfile
>  check_label
>  
>  scenario "S4: Check that setting with rtdev + logdev works"
> -USE_EXTERNAL=yes
> -SCRATCH_LOGDEV=$fake_logfile
> -SCRATCH_RTDEV=$fake_rtfile
> +logdev=$fake_logfile
> +rtdev=$fake_rtfile
>  check_label
>  
>  scenario "S5: Check that setting with nortdev + nologdev works"
> -USE_EXTERNAL=
> -SCRATCH_LOGDEV=
> -SCRATCH_RTDEV=
>  check_label
>  
>  scenario "S6: Check that setting with bdev incorrectly flagged as file works"
> -- 
> 2.47.3
> 
> 

  reply	other threads:[~2025-12-10 20:05 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-10  5:46 stop overriding SCRATCH_{,LOG,RT}DEV Christoph Hellwig
2025-12-10  5:46 ` [PATCH 01/12] dmflakey: override SCRATCH_DEV in _init_flakey Christoph Hellwig
2025-12-10  5:46 ` [PATCH 02/12] ext4/006: call e2fsck directly Christoph Hellwig
2025-12-10 19:32   ` Darrick J. Wong
2025-12-11  4:52     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 03/12] common: add a _check_dev_fs helper Christoph Hellwig
2025-12-10 23:24   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 04/12] ext4/032: use _check_dev_fs Christoph Hellwig
2025-12-10 23:24   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 05/12] generic/590: split XFS RT specific bits out Christoph Hellwig
2025-12-10 22:51   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 06/12] xfs/157: don't override SCRATCH_{,LOG,RT}DEV Christoph Hellwig
2025-12-10 20:05   ` Darrick J. Wong [this message]
2025-12-10  5:46 ` [PATCH 07/12] xfs/185: don't use SCRATCH_{,RT}DEV helpers Christoph Hellwig
2025-12-10 20:02   ` Darrick J. Wong
2025-12-11  5:00     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 08/12] xfs/424: don't use SCRATCH_DEV helpers Christoph Hellwig
2025-12-10 19:55   ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 09/12] xfs/521: require a real SCRATCH_RTDEV Christoph Hellwig
2025-12-10 19:54   ` Darrick J. Wong
2025-12-11  4:58     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 10/12] xfs/528: " Christoph Hellwig
2025-12-10 19:52   ` Darrick J. Wong
2025-12-11  4:57     ` Christoph Hellwig
2025-12-10  5:46 ` [PATCH 11/12] xfs/530: " Christoph Hellwig
2025-12-10 19:49   ` Darrick J. Wong
2025-12-11  4:55     ` Christoph Hellwig
2025-12-12 20:00       ` Darrick J. Wong
2025-12-10  5:46 ` [PATCH 12/12] xfs/650: " Christoph Hellwig
2025-12-10 19:45   ` Darrick J. Wong
2025-12-10 22:50     ` Darrick J. Wong
2025-12-11  4:54       ` Christoph Hellwig

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=20251210200550.GH94594@frogsfrogsfrogs \
    --to=djwong@kernel.org \
    --cc=anand.jain@oracle.com \
    --cc=fdmanana@suse.com \
    --cc=fstests@vger.kernel.org \
    --cc=hch@lst.de \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-xfs@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