-run_check make btrfs-corrupt-block
-
-for i in $(find $here/tests/fsck-tests -name '*.img')
-do
- echo " [TEST] $(basename $i)"
- echo "testing image $i" >> $RESULT
-
- run_check $here/btrfs-image -r $i test.img
-
- $here/btrfsck test.img >> $RESULT 2>&1
- [ $? -eq 0 ] && _fail "btrfsck should have detected corruption"
-
- run_check $here/btrfsck --repair test.img
- run_check $here/btrfsck test.img
-done
-
-# test whether fsck can rebuild a corrupted extent tree
-test_extent_tree_rebuild()
-{
- echo " [TEST] extent tree rebuild"
- $here/mkfs.btrfs -f $TEST_DEV >> /dev/null 2>&1 || _fail "fail to mkfs"
-
- run_check mount $TEST_DEV $TEST_MNT
- cp -aR /lib/modules/`uname -r`/ $TEST_MNT 2>&1
-
- for i in `seq 1 100`;do
- $here/btrfs sub snapshot $TEST_MNT \
- $TEST_MNT/snapaaaaaaa_$i >& /dev/null
- done
- run_check umount $TEST_DEV
-
- # get extent root bytenr
- extent_root_bytenr=`$here/btrfs-debug-tree -r $TEST_DEV | grep extent | awk '{print $7}'`
- if [ -z $extent_root_bytenr ];then
- _fail "fail to get extent root bytenr"
+check_prereq btrfs-corrupt-block
+check_prereq btrfs-image
+check_prereq btrfs
+check_prereq btrfstune
+check_kernel_support
+
+run_one_test() {
+ local testname
+
+ testname="$1"
+ echo " [TEST/fsck] $(basename $testname)"
+ cd "$testname"
+ echo "=== Entering $testname" >> "$RESULTS"
+ if [ -x test.sh ]; then
+ # Type 2
+ ./test.sh
+ if [ $? -ne 0 ]; then
+ if [[ $TEST_LOG =~ dump ]]; then
+ cat "$RESULTS"
+ fi
+ _fail "test failed for case $(basename $testname)"
+ fi
+ else
+ # Type 1
+ check_all_images