e3da3949031c3d4d654c2c82099801643f8dbcdb
[platform/upstream/btrfs-progs.git] / tests / misc-tests / 001-btrfstune-features / test.sh
1 #!/bin/bash
2 # test btrfstune options that enable filesystem features
3
4 source "$TEST_TOP/common"
5
6 check_prereq mkfs.btrfs
7 check_prereq btrfstune
8 check_prereq btrfs
9
10 setup_root_helper
11 prepare_test_dev
12
13 # test whether fsck can rebuild a corrupted extent tree
14 # parameters:
15 # - option for mkfs.btrfs -O, empty for defaults
16 # - option for btrfstune
17 # - string representing the feature in dump-super output
18 test_feature()
19 {
20         local mkfsfeatures
21         local tuneopt
22         local sbflag
23
24         mkfsfeatures=$1
25         tuneopt="$2"
26         sbflag="$3"
27
28         run_check $SUDO_HELPER "$TOP/mkfs.btrfs" -f \
29                 ${mkfsfeatures:+-O ^"$mkfsfeatures"} "$TEST_DEV"
30         if run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \
31                         grep -q "$sbflag"; then
32                 _fail "FAIL: feature $sbflag must not be set on the base image"
33         fi
34         run_check "$TOP/btrfstune" "$tuneopt" "$TEST_DEV"
35         if ! run_check_stdout "$TOP/btrfs" inspect-internal dump-super "$TEST_DEV" | \
36                         grep -q "$sbflag"; then
37                 _fail "FAIL: feature $sbflag not set"
38         fi
39         run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
40 }
41
42 test_feature extref -r EXTENDED_IREF
43 test_feature skinny-metadata -x SKINNY_METADATA
44 test_feature no-holes -n NO_HOLES
45 test_feature '' '-S 1' SEEDING