btrfs-progs: tests: unify test drivers, make ready for extenral testsuite
Make the TOP variable more configurable, allow to set it to any path where to find binaries when the testsuite is exported, or fallback to system binaries. There's now more code duplication, the logic is now more complex so it's left open coded for clarity. Further cleanups are possible. Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
dd11901dae
commit
e44f595dd7
|
@ -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/tests/common"
|
||||
|
||||
setup_root_helper
|
||||
|
||||
|
|
|
@ -4,10 +4,26 @@
|
|||
|
||||
LANG=C
|
||||
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
||||
TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
|
||||
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
||||
if ! [ -f "$TOP/btrfs" ];then
|
||||
TOP=$(dirname `which btrfs`)
|
||||
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"
|
||||
|
@ -15,6 +31,7 @@ IMAGE="$TEST_TOP/test.img"
|
|||
|
||||
source "$TEST_TOP/common"
|
||||
|
||||
export INTERNAL_BIN
|
||||
export TEST_TOP
|
||||
export TOP
|
||||
export RESULTS
|
||||
|
|
|
@ -5,10 +5,26 @@
|
|||
|
||||
LANG=C
|
||||
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
||||
TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
|
||||
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
||||
if ! [ -f "$TOP/btrfs" ];then
|
||||
TOP=$(dirname `which btrfs`)
|
||||
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/convert-tests-results.txt"
|
||||
|
@ -17,6 +33,7 @@ IMAGE="$TEST_TOP/test.img"
|
|||
source "$TEST_TOP/common"
|
||||
source "$TEST_TOP/common.convert"
|
||||
|
||||
export INTERNAL_BIN
|
||||
export TEST_TOP
|
||||
export TOP
|
||||
export RESULTS
|
||||
|
|
|
@ -4,11 +4,26 @@
|
|||
|
||||
LANG=C
|
||||
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
||||
INTERNAL_BIN=$(readlink -f "$SCRIPT_DIR/../")
|
||||
TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
|
||||
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
||||
if ! [ -f "$TOP/btrfs" ];then
|
||||
TOP=$(dirname `which btrfs`)
|
||||
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/fsck-tests-results.txt"
|
||||
|
|
|
@ -4,10 +4,26 @@
|
|||
|
||||
LANG=C
|
||||
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
||||
TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
|
||||
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
||||
if ! [ -f "$TOP/btrfs" ];then
|
||||
TOP=$(dirname `which btrfs`)
|
||||
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/fuzz-tests-results.txt"
|
||||
|
@ -15,6 +31,7 @@ IMAGE="$TEST_TOP/test.img"
|
|||
|
||||
source "$TEST_TOP/common"
|
||||
|
||||
export INTERNAL_BIN
|
||||
export TEST_TOP
|
||||
export TOP
|
||||
export RESULTS
|
||||
|
|
|
@ -4,11 +4,26 @@
|
|||
|
||||
LANG=C
|
||||
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
||||
TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
|
||||
INTERNAL_BIN=$(readlink -f "$SCRIPT_DIR/../")
|
||||
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
||||
if ! [ -f "$TOP/btrfs" ];then
|
||||
TOP=$(dirname `which btrfs`)
|
||||
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/misc-tests-results.txt"
|
||||
|
@ -21,8 +36,8 @@ export TEST_TOP
|
|||
export TOP
|
||||
export RESULTS
|
||||
export LANG
|
||||
export TEST_DEV
|
||||
export IMAGE
|
||||
export TEST_DEV
|
||||
|
||||
rm -f "$RESULTS"
|
||||
|
||||
|
|
|
@ -4,11 +4,26 @@
|
|||
|
||||
LANG=C
|
||||
SCRIPT_DIR=$(dirname $(readlink -f "$0"))
|
||||
INTERNAL_BIN=$(readlink -f "$SCRIPT_DIR/../")
|
||||
TEST_TOP=$(readlink -f "$SCRIPT_DIR/../tests/")
|
||||
TOP=$(readlink -f "$SCRIPT_DIR/../")
|
||||
if ! [ -f "$TOP/btrfs" ];then
|
||||
TOP=$(dirname `which btrfs`)
|
||||
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/mkfs-tests-results.txt"
|
||||
|
|
Loading…
Reference in New Issue