[2/2] btrfs-progs: convert-test: Add test for converting ext* with regular file extent.
diff mbox

Message ID 1427941296-19502-2-git-send-email-quwenruo@cn.fujitsu.com
State New, archived
Headers show

Commit Message

Qu Wenruo April 2, 2015, 2:21 a.m. UTC
Before previous patch, btrfs-convert will result fsck complain if there
is any regular file extent in newly converted btrfs.

Add test case for it.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
---
 tests/convert-tests.sh | 85 ++++++++++++++++++++++++++++++++------------------
 1 file changed, 55 insertions(+), 30 deletions(-)

Comments

David Sterba April 2, 2015, 3:45 p.m. UTC | #1
On Thu, Apr 02, 2015 at 10:21:36AM +0800, Qu Wenruo wrote:
> Before previous patch, btrfs-convert will result fsck complain if there
> is any regular file extent in newly converted btrfs.
> 
> Add test case for it.

Please separate the changes that update generic code and the test
itself.

> +script_dir=$(dirname $(realpath $0))
> +top=$(realpath $script_dir/../)

Please use upper case names.

> +TEST_DEV=${TEST_DEV:-}
> +TEST_MNT=${TEST_MNT:-$top/tests/mnt}
> +RESULT="$top/tests/convert-tests-results.txt"

RESULTS

