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