2016-07-04 11:45:15 +00:00
|
|
|
#!/bin/bash
|
2015-05-25 14:08:46 +00:00
|
|
|
# remove all intermediate files from tests
|
|
|
|
|
2018-02-08 17:34:40 +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
|
2019-07-04 10:55:33 +00:00
|
|
|
echo "WARNING: cannot find btrfs in TOP=$TOP"
|
2018-02-08 17:34:40 +00:00
|
|
|
fi
|
|
|
|
TEST_DEV=${TEST_DEV:-}
|
|
|
|
RESULTS="$TEST_TOP/cli-tests-results.txt"
|
|
|
|
IMAGE="$TEST_TOP/test.img"
|
|
|
|
|
2018-02-13 15:21:20 +00:00
|
|
|
source "$TEST_TOP/common"
|
2015-08-31 05:04:38 +00:00
|
|
|
|
|
|
|
setup_root_helper
|
|
|
|
|
2015-05-25 14:08:46 +00:00
|
|
|
if [ "$BUILD_VERBOSE" = 1 ]; then
|
|
|
|
verbose=-print
|
|
|
|
fi
|
|
|
|
|
2020-05-04 18:36:52 +00:00
|
|
|
[ "$BUILD_VERBOSE" = 1 ] && echo "Umount $TEST_MNT"
|
2019-05-27 14:08:23 +00:00
|
|
|
$SUDO_HELPER umount -R "$TEST_MNT" &>/dev/null
|
2015-05-25 14:08:46 +00:00
|
|
|
|
2018-02-13 15:21:20 +00:00
|
|
|
if ! cd "$TEST_TOP"; then
|
|
|
|
echo "ERROR: cannot cd to $TEST_TOP"
|
2015-05-25 14:08:46 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2020-05-04 18:36:52 +00:00
|
|
|
[ "$BUILD_VERBOSE" = 1 ] && echo "Delete temporary fsck images $TEST_MNT"
|
2015-05-25 14:08:46 +00:00
|
|
|
find fsck-tests -type f -name '*.restored' $verbose -delete
|
|
|
|
|
2020-05-04 18:36:52 +00:00
|
|
|
for dev in $(losetup --noheadings --output NAME,BACK-FILE | grep "$SCRIPT_DIR"); do
|
|
|
|
# Accept only /dev/loop0
|
|
|
|
# And skip $SCRIPT_DIR/cli-tests/001-test/img1
|
|
|
|
if [[ $dev =~ ^/dev/loop ]]; then
|
|
|
|
lfile=$(losetup --noheadings --output BACK-FILE "$dev")
|
|
|
|
[ "$BUILD_VERBOSE" = 1 ] &&
|
|
|
|
echo "Detach loop device/file $dev ($lfile)"
|
|
|
|
$SUDO_HELPER losetup --detach "$dev"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
2015-05-25 14:08:46 +00:00
|
|
|
# do not remove, the file could have special permissions set
|
|
|
|
echo -n > test.img
|