2014-05-21 17:20:27 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# convert ext2/3/4 images to btrfs images, and make sure the results are
|
|
|
|
# clean.
|
|
|
|
|
2015-04-03 07:01:16 +00:00
|
|
|
LANG=C
|
2016-11-11 09:12:05 +00:00
|
|
|
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
2018-02-08 17:34:40 +00:00
|
|
|
if [ -z "$TOP" ]; then
|
|
|
|
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
|
|
|
if [ -f "$TOP/configure.ac" ]; then
|
|
|
|
# inside git
|
2020-04-03 02:10:41 +00:00
|
|
|
TEST_TOP="$TOP/tests"
|
2018-02-08 17:34:40 +00:00
|
|
|
INTERNAL_BIN="$TOP"
|
|
|
|
else
|
|
|
|
# external, defaults to system binaries
|
2021-02-05 13:23:11 +00:00
|
|
|
TOP=$(dirname `type -p btrfs`)
|
2018-02-08 17:34:40 +00:00
|
|
|
TEST_TOP="$SCRIPT_DIR"
|
|
|
|
INTERNAL_BIN="$TEST_TOP"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
# assume external, TOP set from commandline
|
|
|
|
TEST_TOP="$SCRIPT_DIR"
|
|
|
|
INTERNAL_BIN="$TEST_TOP"
|
|
|
|
fi
|
|
|
|
if ! [ -x "$TOP/btrfs" ]; then
|
|
|
|
echo "ERROR: cannot execute btrfs from TOP=$TOP"
|
|
|
|
exit 1
|
2018-02-08 06:34:19 +00:00
|
|
|
fi
|
2016-06-03 13:54:32 +00:00
|
|
|
TEST_DEV=${TEST_DEV:-}
|
2018-02-08 06:34:19 +00:00
|
|
|
RESULTS="$TEST_TOP/convert-tests-results.txt"
|
|
|
|
IMAGE="$TEST_TOP/test.img"
|
2014-05-21 17:20:27 +00:00
|
|
|
|
2018-02-08 06:34:19 +00:00
|
|
|
source "$TEST_TOP/common"
|
|
|
|
source "$TEST_TOP/common.convert"
|
2014-05-21 17:20:27 +00:00
|
|
|
|
2018-02-08 17:34:40 +00:00
|
|
|
export INTERNAL_BIN
|
2018-02-08 06:34:19 +00:00
|
|
|
export TEST_TOP
|
2016-06-03 02:34:25 +00:00
|
|
|
export TOP
|
|
|
|
export RESULTS
|
|
|
|
export LANG
|
2016-06-03 14:01:51 +00:00
|
|
|
export IMAGE
|
|
|
|
export TEST_DEV
|
2016-06-03 02:34:25 +00:00
|
|
|
|
2016-11-11 09:12:05 +00:00
|
|
|
rm -f "$RESULTS"
|
2014-05-21 17:20:27 +00:00
|
|
|
|
2016-11-10 17:57:38 +00:00
|
|
|
check_kernel_support
|
2017-09-07 15:29:51 +00:00
|
|
|
check_kernel_support_reiserfs
|
2017-08-29 14:35:01 +00:00
|
|
|
# anything expected by common.convert
|
|
|
|
check_global_prereq getfacl
|
|
|
|
check_global_prereq setfacl
|
|
|
|
check_global_prereq md5sum
|
2016-11-10 17:57:38 +00:00
|
|
|
|
2023-06-21 14:44:30 +00:00
|
|
|
test_found=0
|
|
|
|
|
2016-06-03 02:34:25 +00:00
|
|
|
run_one_test() {
|
2016-06-22 09:30:24 +00:00
|
|
|
local testdir
|
2016-06-03 02:34:25 +00:00
|
|
|
local testname
|
|
|
|
|
2016-06-22 09:30:24 +00:00
|
|
|
testdir="$1"
|
|
|
|
testname=$(basename "$testdir")
|
2023-06-21 14:44:30 +00:00
|
|
|
if ! [ -z "$TEST_FROM" ]; then
|
|
|
|
if [ "$test_found" == 0 ]; then
|
|
|
|
case "$testname" in
|
|
|
|
$TEST_FROM) test_found=1;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
if [ "$test_found" == 0 ]; then
|
|
|
|
printf " [TEST/conv] %-40s (SKIPPED)\n" "$testname"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
fi
|
2016-06-03 02:34:25 +00:00
|
|
|
echo " [TEST/conv] $testname"
|
2016-06-22 09:30:24 +00:00
|
|
|
cd "$testdir"
|
2018-05-08 17:04:41 +00:00
|
|
|
echo "=== START TEST $testname" >> "$RESULTS"
|
2016-06-03 02:34:25 +00:00
|
|
|
if [ -x test.sh ]; then
|
2016-06-22 09:30:24 +00:00
|
|
|
# Only support custom test scripts
|
2016-06-03 02:34:25 +00:00
|
|
|
./test.sh
|
|
|
|
if [ $? -ne 0 ]; then
|
2016-11-18 14:18:02 +00:00
|
|
|
if [[ $TEST_LOG =~ dump ]]; then
|
2017-08-29 16:41:30 +00:00
|
|
|
# the logs can be large and may exceed the
|
|
|
|
# limits, use 4MB for now
|
|
|
|
tail -c 3900000 "$RESULTS"
|
2016-11-18 14:18:02 +00:00
|
|
|
fi
|
2017-08-29 15:42:28 +00:00
|
|
|
_fail "test failed for case $testname"
|
2016-06-03 02:34:25 +00:00
|
|
|
fi
|
2020-11-09 05:39:52 +00:00
|
|
|
check_test_results "$RESULTS" "$testname"
|
2016-06-03 02:34:25 +00:00
|
|
|
else
|
|
|
|
_fail "custom test script not found"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
# Test special images
|
2018-02-08 06:34:19 +00:00
|
|
|
for i in $(find "$TEST_TOP/convert-tests" -maxdepth 1 -mindepth 1 -type d \
|
2016-06-03 02:34:25 +00:00
|
|
|
${TEST:+-name "$TEST"} | sort)
|
|
|
|
do
|
|
|
|
run_one_test "$i"
|
|
|
|
done
|
2023-09-05 20:19:45 +00:00
|
|
|
|
|
|
|
"$TEST_TOP/scan-results.sh" "$RESULTS"
|