diff mbox series

btrfs/125 197 198: cleanup using SCRATCH_DEV_NAME

Message ID 703aa9f2e34bf4dcc1fc5eec7ef4f65a6705ff14.1712634550.git.anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series btrfs/125 197 198: cleanup using SCRATCH_DEV_NAME | expand

Commit Message

Anand Jain April 9, 2024, 3:51 a.m. UTC
Use SCRATCH_DEV_NAME[n] to provide the device path for each device from
the scratch device pool. Also, in btrfs/197, remove common/filter since
it calls common/filter.btrfs.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
There are other test cases that potentially could use SCRATCH_DEV_NAME,
but for now, only 3 of those are being fixed.

 tests/btrfs/125 |  6 +++---
 tests/btrfs/197 | 13 +++++--------
 tests/btrfs/198 | 12 +++++-------
 3 files changed, 13 insertions(+), 18 deletions(-)

Comments

David Disseldorp April 9, 2024, 4:30 a.m. UTC | #1
On Tue,  9 Apr 2024 11:51:11 +0800, Anand Jain wrote:

> Use SCRATCH_DEV_NAME[n] to provide the device path for each device from
> the scratch device pool. Also, in btrfs/197, remove common/filter since
> it calls common/filter.btrfs.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Looks good.
Reviewed-by: David Disseldorp <ddiss@suse.de>
Zorro Lang April 13, 2024, 7:40 p.m. UTC | #2
On Tue, Apr 09, 2024 at 11:51:11AM +0800, Anand Jain wrote:
> Use SCRATCH_DEV_NAME[n] to provide the device path for each device from
> the scratch device pool. Also, in btrfs/197, remove common/filter since
> it calls common/filter.btrfs.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>
> ---
> There are other test cases that potentially could use SCRATCH_DEV_NAME,
> but for now, only 3 of those are being fixed.

Hi Anand,

This patch can't be merged, failed as:
  Applying: btrfs/125 197 198: cleanup using SCRATCH_DEV_NAME
  error: patch failed: tests/btrfs/197:55
  error: tests/btrfs/197: patch does not apply
  error: patch failed: tests/btrfs/198:40
  error: tests/btrfs/198: patch does not apply
  Patch failed at 0001 btrfs/125 197 198: cleanup using SCRATCH_DEV_NAME

I'll leave this patch to your next PR, please check and rebase it properly.

Thanks,
Zorro

