c016624fb99d6579273eada54d6b0b92b6ccebaf
[babeltrace.git] / tests / utils / run_python_bt2
1 #!/bin/bash
2 #
3 # Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
4 # Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
5 #
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License
8 # as published by the Free Software Foundation; only version 2
9 # of the License.
10 #
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
15 #
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19 #
20
21 # Execute a shell command in the appropriate environment to have access to the
22 # bt2 Python bindings. For example, one could use it to run a specific Python
23 # binding test case with:
24 #
25 # $ tests/utils/run_python_bt2 python3 ./tests/utils/python/testrunner.py \
26 # -t test_value.MapValueTestCase.test_deepcopy \
27 # ./tests/bindings/python/bt2
28
29 if [ "x${BT_TESTS_SRCDIR:-}" != "x" ]; then
30 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
31 else
32 UTILSSH="$(dirname "$0")/../utils/utils.sh"
33 fi
34
35 # shellcheck source=../utils/utils.sh
36 source "$UTILSSH"
37
38 usage() {
39 echo "Usage: run_python_bt2 [PYTHON_BIN] ..."
40 echo ""
41 echo "Run a binary with the python environment set to use the 'bt2' module"
42 echo "from the build system prior to installation."
43 echo ""
44 echo "When building out of tree export the BT_TESTS_BUILDDIR variable with"
45 echo "the path to the built 'tests' directory."
46 }
47
48 if [ "x$*" = "x" ]; then
49 usage
50 exit 1
51 fi
52
53 # Sanity check that the BT_TESTS_BUILDDIR value makes sense.
54 if [ ! -f "$BT_TESTS_BUILDDIR/Makefile" ]; then
55 fold -w 80 -s <<- END
56 $0: BT_TESTS_BUILDDIR does not point to a valid directory (\`$BT_TESTS_BUILDDIR/Makefile\` does not exist).
57
58 If building out-of-tree, set BT_TESTS_BUILDDIR to point to the \`tests\` directory in the build tree.
59 END
60 exit 1
61 fi
62
63 run_python_bt2 "${@}"
This page took 0.031716 seconds and 3 git commands to generate.