[PATCH v5 07/11] runtest.sh: Prepare Python bindings for in-tree testing

Alan Maguire <[email protected]>
Newsgroups dev.linux.lists.dtrace
Message-ID <[email protected]>
Export the in-tree Python binding directory so tests can import the build
output without installing it.

Also export the Python interpreter selected by the build as
DTRACE_PYTHON.  runtest.sh preserves that setting when invoked by make,
accepts it from a caller that sources the runner, and otherwise falls
back to PYTHON or python3.

Signed-off-by: Alan Maguire <[email protected]>
---
 Makecheck  | 3 +++
 runtest.sh | 4 ++++
 2 files changed, 7 insertions(+)

diff --git a/Makecheck b/Makecheck
index 928fadb5..87db1065 100644
--- a/Makecheck
+++ b/Makecheck
@@ -19,6 +19,9 @@
 # DTrace:
 # check-qa-smoke: Runs the smoke testsuite.
 
+DTRACE_PYTHON := $(PYTHON)
+export DTRACE_PYTHON
+
 ifndef always-installed
 git_version=.git-version
 RUNTEST=./runtest.sh
diff --git a/runtest.sh b/runtest.sh
index 9f06a499..ca230ca7 100755
--- a/runtest.sh
+++ b/runtest.sh
@@ -19,6 +19,8 @@ unset CDPATH
 unset POSIXLY_CORRECT  # Interferes with 'wait'
 export LC_COLLATE="C"
 export dtrace="/usr/sbin/dtrace"
+DTRACE_PYTHON="${DTRACE_PYTHON:-${PYTHON:-python3}}"
+export DTRACE_PYTHON
 
 arch="$(uname -m)"
 
@@ -552,6 +554,7 @@ export LANGUAGE=C
 
 if [[ -z $USE_INSTALLED ]]; then
     dtrace="$(pwd)/build*/dtrace"
+    PYTHONPATH="$(pwd)/build/bindings/python${PYTHONPATH:+:$PYTHONPATH}"
     test_libdir="$(pwd)/build/dlibs"
     test_ldflags="-L$(pwd)/build"
     test_cppflags="-I$(pwd)/include -I$(pwd)/uts/common -I$(pwd)/build -I$(pwd)/libdtrace -DARCH_$arch"
@@ -562,6 +565,7 @@ if [[ -z $USE_INSTALLED ]]; then
     dtprobed_flags="-n $helper_device -s${tmpdir}/run/dtrace -F"
     export DTRACE_DOF_INIT_DEVNAME="/dev/$helper_device"
     export DTRACE_OPT_DOFSTASHPATH="${tmpdir}/run/dtrace"
+    export PYTHONPATH
 
     if [[ -z $(eval echo $dtrace) ]]; then
     	echo "No dtraces available." >&2
-- 
2.43.5
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.