> 
>  tests/btrfs/125 |  6 +++---
>  tests/btrfs/197 | 13 +++++--------
>  tests/btrfs/198 | 12 +++++-------
>  3 files changed, 13 insertions(+), 18 deletions(-)
> 
> diff --git a/tests/btrfs/125 b/tests/btrfs/125
> index d957c13911b4..f742d14f858c 100755
> --- a/tests/btrfs/125
> +++ b/tests/btrfs/125
> @@ -45,9 +45,9 @@ _require_btrfs_raid_type raid5
>  
>  _scratch_dev_pool_get 3
>  
> -dev1=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
> -dev2=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
> -dev3=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`
> +dev1=${SCRATCH_DEV_NAME[0]}
> +dev2=${SCRATCH_DEV_NAME[1]}
> +dev3=${SCRATCH_DEV_NAME[2]}
>  
>  echo dev1=$dev1 >> $seqres.full
>  echo dev2=$dev2 >> $seqres.full
> diff --git a/tests/btrfs/197 b/tests/btrfs/197
> index 9ec4e9f052ba..196110cbdad2 100755
> --- a/tests/btrfs/197
> +++ b/tests/btrfs/197
> @@ -22,7 +22,6 @@ _cleanup()
>  }
>  
>  # Import common functions.
> -. ./common/filter
>  . ./common/filter.btrfs
>  
>  # real QA test starts here
> @@ -55,24 +54,22 @@ workout()
>  	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
>  							_fail "mkfs failed"
>  
> -	# Make device_1 an alien btrfs device for the raid created above by
> +	# Make device # 2 an alien btrfs device for the raid created above by
>  	# adding it to the $TEST_DIR/$seq.mnt
>  
>  	# don't test with the first device as auto fs check (_check_scratch_fs)
>  	# picks the first device
> -	device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
> -	$BTRFS_UTIL_PROG device add -f "$device_1" "$TEST_DIR/$seq.mnt" >> \
> +	$BTRFS_UTIL_PROG device add -f "${SCRATCH_DEV_NAME[1]}" "$TEST_DIR/$seq.mnt" >> \
>  		$seqres.full
>  
> -	device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
> -	_mount -o degraded $device_2 $SCRATCH_MNT
> +	_mount -o degraded ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
>  	# Check if missing device is reported as in the .out
>  	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
>  		_filter_btrfs_filesystem_show > $tmp.output 2>&1
>  	cat $tmp.output >> $seqres.full
> -	grep -q "$device_1" $tmp.output && _fail "found stale device"
> +	grep -q "${SCRATCH_DEV_NAME[1]}" $tmp.output && _fail "found stale device"
>  
> -	$BTRFS_UTIL_PROG device remove "$device_1" "$TEST_DIR/$seq.mnt"
> +	$BTRFS_UTIL_PROG device remove "${SCRATCH_DEV_NAME[1]}" "$TEST_DIR/$seq.mnt"
>  	$UMOUNT_PROG $TEST_DIR/$seq.mnt
>  	_scratch_unmount
>  	_spare_dev_put
> diff --git a/tests/btrfs/198 b/tests/btrfs/198
> index c5a8f39217d3..ad43b4d1b59b 100755
> --- a/tests/btrfs/198
> +++ b/tests/btrfs/198
> @@ -40,21 +40,19 @@ workout()
>  	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
>  							_fail "mkfs failed"
>  
> -	# Make device_1 a free btrfs device for the raid created above by
> -	# clearing its superblock
> +	# Make ${SCRATCH_DEV_NAME[1]} a free btrfs device for the raid created
> +	# above by clearing its superblock
>  
>  	# don't test with the first device as auto fs check (_check_scratch_fs)
>  	# picks the first device
> -	device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
> -	$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1
> +	$WIPEFS_PROG -a ${SCRATCH_DEV_NAME[1]} >> $seqres.full 2>&1
>  
> -	device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
> -	_mount -o degraded $device_2 $SCRATCH_MNT
> +	_mount -o degraded ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
>  	# Check if missing device is reported as in the 196.out
>  	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
>  		_filter_btrfs_filesystem_show > $tmp.output 2>&1
>  	cat $tmp.output >> $seqres.full
> -	grep -q "$device_1" $tmp.output && _fail "found stale device"
> +	grep -q "${SCRATCH_DEV_NAME[1]}" $tmp.output && _fail "found stale device"
>  
>  	_scratch_unmount
>  	_scratch_dev_pool_put
> -- 
> 2.39.3
> 
>
Anand Jain April 13, 2024, 11:17 p.m. UTC | #3
On 4/14/24 03:40, Zorro Lang wrote:
> On Tue, Apr 09, 2024 at 11:51:11AM +0800, Anand Jain wrote:
>> Use SCRATCH_DEV_NAME[n] to provide the device path for each device from
>> the scratch device pool. Also, in btrfs/197, remove common/filter since
>> it calls common/filter.btrfs.
>>
>> Signed-off-by: Anand Jain <anand.jain@oracle.com>
>> ---
>> There are other test cases that potentially could use SCRATCH_DEV_NAME,
>> but for now, only 3 of those are being fixed.
> 
> Hi Anand,
> 
> This patch can't be merged, failed as:
>    Applying: btrfs/125 197 198: cleanup using SCRATCH_DEV_NAME
>    error: patch failed: tests/btrfs/197:55
>    error: tests/btrfs/197: patch does not apply
>    error: patch failed: tests/btrfs/198:40
>    error: tests/btrfs/198: patch does not apply
>    Patch failed at 0001 btrfs/125 197 198: cleanup using SCRATCH_DEV_NAME
> 
> I'll leave this patch to your next PR, please check and rebase it properly.
> 

Sure. This patch is on top of the patch-set below, which is in my 
upcoming PR.
  [PATCH v2 0/3] fstests: various RAID56 related fixes for btrfs


Thanks, Anand

> Thanks,
> Zorro
> 
>>
>>   tests/btrfs/125 |  6 +++---
>>   tests/btrfs/197 | 13 +++++--------
>>   tests/btrfs/198 | 12 +++++-------
>>   3 files changed, 13 insertions(+), 18 deletions(-)
>>
>> diff --git a/tests/btrfs/125 b/tests/btrfs/125
>> index d957c13911b4..f742d14f858c 100755
>> --- a/tests/btrfs/125
>> +++ b/tests/btrfs/125
>> @@ -45,9 +45,9 @@ _require_btrfs_raid_type raid5
>>   
>>   _scratch_dev_pool_get 3
>>   
>> -dev1=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
>> -dev2=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
>> -dev3=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`
>> +dev1=${SCRATCH_DEV_NAME[0]}
>> +dev2=${SCRATCH_DEV_NAME[1]}
>> +dev3=${SCRATCH_DEV_NAME[2]}
>>   
>>   echo dev1=$dev1 >> $seqres.full
>>   echo dev2=$dev2 >> $seqres.full
>> diff --git a/tests/btrfs/197 b/tests/btrfs/197
>> index 9ec4e9f052ba..196110cbdad2 100755
>> --- a/tests/btrfs/197
>> +++ b/tests/btrfs/197
>> @@ -22,7 +22,6 @@ _cleanup()
>>   }
>>   
>>   # Import common functions.
>> -. ./common/filter
>>   . ./common/filter.btrfs
>>   
>>   # real QA test starts here
>> @@ -55,24 +54,22 @@ workout()
>>   	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
>>   							_fail "mkfs failed"
>>   
>> -	# Make device_1 an alien btrfs device for the raid created above by
>> +	# Make device # 2 an alien btrfs device for the raid created above by
>>   	# adding it to the $TEST_DIR/$seq.mnt
>>   
>>   	# don't test with the first device as auto fs check (_check_scratch_fs)
>>   	# picks the first device
>> -	device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
>> -	$BTRFS_UTIL_PROG device add -f "$device_1" "$TEST_DIR/$seq.mnt" >> \
>> +	$BTRFS_UTIL_PROG device add -f "${SCRATCH_DEV_NAME[1]}" "$TEST_DIR/$seq.mnt" >> \
>>   		$seqres.full
>>   
>> -	device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
>> -	_mount -o degraded $device_2 $SCRATCH_MNT
>> +	_mount -o degraded ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
>>   	# Check if missing device is reported as in the .out
>>   	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
>>   		_filter_btrfs_filesystem_show > $tmp.output 2>&1
>>   	cat $tmp.output >> $seqres.full
>> -	grep -q "$device_1" $tmp.output && _fail "found stale device"
>> +	grep -q "${SCRATCH_DEV_NAME[1]}" $tmp.output && _fail "found stale device"
>>   
>> -	$BTRFS_UTIL_PROG device remove "$device_1" "$TEST_DIR/$seq.mnt"
>> +	$BTRFS_UTIL_PROG device remove "${SCRATCH_DEV_NAME[1]}" "$TEST_DIR/$seq.mnt"
>>   	$UMOUNT_PROG $TEST_DIR/$seq.mnt
>>   	_scratch_unmount
>>   	_spare_dev_put
>> diff --git a/tests/btrfs/198 b/tests/btrfs/198
>> index c5a8f39217d3..ad43b4d1b59b 100755
>> --- a/tests/btrfs/198
>> +++ b/tests/btrfs/198
>> @@ -40,21 +40,19 @@ workout()
>>   	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
>>   							_fail "mkfs failed"
>>   
>> -	# Make device_1 a free btrfs device for the raid created above by
>> -	# clearing its superblock
>> +	# Make ${SCRATCH_DEV_NAME[1]} a free btrfs device for the raid created
>> +	# above by clearing its superblock
>>   
>>   	# don't test with the first device as auto fs check (_check_scratch_fs)
>>   	# picks the first device
>> -	device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
>> -	$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1
>> +	$WIPEFS_PROG -a ${SCRATCH_DEV_NAME[1]} >> $seqres.full 2>&1
>>   
>> -	device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
>> -	_mount -o degraded $device_2 $SCRATCH_MNT
>> +	_mount -o degraded ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
>>   	# Check if missing device is reported as in the 196.out
>>   	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
>>   		_filter_btrfs_filesystem_show > $tmp.output 2>&1
>>   	cat $tmp.output >> $seqres.full
>> -	grep -q "$device_1" $tmp.output && _fail "found stale device"
>> +	grep -q "${SCRATCH_DEV_NAME[1]}" $tmp.output && _fail "found stale device"
>>   
>>   	_scratch_unmount
>>   	_scratch_dev_pool_put
>> -- 
>> 2.39.3
>>
>>
>
diff mbox series

