3 # loop through all of our bad images and make sure fsck repairs them properly
6 SCRIPT_DIR=$(dirname $(readlink -f "$0"))
8 TOP=$(readlink -f "$SCRIPT_DIR/../")
9 if [ -f "$TOP/configure.ac" ]; then
11 TEST_TOP="$TOP/tests/"
14 # external, defaults to system binaries
15 TOP=$(dirname `which btrfs`)
16 TEST_TOP="$SCRIPT_DIR"
17 INTERNAL_BIN="$TEST_TOP"
20 # assume external, TOP set from commandline
21 TEST_TOP="$SCRIPT_DIR"
22 INTERNAL_BIN="$TEST_TOP"
24 if ! [ -x "$TOP/btrfs" ]; then
25 echo "ERROR: cannot execute btrfs from TOP=$TOP"
28 TEST_DEV=${TEST_DEV:-}
29 RESULTS="$TEST_TOP/fsck-tests-results.txt"
30 IMAGE="$TEST_TOP/test.img"
32 source "$TEST_TOP/common"
44 # test rely on corrupting blocks tool
45 check_prereq btrfs-corrupt-block
46 check_prereq btrfs-image
48 check_prereq btrfstune
55 echo " [TEST/fsck] $(basename $testname)"
57 echo "=== Entering $testname" >> "$RESULTS"
58 if [ -x test.sh ]; then
62 if [[ $TEST_LOG =~ dump ]]; then
65 _fail "test failed for case $(basename $testname)"
74 # Each dir contains one type of error for btrfsck test.
75 # Each dir must be one of the following 2 types:
76 # 1) Only btrfs-image dump
77 # Only contains one or several btrfs-image dumps (.img)
78 # Each image will be tested by generic test routine
79 # (btrfsck --repair and btrfsck).
80 # This is for case that btree-healthy images.
81 # 2) Custom test script
82 # This dir contains test.sh which will do custom image
83 # generation/check/verification.
84 # This is for case btrfs-image can't dump or case needs extra
87 for i in $(find "$TEST_TOP/fsck-tests" -maxdepth 1 -mindepth 1 -type d \
88 ${TEST:+-name "$TEST"} | sort)