2013-09-09 20:41:58 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# loop through all of our bad images and make sure fsck repairs them properly
|
|
|
|
#
|
|
|
|
# It's GPL, same as everything else in this tree.
|
|
|
|
#
|
|
|
|
|
2015-04-03 07:01:12 +00:00
|
|
|
unset TOP
|
2014-12-25 01:32:11 +00:00
|
|
|
unset LANG
|
|
|
|
LANG=C
|
2015-05-21 16:48:55 +00:00
|
|
|
SCRIPT_DIR=$(dirname $(readlink -f $0))
|
|
|
|
TOP=$(readlink -f $SCRIPT_DIR/../)
|
2014-12-25 01:32:11 +00:00
|
|
|
TEST_DEV=${TEST_DEV:-}
|
2015-04-03 07:01:12 +00:00
|
|
|
RESULTS="$TOP/tests/fsck-tests-results.txt"
|
2014-12-25 01:32:11 +00:00
|
|
|
|
2015-04-03 07:01:12 +00:00
|
|
|
source $TOP/tests/common
|
2014-12-25 01:32:11 +00:00
|
|
|
|
2015-04-03 07:01:12 +00:00
|
|
|
# Allow child test to use $TOP and $RESULTS
|
|
|
|
export TOP
|
|
|
|
export RESULTS
|
2016-05-11 23:50:36 +00:00
|
|
|
# For custom script needs to verify recovery
|
2014-12-25 01:32:11 +00:00
|
|
|
export LANG
|
2014-12-12 14:49:26 +00:00
|
|
|
|
2015-04-03 07:01:12 +00:00
|
|
|
rm -f $RESULTS
|
2014-05-29 10:01:44 +00:00
|
|
|
|
|
|
|
# test rely on corrupting blocks tool
|
2014-12-12 14:49:26 +00:00
|
|
|
check_prereq btrfs-corrupt-block
|
|
|
|
check_prereq btrfs-image
|
|
|
|
check_prereq btrfs
|
2013-09-09 20:41:58 +00:00
|
|
|
|
2015-07-10 22:31:02 +00:00
|
|
|
run_one_test() {
|
|
|
|
local testname
|
|
|
|
|
|
|
|
testname="$1"
|
2015-11-30 17:13:01 +00:00
|
|
|
echo " [TEST/fsck] $(basename $testname)"
|
2015-07-10 22:31:02 +00:00
|
|
|
cd $testname
|
|
|
|
echo "=== Entering $testname" >> $RESULTS
|
|
|
|
if [ -x test.sh ]; then
|
|
|
|
# Type 2
|
|
|
|
./test.sh
|
|
|
|
if [ $? -ne 0 ]; then
|
|
|
|
_fail "test failed for case $(basename $testname)"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# Type 1
|
|
|
|
check_all_images `pwd`
|
|
|
|
fi
|
|
|
|
cd $TOP
|
|
|
|
}
|
|
|
|
|
2014-12-25 01:32:11 +00:00
|
|
|
# Each dir contains one type of error for btrfsck test.
|
|
|
|
# Each dir must be one of the following 2 types:
|
|
|
|
# 1) Only btrfs-image dump
|
|
|
|
# Only contains one or several btrfs-image dumps (.img)
|
|
|
|
# Each image will be tested by generic test routine
|
|
|
|
# (btrfsck --repair and btrfsck).
|
|
|
|
# This is for case that btree-healthy images.
|
|
|
|
# 2) Custom test script
|
|
|
|
# This dir contains test.sh which will do custom image
|
|
|
|
# generation/check/verification.
|
|
|
|
# This is for case btrfs-image can't dump or case needs extra
|
|
|
|
# check/verify
|
|
|
|
|
2015-07-10 22:38:07 +00:00
|
|
|
for i in $(find $TOP/tests/fsck-tests -maxdepth 1 -mindepth 1 -type d \
|
|
|
|
${TEST:+-name "$TEST"} | sort)
|
2013-09-09 20:41:58 +00:00
|
|
|
do
|
2015-07-10 22:31:02 +00:00
|
|
|
run_one_test "$i"
|
2013-09-09 20:41:58 +00:00
|
|
|
done
|