Patch

diff --git a/tests/btrfs/125 b/tests/btrfs/125
index d957c13911b4..f742d14f858c 100755
--- a/tests/btrfs/125
+++ b/tests/btrfs/125
@@ -45,9 +45,9 @@  _require_btrfs_raid_type raid5
 
 _scratch_dev_pool_get 3
 
-dev1=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}'`
-dev2=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}'`
-dev3=`echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $3}'`
+dev1=${SCRATCH_DEV_NAME[0]}
+dev2=${SCRATCH_DEV_NAME[1]}
+dev3=${SCRATCH_DEV_NAME[2]}
 
 echo dev1=$dev1 >> $seqres.full
 echo dev2=$dev2 >> $seqres.full
diff --git a/tests/btrfs/197 b/tests/btrfs/197
index 9ec4e9f052ba..196110cbdad2 100755
--- a/tests/btrfs/197
+++ b/tests/btrfs/197
@@ -22,7 +22,6 @@  _cleanup()
 }
 
 # Import common functions.
-. ./common/filter
 . ./common/filter.btrfs
 
 # real QA test starts here
@@ -55,24 +54,22 @@  workout()
 	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
 							_fail "mkfs failed"
 
-	# Make device_1 an alien btrfs device for the raid created above by
+	# Make device # 2 an alien btrfs device for the raid created above by
 	# adding it to the $TEST_DIR/$seq.mnt
 
 	# don't test with the first device as auto fs check (_check_scratch_fs)
 	# picks the first device
