#!/bin/bash
#
# minimal version of upstream tests/test_run.sh, modified for autopkgtest

set -eu

testroot="$(pwd)/tests"
version="$(dpkg-parsechangelog -ldebian/changelog --show-field Version | sed 's/.*://; s/-[^-]*$//; s/\+.*//')"

export SBTEST_INCDIR="$testroot/include"
export SBTEST_ROOTDIR="$testroot"
export SBTEST_SCRIPTDIR="/usr/share/sysbench"
export SBTEST_SUITEDIR="$testroot/t"
export SBTEST_VERSION_STRING="sysbench $version"
export SBTEST_VERSION="$version"
export SBTEST_HAS_MYSQL=1
export SBTEST_HAS_PGSQL=1

export LUA_PATH="$SBTEST_SCRIPTDIR/?;$SBTEST_SCRIPTDIR/?.lua;$SBTEST_INCDIR/?;$SBTEST_INCDIR/?.lua"
export PATH=/usr/bin:/bin

cram3 --shell=/bin/bash --verbose "$testroot/t/"*.t
