summaryrefslogtreecommitdiff
path: root/tests/clean-tests.sh
diff options
context:
space:
mode:
authorDimitri John Ledkov <xnox@ubuntu.com>2018-02-19 15:51:31 +0000
committerDimitri John Ledkov <xnox@ubuntu.com>2018-02-19 15:52:49 +0000
commitb70cb0d0a21394d5d6b00b51f064115c2724cea8 (patch)
treef001381d2ee826e6665e003e7c6dccb084a54316 /tests/clean-tests.sh
parentf1b0adb46b2c193e940f8c22b35036d2ee76c673 (diff)
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 61baa06..342616f 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