btrfs-progs: build: Do not use cp -a to install library links
[platform/upstream/btrfs-progs.git] / tests / clean-tests.sh
index 61baa06..342616f 100755 (executable)
@@ -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