Btrfs progs v4.17.1
[btrfs-progs-unstable/devel.git] / tests / clean-tests.sh
blob342616f7c7c988503345dfc0e9b785e69e27fc11
1 #!/bin/bash
2 # remove all intermediate files from tests
4 LANG=C
5 SCRIPT_DIR=$(dirname $(readlink -f "$0"))
6 if [ -z "$TOP" ]; then
7 TOP=$(readlink -f "$SCRIPT_DIR/../")
8 if [ -f "$TOP/configure.ac" ]; then
9 # inside git
10 TEST_TOP="$TOP/tests/"
11 INTERNAL_BIN="$TOP"
12 else
13 # external, defaults to system binaries
14 TOP=$(dirname `which btrfs`)
15 TEST_TOP="$SCRIPT_DIR"
16 INTERNAL_BIN="$TEST_TOP"
18 else
19 # assume external, TOP set from commandline
20 TEST_TOP="$SCRIPT_DIR"
21 INTERNAL_BIN="$TEST_TOP"
23 if ! [ -x "$TOP/btrfs" ]; then
24 echo "ERROR: cannot execute btrfs from TOP=$TOP"
25 exit 1
27 TEST_DEV=${TEST_DEV:-}
28 RESULTS="$TEST_TOP/cli-tests-results.txt"
29 IMAGE="$TEST_TOP/test.img"
31 source "$TEST_TOP/common"
33 setup_root_helper
35 if [ "$BUILD_VERBOSE" = 1 ]; then
36 verbose=-print
39 $SUDO_HELPER umount "$TEST_MNT" &>/dev/null
41 if ! cd "$TEST_TOP"; then
42 echo "ERROR: cannot cd to $TEST_TOP"
43 exit 1
46 find fsck-tests -type f -name '*.restored' $verbose -delete
48 # do not remove, the file could have special permissions set
49 echo -n > test.img