File: test_run.sh

package info (click to toggle)
sysbench 1.0.20%2Bds-7
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 1,840 kB
  • sloc: ansic: 11,830; sh: 1,752; xml: 736; makefile: 195
file content (97 lines) | stat: -rwxr-xr-x 2,761 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#!/usr/bin/env bash

# Copyright (C) 2016-2017 Alexey Kopytov <akopytov@gmail.com>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA

set -eu

testroot=$(cd $(dirname "$0"); echo $PWD)

# Find the sysbench binary to use
dirlist=( "$testroot/../src"       # source directory
          "$testroot/../bin"       # standalone install root directory
          "$testroot/../../../bin" # system-wide install (e.g. /usr/local/share/sysbench/tests)
          "$PWD/../src" )          # build directory by 'make distcheck'

for dir in ${dirlist[@]}
do
    if [ -x "$dir/sysbench" ]
    then
        sysbench_dir="$dir"
        break
    fi
done

if [ -z ${sysbench_dir+x} ]
then
    echo "Cannot find sysbench in the following list of directories: \
${dirlist[@]}"
    exit 1
fi

if [ -z ${srcdir+x} ]
then
    SBTEST_INCDIR="$PWD/include"
    SBTEST_CONFIG="$SBTEST_INCDIR/config.sh"
    if [ $# -lt 1 ]
    then
        tests="t/*.t"
    fi
else
    # SBTEST_INCDIR must be an absolute path, because cram changes CWD to a
    # temporary directory when executing tests. That's why we can just use
    # $srcdir here
    SBTEST_INCDIR="$(cd $srcdir; echo $PWD)/include"
    SBTEST_CONFIG="$PWD/include/config.sh"
    if [ $# -lt 1 ]
    then
        tests="$srcdir/t/*.t"
    fi
fi
if [ -z ${tests+x} ]
then
   tests="$*"
fi

export SBTEST_ROOTDIR="$testroot"
export SBTEST_SCRIPTDIR="$testroot/../src/lua"
export SBTEST_SUITEDIR="$testroot/t"
export SBTEST_CONFIG
export SBTEST_INCDIR

# Add directories containing sysbench and cram to PATH
export PATH="${sysbench_dir}:${SBTEST_ROOTDIR}/../third_party/cram/scripts:$PATH"

export PYTHONPATH="${SBTEST_ROOTDIR}/../third_party/cram:${PYTHONPATH:-}"

LUA_PATH="$SBTEST_SCRIPTDIR/?;$SBTEST_SCRIPTDIR/?.lua"
LUA_PATH="$LUA_PATH;$SBTEST_INCDIR/?;$SBTEST_INCDIR/?.lua"
export LUA_PATH

. $SBTEST_CONFIG

if $(command -v python3 >/dev/null 2>&1)
then
    PYTHON=python3
elif $(command -v python2 >/dev/null 2>&1)
then
    PYTHON=python2
else
    echo "Cannot find python interpreter in PATH"
    exit 1
fi

$PYTHON $(command -v cram3) --shell=/bin/bash --verbose $tests