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:
David Sterba 2018-02-08 18:34:40 +01:00
parent dd11901dae
commit e44f595dd7
7 changed files with 151 additions and 30 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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"

View File

@ -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"