From 8fc9357cf014a7006b571785bc551d522d572e33 Mon Sep 17 00:00:00 2001 From: Alexey Kopytov Date: Mon, 5 Sep 2016 10:39:47 +0300 Subject: [PATCH] Add version.t test + some necessary test harness improvements. --- configure.ac | 1 + tests/test_run.sh | 24 ++++++++++++++---------- tests/version.t | 7 +++++++ 3 files changed, 22 insertions(+), 10 deletions(-) create mode 100644 tests/version.t diff --git a/configure.ac b/configure.ac index d3204bb..7165a67 100644 --- a/configure.ac +++ b/configure.ac @@ -462,5 +462,6 @@ sysbench/scripting/Makefile sysbench/scripting/lua/Makefile sysbench/scripting/lua/src/Makefile tests/Makefile +tests/include/config.sh ]) AC_OUTPUT diff --git a/tests/test_run.sh b/tests/test_run.sh index 2efbce2..a131027 100755 --- a/tests/test_run.sh +++ b/tests/test_run.sh @@ -18,18 +18,21 @@ set -eu -if [ -x "$PWD/../sysbench/sysbench" ] +testroot=$(cd $(dirname "$0"); echo $PWD) + +# Find the sysbench binary to use +if [ -x "$testroot/../sysbench/sysbench" ] then # Invoked from a source directory? - export PATH=$PWD/../sysbench:$PATH -elif [ -x "$PWD/../bin" ] + export PATH="$testroot/../sysbench:$PATH" +elif [ -x "$testroot/../bin" ] then # Invoked from a standalone install root directory? - export PATH=$PWD/../bin:$PATH -elif [ -x "$PWD/../../../bin/sysbench" ] + export PATH="$testroot/../bin:$PATH" +elif [ -x "$testroot/../../../bin/sysbench" ] then # Invoked from a system-wide install (e.g. /usr/local/share/sysbench/tests)? - export PATH=$PWD/../../../bin:$PATH + export PATH="$testroot/../../../bin:$PATH" fi if ! which sysbench >/dev/null 2>&1 @@ -40,16 +43,17 @@ fi if [ $# -lt 1 ] then - # Automake defines $srcdir where test datafiles are located on 'make check' if [ -z ${srcdir+x} ] then - testroot="." + tests="*.t" else - testroot="$srcdir" + tests="$srcdir/*.t" fi - tests="${testroot}/*.t" else tests="$*" fi +export SBTEST_INCDIR="$PWD/include" +export SBTEST_CONFIG="$SBTEST_INCDIR/config.sh" + cram --shell=/bin/bash --verbose $tests diff --git a/tests/version.t b/tests/version.t new file mode 100644 index 0000000..8f22cd2 --- /dev/null +++ b/tests/version.t @@ -0,0 +1,7 @@ + $ . $SBTEST_CONFIG + + $ sysbench --version + sysbench [.0-9]* (re) + + $ version=$(sysbench --version | cut -d ' ' -f 2) + $ test "$version" = "$SBTEST_VERSION"