diff mbox series

[2/5] btrfs/282: append scrub status output to 282.full

Message ID 20231207072056.14588-3-ddiss@suse.de (mailing list archive)
State New, archived
Headers show
Series btrfs/282: resolve intermittent failures | expand

Commit Message

David Disseldorp Dec. 7, 2023, 7:20 a.m. UTC
Also, collapse the grep/cut usage into the existing awk one-liner.

Signed-off-by: David Disseldorp <ddiss@suse.de>
---
 tests/btrfs/282 | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

Comments

Qu Wenruo Dec. 7, 2023, 9:46 a.m. UTC | #1
On 2023/12/7 17:50, David Disseldorp wrote:
> Also, collapse the grep/cut usage into the existing awk one-liner.
>
> Signed-off-by: David Disseldorp <ddiss@suse.de>

This change itself is totally fine independent of the fix for btrfs/282.

Reviewed-by: Qu Wenruo <wqu@suse.com>

Thanks,
Qu
> ---
>   tests/btrfs/282 | 10 ++++++----
>   1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/tests/btrfs/282 b/tests/btrfs/282
> index 395e0626..66d14f82 100755
> --- a/tests/btrfs/282
> +++ b/tests/btrfs/282
> @@ -60,8 +60,9 @@ $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >> $seqres.full
>   # Error summary:    no errors found
>   #
>   # What we care is that Rate line.
> -init_speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT | grep "Rate:" |\
> -	     $AWK_PROG '{print $2}' | cut -f1 -d\/)
> +init_speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT |\
> +	     tee -a $seqres.full |\
> +	     $AWK_PROG '$1 == "Rate:" {sub(/\/s/, "", $2); print $2}')
>
>   # This can happen for older progs
>   if [ -z "$init_speed" ]; then
> @@ -76,8 +77,9 @@ echo "$target_speed" > "${devinfo_dir}/scrub_speed_max"
>
>   # The second scrub, to check the throttled speed.
>   $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >> $seqres.full
> -speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT | grep "Rate:" |\
> -	     $AWK_PROG '{print $2}' | cut -f1 -d\/)
> +speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT |\
> +	tee -a $seqres.full |\
> +	$AWK_PROG '$1 == "Rate:" {sub(/\/s/, "", $2); print $2}')
>
>   # We gave a +- 10% tolerance for the throttle
>   if [ "$speed" -gt "$(( $target_speed * 11 / 10 ))" -o \
diff mbox series

Patch

diff --git a/tests/btrfs/282 b/tests/btrfs/282
index 395e0626..66d14f82 100755
--- a/tests/btrfs/282
+++ b/tests/btrfs/282
@@ -60,8 +60,9 @@  $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >> $seqres.full
 # Error summary:    no errors found
 #
 # What we care is that Rate line.
-init_speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT | grep "Rate:" |\
-	     $AWK_PROG '{print $2}' | cut -f1 -d\/)
+init_speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT |\
+	     tee -a $seqres.full |\
+	     $AWK_PROG '$1 == "Rate:" {sub(/\/s/, "", $2); print $2}')
 
 # This can happen for older progs
 if [ -z "$init_speed" ]; then
@@ -76,8 +77,9 @@  echo "$target_speed" > "${devinfo_dir}/scrub_speed_max"
 
 # The second scrub, to check the throttled speed.
 $BTRFS_UTIL_PROG scrub start -B $SCRATCH_MNT >> $seqres.full
-speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT | grep "Rate:" |\
-	     $AWK_PROG '{print $2}' | cut -f1 -d\/)
+speed=$($BTRFS_UTIL_PROG scrub status --raw $SCRATCH_MNT |\
+	tee -a $seqres.full |\
+	$AWK_PROG '$1 == "Rate:" {sub(/\/s/, "", $2); print $2}')
 
 # We gave a +- 10% tolerance for the throttle
 if [ "$speed" -gt "$(( $target_speed * 11 / 10 ))" -o \