> +IMAGE="$script_dir/test.img"
>  
> -_fail()
> -{
> -	echo "$*" | tee -a convert-tests-results.txt
> -	exit 1
> -}
> +source $top/tests/common
> +export top
> +export RESULT
> +# For comprehensive convert test which needs write something into ext*
> +export TEST_MNT
> +export LANG
> +
> +rm -f $RESULT
> +mkdir -p $TEST_MNT || _fail "unable to create mount point on $TEST_MNT"
> +
> +# test reply on btrfs-convert
> +check_prereq btrfs-convert
> +check_prereq btrfs
>  
> -rm -f convert-tests-results.txt
>  
> -test(){
> +convert_test(){
>  	echo "    [TEST]   $1"
>  	nodesize=$2
>  	shift 2
> -	echo "creating ext image with: $*" >> convert-tests-results.txt
> +	echo "creating ext image with: $*" >> $RESULT
>  	# 256MB is the smallest acceptable btrfs image.
> -	rm -f $here/test.img >> convert-tests-results.txt 2>&1 \
> +	rm -f $IMAGE >> $RESULT 2>&1 \
>  		|| _fail "could not remove test image file"
> -	truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1 \
> +	truncate -s 256M $IMAGE >> $RESULT 2>&1 \
>  		|| _fail "could not create test image file"
> -	$* -F $here/test.img >> convert-tests-results.txt 2>&1 \
> +	$* -F $IMAGE >> $RESULT 2>&1 \
>  		|| _fail "filesystem create failed"
> -	$here/btrfs-convert -N "$nodesize" $here/test.img \
> -			>> convert-tests-results.txt 2>&1 \
> +
> +	# write a file with regular file extent
> +	$SUDO_HELPER mount $IMAGE $TEST_MNT
> +	$SUDO_HELPER dd if=/dev/zero bs=$nodesize count=4 of=$TEST_MNT/test \
> +		1>/dev/null 2>&1
> +	$SUDO_HELPER umount $TEST_MNT
> +
> +	# do convert test
> +	$top/btrfs-convert -N "$nodesize" $script_dir/test.img \

$IMAGE instead of "$script_dir/test.img"

> +			>> $RESULT 2>&1 \
>  		|| _fail "btrfs-convert failed"
> -	$here/btrfs check $here/test.img >> convert-tests-results.txt 2>&1 \

same here

> +	$top/btrfs check $script_dir/test.img >> $RESULT 2>&1 \

and here

>  		|| _fail "btrfs check detected errors"

Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Qu Wenruo April 3, 2015, 12:42 a.m. UTC | #2
-------- Original Message  --------
Subject: Re: [PATCH 2/2] btrfs-progs: convert-test: Add test for 
converting ext* with regular file extent.
From: David Sterba <dsterba@suse.cz>
To: Qu Wenruo <quwenruo@cn.fujitsu.com>
Date: 2015?04?02? 23:45

> On Thu, Apr 02, 2015 at 10:21:36AM +0800, Qu Wenruo wrote:
>> Before previous patch, btrfs-convert will result fsck complain if there
>> is any regular file extent in newly converted btrfs.
>>
>> Add test case for it.
>
> Please separate the changes that update generic code and the test
> itself.
OK, I'll update it soon.
>
>> +script_dir=$(dirname $(realpath $0))
>> +top=$(realpath $script_dir/../)
>
> Please use upper case names.
Some fsck-tests use lower case names, I'll update them too.

Thanks,
Qu
>
>> +TEST_DEV=${TEST_DEV:-}
>> +TEST_MNT=${TEST_MNT:-$top/tests/mnt}
>> +RESULT="$top/tests/convert-tests-results.txt"
>
> RESULTS
>
>> +IMAGE="$script_dir/test.img"
>>
>> -_fail()
>> -{
>> -	echo "$*" | tee -a convert-tests-results.txt
>> -	exit 1
>> -}
>> +source $top/tests/common
>> +export top
>> +export RESULT
>> +# For comprehensive convert test which needs write something into ext*
>> +export TEST_MNT
>> +export LANG
>> +
>> +rm -f $RESULT
>> +mkdir -p $TEST_MNT || _fail "unable to create mount point on $TEST_MNT"
>> +
>> +# test reply on btrfs-convert
>> +check_prereq btrfs-convert
>> +check_prereq btrfs
>>
>> -rm -f convert-tests-results.txt
>>
>> -test(){
>> +convert_test(){
>>   	echo "    [TEST]   $1"
>>   	nodesize=$2
>>   	shift 2
>> -	echo "creating ext image with: $*" >> convert-tests-results.txt
>> +	echo "creating ext image with: $*" >> $RESULT
>>   	# 256MB is the smallest acceptable btrfs image.
>> -	rm -f $here/test.img >> convert-tests-results.txt 2>&1 \
>> +	rm -f $IMAGE >> $RESULT 2>&1 \
>>   		|| _fail "could not remove test image file"
>> -	truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1 \
>> +	truncate -s 256M $IMAGE >> $RESULT 2>&1 \
>>   		|| _fail "could not create test image file"
>> -	$* -F $here/test.img >> convert-tests-results.txt 2>&1 \
>> +	$* -F $IMAGE >> $RESULT 2>&1 \
>>   		|| _fail "filesystem create failed"
>> -	$here/btrfs-convert -N "$nodesize" $here/test.img \
>> -			>> convert-tests-results.txt 2>&1 \
>> +
>> +	# write a file with regular file extent
>> +	$SUDO_HELPER mount $IMAGE $TEST_MNT
>> +	$SUDO_HELPER dd if=/dev/zero bs=$nodesize count=4 of=$TEST_MNT/test \
>> +		1>/dev/null 2>&1
>> +	$SUDO_HELPER umount $TEST_MNT
>> +
>> +	# do convert test
>> +	$top/btrfs-convert -N "$nodesize" $script_dir/test.img \
>
> $IMAGE instead of "$script_dir/test.img"
>
>> +			>> $RESULT 2>&1 \
>>   		|| _fail "btrfs-convert failed"
>> -	$here/btrfs check $here/test.img >> convert-tests-results.txt 2>&1 \
>
> same here
>
>> +	$top/btrfs check $script_dir/test.img >> $RESULT 2>&1 \
>
> and here
>
>>   		|| _fail "btrfs check detected errors"
>
> Thanks.
>
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/tests/convert-tests.sh b/tests/convert-tests.sh
index f6b919d..5c4f22e 100644
--- a/tests/convert-tests.sh
+++ b/tests/convert-tests.sh
@@ -4,48 +4,73 @@ 
 # clean.
 #
 
-here=`pwd`
+unset top
+unset LANG
+LANG=C
+script_dir=$(dirname $(realpath $0))
+top=$(realpath $script_dir/../)
+TEST_DEV=${TEST_DEV:-}
+TEST_MNT=${TEST_MNT:-$top/tests/mnt}
+RESULT="$top/tests/convert-tests-results.txt"
+IMAGE="$script_dir/test.img"
 
-_fail()
-{
-	echo "$*" | tee -a convert-tests-results.txt
-	exit 1
-}
+source $top/tests/common
+export top
+export RESULT
+# For comprehensive convert test which needs write something into ext*
+export TEST_MNT
+export LANG
+
+rm -f $RESULT
+mkdir -p $TEST_MNT || _fail "unable to create mount point on $TEST_MNT"
+
+# test reply on btrfs-convert
+check_prereq btrfs-convert
+check_prereq btrfs
 
-rm -f convert-tests-results.txt
 
-test(){
+convert_test(){
 	echo "    [TEST]   $1"
 	nodesize=$2
 	shift 2
-	echo "creating ext image with: $*" >> convert-tests-results.txt
+	echo "creating ext image with: $*" >> $RESULT
 	# 256MB is the smallest acceptable btrfs image.
-	rm -f $here/test.img >> convert-tests-results.txt 2>&1 \
+	rm -f $IMAGE >> $RESULT 2>&1 \
 		|| _fail "could not remove test image file"
-	truncate -s 256M $here/test.img >> convert-tests-results.txt 2>&1 \
+	truncate -s 256M $IMAGE >> $RESULT 2>&1 \
 		|| _fail "could not create test image file"
-	$* -F $here/test.img >> convert-tests-results.txt 2>&1 \
+	$* -F $IMAGE >> $RESULT 2>&1 \
 		|| _fail "filesystem create failed"
-	$here/btrfs-convert -N "$nodesize" $here/test.img \
-			>> convert-tests-results.txt 2>&1 \
+
+	# write a file with regular file extent
+	$SUDO_HELPER mount $IMAGE $TEST_MNT
+	$SUDO_HELPER dd if=/dev/zero bs=$nodesize count=4 of=$TEST_MNT/test \
+		1>/dev/null 2>&1
+	$SUDO_HELPER umount $TEST_MNT
+
+	# do convert test
+	$top/btrfs-convert -N "$nodesize" $script_dir/test.img \
+			>> $RESULT 2>&1 \
 		|| _fail "btrfs-convert failed"
-	$here/btrfs check $here/test.img >> convert-tests-results.txt 2>&1 \
+	$top/btrfs check $script_dir/test.img >> $RESULT 2>&1 \
 		|| _fail "btrfs check detected errors"
 }
 
+setup_root_helper
+
 # btrfs-convert requires 4k blocksize.
-test "ext2 4k nodesize" 4096 mke2fs -b 4096
-test "ext3 4k nodesize" 4096 mke2fs -j -b 4096
-test "ext4 4k nodesize" 4096 mke2fs -t ext4 -b 4096
-test "ext2 8k nodesize" 8192 mke2fs -b 4096
-test "ext3 8k nodesize" 8192 mke2fs -j -b 4096
-test "ext4 8k nodesize" 8192 mke2fs -t ext4 -b 4096
-test "ext2 16k nodesize" 16384 mke2fs -b 4096
-test "ext3 16k nodesize" 16384 mke2fs -j -b 4096
-test "ext4 16k nodesize" 16384 mke2fs -t ext4 -b 4096
-test "ext2 32k nodesize" 32768 mke2fs -b 4096
-test "ext3 32k nodesize" 32768 mke2fs -j -b 4096
-test "ext4 32k nodesize" 32768 mke2fs -t ext4 -b 4096
-test "ext2 64k nodesize" 65536 mke2fs -b 4096
-test "ext3 64k nodesize" 65536 mke2fs -j -b 4096
-test "ext4 64k nodesize" 65536 mke2fs -t ext4 -b 4096
+convert_test "ext2 4k nodesize" 4096 mke2fs -b 4096
+convert_test "ext3 4k nodesize" 4096 mke2fs -j -b 4096
+convert_test "ext4 4k nodesize" 4096 mke2fs -t ext4 -b 4096
+convert_test "ext2 8k nodesize" 8192 mke2fs -b 4096
+convert_test "ext3 8k nodesize" 8192 mke2fs -j -b 4096
+convert_test "ext4 8k nodesize" 8192 mke2fs -t ext4 -b 4096
+convert_test "ext2 16k nodesize" 16384 mke2fs -b 4096
+convert_test "ext3 16k nodesize" 16384 mke2fs -j -b 4096
+convert_test "ext4 16k nodesize" 16384 mke2fs -t ext4 -b 4096
+convert_test "ext2 32k nodesize" 32768 mke2fs -b 4096
+convert_test "ext3 32k nodesize" 32768 mke2fs -j -b 4096
+convert_test "ext4 32k nodesize" 32768 mke2fs -t ext4 -b 4096
+convert_test "ext2 64k nodesize" 65536 mke2fs -b 4096
+convert_test "ext3 64k nodesize" 65536 mke2fs -j -b 4096
+convert_test "ext4 64k nodesize" 65536 mke2fs -t ext4 -b 4096