Reduce the number of Makefiles in 'doc/'
[babeltrace.git] / tests / utils / run_python_bt2
CommitLineData
644e0364
MJ
1#!/bin/bash
2#
0235b0db
MJ
3# SPDX-License-Identifier: GPL-2.0-only
4#
644e0364
MJ
5# Copyright (C) 2017 Philippe Proulx <pproulx@efficios.com>
6# Copyright (C) 2019 Simon Marchi <simon.marchi@efficios.com>
7#
644e0364
MJ
8
9# Execute a shell command in the appropriate environment to have access to the
10# bt2 Python bindings. For example, one could use it to run a specific Python
11# binding test case with:
12#
5968a1ad
FD
13# $ tests/utils/run_python_bt2 python3 ./tests/utils/python/testrunner.py \
14# -t test_value.MapValueTestCase.test_deepcopy \
15# ./tests/bindings/python/bt2
644e0364 16
75e396f6 17if [ -n "${BT_TESTS_SRCDIR:-}" ]; then
644e0364
MJ
18 UTILSSH="$BT_TESTS_SRCDIR/utils/utils.sh"
19else
20 UTILSSH="$(dirname "$0")/../utils/utils.sh"
21fi
22
23# shellcheck source=../utils/utils.sh
24source "$UTILSSH"
25
26usage() {
27 echo "Usage: run_python_bt2 [PYTHON_BIN] ..."
28 echo ""
29 echo "Run a binary with the python environment set to use the 'bt2' module"
30 echo "from the build system prior to installation."
31 echo ""
32 echo "When building out of tree export the BT_TESTS_BUILDDIR variable with"
33 echo "the path to the built 'tests' directory."
34}
35
75e396f6 36if [ -z "$*" ]; then
644e0364 37 usage
b841eced 38 exit 1
644e0364 39fi
b841eced
SM
40
41# Sanity check that the BT_TESTS_BUILDDIR value makes sense.
42if [ ! -f "$BT_TESTS_BUILDDIR/Makefile" ]; then
43 fold -w 80 -s <<- END
44 $0: BT_TESTS_BUILDDIR does not point to a valid directory (\`$BT_TESTS_BUILDDIR/Makefile\` does not exist).
45
46 If building out-of-tree, set BT_TESTS_BUILDDIR to point to the \`tests\` directory in the build tree.
47 END
48 exit 1
49fi
50
51run_python_bt2 "${@}"
This page took 0.0543 seconds and 4 git commands to generate.