summaryrefslogtreecommitdiff
path: root/tests/clean-tests.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/clean-tests.sh')
-rwxr-xr-xtests/clean-tests.sh33
1 files changed, 29 insertions, 4 deletions
diff --git a/tests/clean-tests.sh b/tests/clean-tests.sh
index 61baa069..342616f7 100755
--- a/tests/clean-tests.sh
+++ b/tests/clean-tests.sh
@@ -1,9 +1,34 @@
#!/bin/bash
# remove all intermediate files from tests
+LANG=C
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
-TOP=$(readlink -f "$SCRIPT_DIR/../")
-source "$TOP/tests/common"
+if [ -z "$TOP" ]; then
+ TOP=$(readlink -f "$SCRIPT_DIR/../")
+ if [ -f "$TOP/configure.ac" ]; then
+ # inside git
+ TEST_TOP="$TOP/tests/"
+ INTERNAL_BIN="$TOP"
+ else
+ # external, defaults to system binaries
+ TOP=$(dirname `which btrfs`)
+ 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
+fi
+TEST_DEV=${TEST_DEV:-}
+RESULTS="$TEST_TOP/cli-tests-results.txt"
+IMAGE="$TEST_TOP/test.img"
+
+source "$TEST_TOP/common"
setup_root_helper
@@ -13,8 +38,8 @@ fi
$SUDO_HELPER umount "$TEST_MNT" &>/dev/null
-if ! cd "$TOP/tests"; then
- echo "ERROR: cannot cd to $TOP/tests"
+if ! cd "$TEST_TOP"; then
+ echo "ERROR: cannot cd to $TEST_TOP"
exit 1
fi