diff options
author | David Sterba <dsterba@suse.cz> | 2015-06-02 16:37:20 +0200 |
---|---|---|
committer | David Sterba <dsterba@suse.cz> | 2015-06-02 16:37:20 +0200 |
commit | 1e9a6b698479ad759270270d585a5af36253cc30 (patch) | |
tree | 7584eaaa700f8bc4d7e334086f79a350b460abc4 | |
parent | cf3d13132b92abd9e149f905b06d7a6b61a5d72b (diff) |
btrfs-progs: tests: add misc test for fs features
A sample test for the misc-test category. Verify that btrfstune sets the
requested fs features. Now implemented extrefs, skinny-metadata and
seeding.
Signed-off-by: David Sterba <dsterba@suse.cz>
-rwxr-xr-x | tests/misc-tests/001-btrfstune-features/test.sh | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/tests/misc-tests/001-btrfstune-features/test.sh b/tests/misc-tests/001-btrfstune-features/test.sh new file mode 100755 index 00000000..4ce3411f --- /dev/null +++ b/tests/misc-tests/001-btrfstune-features/test.sh @@ -0,0 +1,56 @@ +#!/bin/bash +# test btrfstune options that enable filesystem features + +source $TOP/tests/common + +check_prereq btrfs-debug-tree +check_prereq btrfs-show-super +check_prereq mkfs.btrfs +setup_root_helper + +if [ -z $TEST_DEV ]; then + echo "\$TEST_DEV not given, use $TOP/test/test.img as fallback" >> \ + $RESULTS + TEST_DEV="$TOP/tests/test.img" + + # Need at least 1G to avoid mixed block group, which extent tree + # rebuild doesn't support. + run_check truncate -s 1G $TEST_DEV +fi + +if [ -z $TEST_MNT ];then + echo " [NOTRUN] extent tree rebuild, need TEST_MNT variant" + exit 0 +fi + +# test whether fsck can rebuild a corrupted extent tree +# parameters: +# - option for mkfs.btrfs -O, empty for defaults +# - option for btrfstune +# - string representing the feature in btrfs-show-super dump +test_feature() +{ + local mkfsfeatures + local tuneopt + local sbflag + + mkfsfeatures=${1:+-O ^$1} + tuneopt="$2" + sbflag="$3" + + run_check $SUDO_HELPER $TOP/mkfs.btrfs -f $mkfsfeatures $TEST_DEV + if run_check_stdout $TOP/btrfs-show-super $TEST_DEV | \ + grep -q "$sbflag"; then + _fail "FAIL: feature $sbflag must not be set on the base image" + fi + run_check $TOP/btrfstune $tuneopt $TEST_DEV + if ! run_check_stdout $TOP/btrfs-show-super $TEST_DEV | \ + grep -q "$sbflag"; then + _fail "FAIL: feature $sbflag not set" + fi + run_check $SUDO_HELPER $TOP/btrfs check $TEST_DEV +} + +test_feature extref -r EXTENDED_IREF +test_feature skinny-metadata -x SKINNY_METADATA +test_feature '' '-S 1' SEEDING |