* [PATCH v2] fstests: generic/733: avoid output difference due to bash's version
@ 2025-09-04 21:44 Qu Wenruo
2025-09-05 1:01 ` Darrick J. Wong
2025-09-07 23:32 ` Neal Gompa
0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2025-09-04 21:44 UTC (permalink / raw)
To: linux-btrfs, fstests
[FALSE ALERT]
When running generic/733 with bash 5.3.3 (any thing newer than 5.3.0
will reproduce the bug), the test case will fail like the following:
generic/733 19s ... - output mismatch (see /home/adam/xfstests/results//generic/733.out.bad)
--- tests/generic/733.out 2025-09-04 17:30:08.568000000 +0930
+++ /home/adam/xfstests/results//generic/733.out.bad 2025-09-04 17:30:32.898475103 +0930
@@ -2,5 +2,5 @@
Format and mount
Create a many-block file
Reflink the big file
-Terminated
+Terminated $here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" "$testdir/outcome" &>> $seqres.full
test completed successfully
...
(Run 'diff -u /home/adam/xfstests/tests/generic/733.out /home/adam/xfstests/results//generic/733.out.bad' to see the entire diff)
[CAUSE]
The failure is fs independent, but bash version dependent.
In bash v5.3.x, the job control will output the command which triggered
the job control (from termination to core dump etc).
The "Terminated" message is not from the program, but from bash's job
control, thus redirection won't hide that message.
[FIX]
Run the command in a command group, which will be executed in a
subshell.
By this we can redirect the output of the subshell, including the job
control message, thus hide the different output pattern caused by
different bash versions.
Thankfully this particular test case does extra checks on the outcome
file to determine if the program is properly terminated, thus we are
safe to move the "Terminated" line from the golden output to
seqres.full.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
v2:
- Use command grouping instead of background execution
Background execution requires extra cleanup to wait for the background
program.
Meanwhile command grouping will run in a subshell thus we can redirect
everything including the job control message.
Thanks Darrick for pointing this solution out.
---
tests/generic/733 | 17 +++++++++++++++--
tests/generic/733.out | 1 -
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/tests/generic/733 b/tests/generic/733
index aa7ad994..21347d51 100755
--- a/tests/generic/733
+++ b/tests/generic/733
@@ -70,8 +70,21 @@ done
echo "fnr=$fnr" >> $seqres.full
echo "Reflink the big file"
-$here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" \
- "$testdir/outcome" &>> $seqres.full
+# Workaround the default job control by command grouping so that we can redirect
+# the job control message of the subshell.
+#
+# Job control of bash v5.3.x will output the command which triggered the job
+# control (terminated, core dump etc).
+# And since it's handled by bash itself, redirection of the program won't work
+# for the job control message.
+#
+# Running the command in a command group will make the program run in a subshell
+# so that we can direct the job control message of the subshell.
+#
+# We will check the outcome file to determine if the program is properly
+# terminated, thus no need to bother the job control message.
+{ $here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" \
+ "$testdir/outcome" ; } &>> $seqres.full
if [ ! -e "$testdir/outcome" ]; then
echo "Could not set up program"
diff --git a/tests/generic/733.out b/tests/generic/733.out
index d4f5a7c7..2383cc8d 100644
--- a/tests/generic/733.out
+++ b/tests/generic/733.out
@@ -2,5 +2,4 @@ QA output created by 733
Format and mount
Create a many-block file
Reflink the big file
-Terminated
test completed successfully
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH v2] fstests: generic/733: avoid output difference due to bash's version
2025-09-04 21:44 [PATCH v2] fstests: generic/733: avoid output difference due to bash's version Qu Wenruo
@ 2025-09-05 1:01 ` Darrick J. Wong
2025-09-07 23:32 ` Neal Gompa
1 sibling, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2025-09-05 1:01 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs, fstests
On Fri, Sep 05, 2025 at 07:14:15AM +0930, Qu Wenruo wrote:
> [FALSE ALERT]
> When running generic/733 with bash 5.3.3 (any thing newer than 5.3.0
> will reproduce the bug), the test case will fail like the following:
>
> generic/733 19s ... - output mismatch (see /home/adam/xfstests/results//generic/733.out.bad)
> --- tests/generic/733.out 2025-09-04 17:30:08.568000000 +0930
> +++ /home/adam/xfstests/results//generic/733.out.bad 2025-09-04 17:30:32.898475103 +0930
> @@ -2,5 +2,5 @@
> Format and mount
> Create a many-block file
> Reflink the big file
> -Terminated
> +Terminated $here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" "$testdir/outcome" &>> $seqres.full
> test completed successfully
> ...
> (Run 'diff -u /home/adam/xfstests/tests/generic/733.out /home/adam/xfstests/results//generic/733.out.bad' to see the entire diff)
>
> [CAUSE]
> The failure is fs independent, but bash version dependent.
>
> In bash v5.3.x, the job control will output the command which triggered
> the job control (from termination to core dump etc).
>
> The "Terminated" message is not from the program, but from bash's job
> control, thus redirection won't hide that message.
>
> [FIX]
> Run the command in a command group, which will be executed in a
> subshell.
>
> By this we can redirect the output of the subshell, including the job
> control message, thus hide the different output pattern caused by
> different bash versions.
>
> Thankfully this particular test case does extra checks on the outcome
> file to determine if the program is properly terminated, thus we are
> safe to move the "Terminated" line from the golden output to
> seqres.full.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> v2:
> - Use command grouping instead of background execution
> Background execution requires extra cleanup to wait for the background
> program.
> Meanwhile command grouping will run in a subshell thus we can redirect
> everything including the job control message.
>
> Thanks Darrick for pointing this solution out.
> ---
> tests/generic/733 | 17 +++++++++++++++--
> tests/generic/733.out | 1 -
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/tests/generic/733 b/tests/generic/733
> index aa7ad994..21347d51 100755
> --- a/tests/generic/733
> +++ b/tests/generic/733
> @@ -70,8 +70,21 @@ done
> echo "fnr=$fnr" >> $seqres.full
>
> echo "Reflink the big file"
> -$here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" \
> - "$testdir/outcome" &>> $seqres.full
> +# Workaround the default job control by command grouping so that we can redirect
> +# the job control message of the subshell.
> +#
> +# Job control of bash v5.3.x will output the command which triggered the job
> +# control (terminated, core dump etc).
> +# And since it's handled by bash itself, redirection of the program won't work
> +# for the job control message.
> +#
> +# Running the command in a command group will make the program run in a subshell
> +# so that we can direct the job control message of the subshell.
> +#
> +# We will check the outcome file to determine if the program is properly
> +# terminated, thus no need to bother the job control message.
> +{ $here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" \
> + "$testdir/outcome" ; } &>> $seqres.full
/me wonders how many more of these bash messages are lurking out there,
but in the meantime
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
>
> if [ ! -e "$testdir/outcome" ]; then
> echo "Could not set up program"
> diff --git a/tests/generic/733.out b/tests/generic/733.out
> index d4f5a7c7..2383cc8d 100644
> --- a/tests/generic/733.out
> +++ b/tests/generic/733.out
> @@ -2,5 +2,4 @@ QA output created by 733
> Format and mount
> Create a many-block file
> Reflink the big file
> -Terminated
> test completed successfully
> --
> 2.51.0
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH v2] fstests: generic/733: avoid output difference due to bash's version
2025-09-04 21:44 [PATCH v2] fstests: generic/733: avoid output difference due to bash's version Qu Wenruo
2025-09-05 1:01 ` Darrick J. Wong
@ 2025-09-07 23:32 ` Neal Gompa
1 sibling, 0 replies; 3+ messages in thread
From: Neal Gompa @ 2025-09-07 23:32 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs, fstests
On Thu, Sep 4, 2025 at 11:44 PM Qu Wenruo <wqu@suse.com> wrote:
>
> [FALSE ALERT]
> When running generic/733 with bash 5.3.3 (any thing newer than 5.3.0
> will reproduce the bug), the test case will fail like the following:
>
> generic/733 19s ... - output mismatch (see /home/adam/xfstests/results//generic/733.out.bad)
> --- tests/generic/733.out 2025-09-04 17:30:08.568000000 +0930
> +++ /home/adam/xfstests/results//generic/733.out.bad 2025-09-04 17:30:32.898475103 +0930
> @@ -2,5 +2,5 @@
> Format and mount
> Create a many-block file
> Reflink the big file
> -Terminated
> +Terminated $here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" "$testdir/outcome" &>> $seqres.full
> test completed successfully
> ...
> (Run 'diff -u /home/adam/xfstests/tests/generic/733.out /home/adam/xfstests/results//generic/733.out.bad' to see the entire diff)
>
> [CAUSE]
> The failure is fs independent, but bash version dependent.
>
> In bash v5.3.x, the job control will output the command which triggered
> the job control (from termination to core dump etc).
>
> The "Terminated" message is not from the program, but from bash's job
> control, thus redirection won't hide that message.
>
> [FIX]
> Run the command in a command group, which will be executed in a
> subshell.
>
> By this we can redirect the output of the subshell, including the job
> control message, thus hide the different output pattern caused by
> different bash versions.
>
> Thankfully this particular test case does extra checks on the outcome
> file to determine if the program is properly terminated, thus we are
> safe to move the "Terminated" line from the golden output to
> seqres.full.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> v2:
> - Use command grouping instead of background execution
> Background execution requires extra cleanup to wait for the background
> program.
> Meanwhile command grouping will run in a subshell thus we can redirect
> everything including the job control message.
>
> Thanks Darrick for pointing this solution out.
> ---
> tests/generic/733 | 17 +++++++++++++++--
> tests/generic/733.out | 1 -
> 2 files changed, 15 insertions(+), 3 deletions(-)
>
> diff --git a/tests/generic/733 b/tests/generic/733
> index aa7ad994..21347d51 100755
> --- a/tests/generic/733
> +++ b/tests/generic/733
> @@ -70,8 +70,21 @@ done
> echo "fnr=$fnr" >> $seqres.full
>
> echo "Reflink the big file"
> -$here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" \
> - "$testdir/outcome" &>> $seqres.full
> +# Workaround the default job control by command grouping so that we can redirect
> +# the job control message of the subshell.
> +#
> +# Job control of bash v5.3.x will output the command which triggered the job
> +# control (terminated, core dump etc).
> +# And since it's handled by bash itself, redirection of the program won't work
> +# for the job control message.
> +#
> +# Running the command in a command group will make the program run in a subshell
> +# so that we can direct the job control message of the subshell.
> +#
> +# We will check the outcome file to determine if the program is properly
> +# terminated, thus no need to bother the job control message.
> +{ $here/src/t_reflink_read_race "$testdir/file1" "$testdir/file2" \
> + "$testdir/outcome" ; } &>> $seqres.full
>
> if [ ! -e "$testdir/outcome" ]; then
> echo "Could not set up program"
> diff --git a/tests/generic/733.out b/tests/generic/733.out
> index d4f5a7c7..2383cc8d 100644
> --- a/tests/generic/733.out
> +++ b/tests/generic/733.out
> @@ -2,5 +2,4 @@ QA output created by 733
> Format and mount
> Create a many-block file
> Reflink the big file
> -Terminated
> test completed successfully
> --
> 2.51.0
>
LGTM.
Reviewed-by: Neal Gompa <neal@gompa.dev>
--
真実はいつも一つ!/ Always, there's only one truth!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-09-07 23:32 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-04 21:44 [PATCH v2] fstests: generic/733: avoid output difference due to bash's version Qu Wenruo
2025-09-05 1:01 ` Darrick J. Wong
2025-09-07 23:32 ` Neal Gompa
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.