Skip to contentSkip to conversation

fstests: generic/733: avoid output difference due to bash's version

PATCH Superseded Qu Wenruo 3 participants 3 messages Sep 4, 2025 Btrfs file system

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

PATCH 1/1 fstests: generic/733: avoid output difference due to bash's version

[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]
Instead of relying on the job control behavior from bash, run the t_reflink_read_race tool in background, and wait for it to finish.

Background bash will be non-interactive, thus no job control and no "Terminated" message.

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 delete the "Terminated" line from the golden output.

---
 tests/generic/733     | 15 ++++++++++++++-
 tests/generic/733.out |  1 -
 2 files changed, 14 insertions(+), 2 deletions(-)
tests/generic/733 +14 -1
index aa7ad994..b8321abc 100755
@@ -70,8 +70,21 @@ done
 echo "fnr=$fnr" >> $seqres.full
 
 echo "Reflink the big file"
+# Workaround the default job control by running it at background.
+#
+# 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 won't work for the job
+# control message.
+#
+# Running the command in background will disable the job control thus
+# there will be no extra message like "Terminated".
+#
+# 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
+	"$testdir/outcome" &>> $seqres.full &
+wait
 
 if [ ! -e "$testdir/outcome" ]; then
 	echo "Could not set up program"
tests/generic/733.out +0 -1
index d4f5a7c7..2383cc8d 100644
@@ -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
Signature · 1 line
2.51.0
#1 lore raw
Quoted 57 lines · Qu Wenruo

[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]
Instead of relying on the job control behavior from bash, run the t_reflink_read_race tool in background, and wait for it to finish.

Background bash will be non-interactive, thus no job control and no "Terminated" message.

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 delete the "Terminated" line from the golden output.

---
 tests/generic/733     | 15 ++++++++++++++-
 tests/generic/733.out |  1 -
 2 files changed, 14 insertions(+), 2 deletions(-)
tests/generic/733 +6 -0
index aa7ad994..b8321abc 100755
@@ -70,8 +70,21 @@ done
 echo "fnr=$fnr" >> $seqres.full
 
 echo "Reflink the big file"
+# Workaround the default job control by running it at background.
+#
+# 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 won't work for the job
+# control message.

tests/generic/733 done · line 87

Quoted 10 lines
tests/generic/733 +8 -1
+#
+# Running the command in background will disable the job control thus
+# there will be no extra message like "Terminated".
+#
+# 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
+	"$testdir/outcome" &>> $seqres.full &
+wait

Hrmm, the only problem I can see is what happens if someone hits ^C to terminate fstests while t_reflink_read_race is running? Will anything wait for it to terminate, or will the user be stuck with it running in the background, pinning the mount, etc. ?

Or can we use shell command groups here:

{ $here/src/t_reflink_read_race <params> ; } 2>/dev/null

(the semicolon is significant)

to run t_reflink_read_race as a foreground job but redirect the shell's helpful termination messages to /dev/null?

--D

Quoted 17 lines
tests/generic/733 +0 -0
 if [ ! -e "$testdir/outcome" ]; then
 	echo "Could not set up program"
tests/generic/733.out +0 -1
index d4f5a7c7..2383cc8d 100644
@@ -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
Signature · 1 line
2.51.0
#2 lore raw
Quoted 74 lines · Darrick J. Wong
Quoted 57 lines · Qu Wenruo

[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]
Instead of relying on the job control behavior from bash, run the t_reflink_read_race tool in background, and wait for it to finish.

Background bash will be non-interactive, thus no job control and no "Terminated" message.

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 delete the "Terminated" line from the golden output.

---
  tests/generic/733     | 15 ++++++++++++++-
  tests/generic/733.out |  1 -
  2 files changed, 14 insertions(+), 2 deletions(-)
tests/generic/733 +6 -0
index aa7ad994..b8321abc 100755
@@ -70,8 +70,21 @@ done
  echo "fnr=$fnr" >> $seqres.full
 
  echo "Reflink the big file"
+# Workaround the default job control by running it at background.
+#
+# 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 won't work for the job
+# control message.

tests/generic/733 done · line 87

Quoted 10 lines
tests/generic/733 +8 -1
+#
+# Running the command in background will disable the job control thus
+# there will be no extra message like "Terminated".
+#
+# 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
+	"$testdir/outcome" &>> $seqres.full &
+wait

Hrmm, the only problem I can see is what happens if someone hits ^C to terminate fstests while t_reflink_read_race is running? Will anything wait for it to terminate, or will the user be stuck with it running in the background, pinning the mount, etc. ?

Quoted 5 lines

Or can we use shell command groups here:

{ $here/src/t_reflink_read_race <params> ; } 2>/dev/null

(the semicolon is significant)

That also works, and it keeps the foreground job control output, and this time we can redirect the job control message.

And of course no extra cleanup requirement.

Will go this solution.

Thanks a lot for pointing this out,
Qu

Quoted 24 lines

to run t_reflink_read_race as a foreground job but redirect the shell's helpful termination messages to /dev/null?

--D

Quoted 17 lines
tests/generic/733 +0 -0
  if [ ! -e "$testdir/outcome" ]; then
  	echo "Could not set up program"
tests/generic/733.out +0 -1
index d4f5a7c7..2383cc8d 100644
@@ -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
Signature · 1 line
2.51.0