btrfs-progs: tests: mkfs, check sectorsize and nodesize combinations

Add mkfs selftest for invalid and valid sectorsize/nodesize
combinations.

Signed-off-by: Qu Wenruo <quwenruo@cn.fujitsu.com>
[ switched to TEST_DEV ]
Signed-off-by: David Sterba <dsterba@suse.com>
master
Qu Wenruo 2015-11-30 09:39:30 +08:00 committed by David Sterba
parent f25142f2d0
commit 16e240eca7
1 changed files with 49 additions and 0 deletions

View File

@ -0,0 +1,49 @@
#!/bin/bash
# test various sectorsize and node size combinations
# including valid and invalid ones
# only do mkfs and fsck check, no mounting as
# sub/multi-pagesize is not supported yet
source $TOP/tests/common
check_prereq mkfs.btrfs
check_prereq btrfs
prepare_test_dev
# disable mixed bg to avoid sectorsize == nodesize check
features="^mixed-bg"
# caller need to check whether the combination is valid
do_test()
{
sectorsize=$1
nodesize=$2
run_mayfail $TOP/mkfs.btrfs -O $features -n $nodesize -s $sectorsize \
$TEST_DEV
ret=$?
if [ $ret == 0 ]; then
run_check $TOP/btrfs check $TEST_DEV
fi
return $ret
}
# Invalid: Unaligned sectorsize and nodesize
do_test 8191 8191 && _fail
# Invalid: Aligned sectorsize with unaligned nodesize
do_test 4k 16385 && _fail
# Invalid: Ungliend sectorsize with aligned nodesize
do_test 8191 16k && _fail
# Valid: Aligned sectorsize and nodesize
do_test 4k 16k || _fail
# Invalid: Sectorsize larger than nodesize
do_test 8k 4k && _fail
# Invalid: too large nodesize
do_test 16k 128k && _fail
# Valid: large sectorsize
do_test 64k 64k || _fail