3 # loop through all of our bad images and make sure fsck repairs them properly
6 SCRIPT_DIR=$(dirname $(readlink -f "$0"))
7 INTERNAL_BIN=$(readlink -f "$SCRIPT_DIR/../")
8 TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
9 TOP=$(readlink -f "$SCRIPT_DIR/../")
10 if ! [ -f "$TOP/btrfs" ];then
11 TOP=$(dirname `which btrfs`)
13 TEST_DEV=${TEST_DEV:-}
14 RESULTS="$TEST_TOP/fsck-tests-results.txt"
15 IMAGE="$TEST_TOP/test.img"
17 source "$TEST_TOP/common"
29 # test rely on corrupting blocks tool
30 check_prereq btrfs-corrupt-block
31 check_prereq btrfs-image
33 check_prereq btrfstune
40 echo " [TEST/fsck] $(basename $testname)"
42 echo "=== Entering $testname" >> "$RESULTS"
43 if [ -x test.sh ]; then
47 if [[ $TEST_LOG =~ dump ]]; then
50 _fail "test failed for case $(basename $testname)"
59 # Each dir contains one type of error for btrfsck test.
60 # Each dir must be one of the following 2 types:
61 # 1) Only btrfs-image dump
62 # Only contains one or several btrfs-image dumps (.img)
63 # Each image will be tested by generic test routine
64 # (btrfsck --repair and btrfsck).
65 # This is for case that btree-healthy images.
66 # 2) Custom test script
67 # This dir contains test.sh which will do custom image
68 # generation/check/verification.
69 # This is for case btrfs-image can't dump or case needs extra
72 for i in $(find "$TEST_TOP/fsck-tests" -maxdepth 1 -mindepth 1 -type d \
73 ${TEST:+-name "$TEST"} | sort)