mirror of
https://github.com/kdave/btrfs-progs
synced 2025-02-28 07:50:32 +00:00
For example, $TEST_DIR is common used in severial tests, and have duplicated code for initialize. These duplicated code not only benifits harddisk vendor, but have inconsistent details, as: convert-tests.sh: lack of mkdir fsck-tests/012-leaf-corruption/test.sh: unnecessary mkdir fsck-tests/013-extent-tree-rebuild/test.sh: unnecessary init misc-tests/XXX ... And severial error message: _fail "unable to create mount point on $TEST_MNT" _fail "failed to create mount point" ... This patch move initizlizaton of $TEST_DIR to common init_env(), to avoid above problem, and init_env() can be used to add more things in future. Signed-off-by: Zhao Lei <zhaolei@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.com>
44 lines
1.1 KiB
Bash
Executable File
44 lines
1.1 KiB
Bash
Executable File
#!/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
|
|
prepare_test_dev
|
|
|
|
# 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 no-holes -n NO_HOLES
|
|
test_feature '' '-S 1' SEEDING
|