btrfs: stop using run_check in _run_btrfs_balance_start
authorFilipe Manana <fdmanana@suse.com>
Tue, 14 Apr 2020 16:22:32 +0000 (17:22 +0100)
committerEryu Guan <guaneryu@gmail.com>
Sun, 19 Apr 2020 16:07:28 +0000 (00:07 +0800)
The use of run_check() immediately stops a test because it calls the
_fail() function when execution of its argument fails. This is
generally not encouraged in fstests as it prevents a test from
detecting further problems after that failure.

Since the next patch in this series updates other tests to use
_run_btrfs_balance_start() for which a failure to run balance can be
expected (btrfs/187 for example), remove the use of run_check() from
_run_btrfs_balance_start(). Existing tests that use
_run_btrfs_balance_start() now redirect standard output to the
test's .full file for debugging purposes. In case balance fails the
tests will fail due to unexpected output from the standard error.

Signed-off-by: Filipe Manana <fdmanana@suse.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
common/btrfs
tests/btrfs/124
tests/btrfs/177

index 7971c046e3892ccf4233904a8a1fa1a60d69f8fa..b43932df22aee6ab7d4d7abbe6b3448a9a1ac36e 100644 (file)
@@ -382,7 +382,7 @@ _run_btrfs_balance_start()
        $BTRFS_UTIL_PROG balance start --help | grep -q "full-balance"
        (( $? == 0 )) && bal_opt="--full-balance"
 
-       run_check $BTRFS_UTIL_PROG balance start $bal_opt $*
+       $BTRFS_UTIL_PROG balance start $bal_opt $*
 }
 
 #return the sector size of the btrfs scratch fs
index 0686a3b5f9913ba9763ca43a013f82cddb309dfd..0600ae50d430997c035bcb20ba16118e66b56752 100755 (executable)
@@ -114,7 +114,7 @@ _run_btrfs_util_prog device scan
 _scratch_mount >> $seqres.full 2>&1
 _run_btrfs_util_prog filesystem show
 echo >> $seqres.full
-_run_btrfs_balance_start ${SCRATCH_MNT}
+_run_btrfs_balance_start ${SCRATCH_MNT} >>$seqres.full
 
 checkpoint2=`md5sum $SCRATCH_MNT/tf2`
 echo $checkpoint2 >> $seqres.full 2>&1
index 69b9a539500a96b454eb5afed53b3d8174b3dd04..ec715c216bc5fdaf93e8a536d8a212c2e0ce7d60 100755 (executable)
@@ -44,7 +44,7 @@ _scratch_mount
 # Create a small file and run balance so we shall deal with the chunk
 # size as allocated by the kernel, mkfs allocated chunks are smaller.
 dd if=/dev/zero of="$SCRATCH_MNT/fill" bs=4096 count=1 >> $seqres.full 2>&1
-_run_btrfs_balance_start "$SCRATCH_MNT"
+_run_btrfs_balance_start "$SCRATCH_MNT" >>$seqres.full
 
 # Now fill it up.
 dd if=/dev/zero of="$SCRATCH_MNT/refill" bs=4096 >> $seqres.full 2>&1
@@ -63,7 +63,7 @@ rm -f "$SCRATCH_MNT/refill"
 
 # Get rid of empty block groups and also make sure that balance skips block
 # groups containing active swap files.
-_run_btrfs_balance_start "$SCRATCH_MNT"
+_run_btrfs_balance_start "$SCRATCH_MNT" >>$seqres.full
 
 # Try to shrink away the area occupied by the swap file, which should fail.
 $BTRFS_UTIL_PROG filesystem resize 1G "$SCRATCH_MNT" 2>&1 | grep -o "Text file busy"