-	device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
-	$BTRFS_UTIL_PROG device add -f "$device_1" "$TEST_DIR/$seq.mnt" >> \
+	$BTRFS_UTIL_PROG device add -f "${SCRATCH_DEV_NAME[1]}" "$TEST_DIR/$seq.mnt" >> \
 		$seqres.full
 
-	device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
-	_mount -o degraded $device_2 $SCRATCH_MNT
+	_mount -o degraded ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
 	# Check if missing device is reported as in the .out
 	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
 		_filter_btrfs_filesystem_show > $tmp.output 2>&1
 	cat $tmp.output >> $seqres.full
-	grep -q "$device_1" $tmp.output && _fail "found stale device"
+	grep -q "${SCRATCH_DEV_NAME[1]}" $tmp.output && _fail "found stale device"
 
-	$BTRFS_UTIL_PROG device remove "$device_1" "$TEST_DIR/$seq.mnt"
+	$BTRFS_UTIL_PROG device remove "${SCRATCH_DEV_NAME[1]}" "$TEST_DIR/$seq.mnt"
 	$UMOUNT_PROG $TEST_DIR/$seq.mnt
 	_scratch_unmount
 	_spare_dev_put
diff --git a/tests/btrfs/198 b/tests/btrfs/198
index c5a8f39217d3..ad43b4d1b59b 100755
--- a/tests/btrfs/198
+++ b/tests/btrfs/198
@@ -40,21 +40,19 @@  workout()
 	_scratch_pool_mkfs "-d$raid -m$raid" >> $seqres.full 2>&1 || \
 							_fail "mkfs failed"
 
-	# Make device_1 a free btrfs device for the raid created above by
-	# clearing its superblock
+	# Make ${SCRATCH_DEV_NAME[1]} a free btrfs device for the raid created
+	# above by clearing its superblock
 
 	# don't test with the first device as auto fs check (_check_scratch_fs)
 	# picks the first device
-	device_1=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $2}')
-	$WIPEFS_PROG -a $device_1 >> $seqres.full 2>&1
+	$WIPEFS_PROG -a ${SCRATCH_DEV_NAME[1]} >> $seqres.full 2>&1
 
-	device_2=$(echo $SCRATCH_DEV_POOL | $AWK_PROG '{print $1}')
-	_mount -o degraded $device_2 $SCRATCH_MNT
+	_mount -o degraded ${SCRATCH_DEV_NAME[0]} $SCRATCH_MNT
 	# Check if missing device is reported as in the 196.out
 	$BTRFS_UTIL_PROG filesystem show -m $SCRATCH_MNT | \
 		_filter_btrfs_filesystem_show > $tmp.output 2>&1
 	cat $tmp.output >> $seqres.full
-	grep -q "$device_1" $tmp.output && _fail "found stale device"
+	grep -q "${SCRATCH_DEV_NAME[1]}" $tmp.output && _fail "found stale device"
 
 	_scratch_unmount
 	_scratch_dev_pool_put