[DTrace-devel] [PATCH 9/9] test: work when relocated

Nick Alcock nick.alcock at oracle.com
Fri May 31 18:59:28 UTC 2024


We do this by writing out a runtest.conf into the testdir at
make install-test time that tells the testsuite where dtrace
is located.  Fix a couple of tests that are assuming the
location of the dtrace binary can be used to determine
whether the installed testsuite is in use.

Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
 Build                                | 1 +
 runtest.sh                           | 5 +++--
 test/unittest/usdt/tst.manyprocs.sh  | 2 +-
 test/unittest/usdt/tst.multitrace.sh | 2 +-
 4 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/Build b/Build
index 485e75d62b4cb..071bef631f7c4 100644
--- a/Build
+++ b/Build
@@ -10,6 +10,7 @@ install-test::
 	mkdir -p $(INSTTESTDIR)
 	$(call describe-install-target,$(INSTTESTDIR),GNUmakefile runtest.sh .git-version Makecheck Makeoptions)
 	install -m 755 runtest.sh $(INSTTESTDIR)
+	echo dtrace="$(SBINDIR)/dtrace" > $(INSTTESTDIR)/runtest.conf
 	install -m 644 Makecheck .git-version $(INSTTESTDIR)
 	install -m 644 Makeoptions.installed $(INSTTESTDIR)/Makeoptions
 	sed "s, at INSTALL_SUBST@,TESTDIR=$(TESTDIR)," < Makecheck.installed.in > $(INSTTESTDIR)/GNUmakefile
diff --git a/runtest.sh b/runtest.sh
index d9b7c02c06a3e..25b8cf5665032 100755
--- a/runtest.sh
+++ b/runtest.sh
@@ -18,6 +18,7 @@ shopt -s nullglob extglob
 unset CDPATH
 unset POSIXLY_CORRECT  # Interferes with 'wait'
 export LC_COLLATE="C"
+export dtrace="/usr/sbin/dtrace"
 
 arch="$(uname -m)"
 
@@ -576,7 +577,7 @@ if [[ -z $USE_INSTALLED ]]; then
     export dtprobed_pid=$!
     ZAPTHESE+=($dtprobed_pid)
 else
-    dtrace="/usr/sbin/dtrace"
+    # inherit the dtrace path from runtest.conf or defaults (above)
     test_libdir="installed"
     test_ldflags=""
     test_cppflags="-DARCH_$arch $(pkg-config --cflags dtrace_sdt) $(pkg-config --cflags dtrace)"
@@ -586,8 +587,8 @@ else
         exit 1
     fi
 fi
-export dtrace
 export test_cppflags
+export test_libdir
 
 # Figure out if the preprocessor supports -fno-diagnostics-show-option: if it
 # does, add a bunch of options designed to make GCC output look like it used
diff --git a/test/unittest/usdt/tst.manyprocs.sh b/test/unittest/usdt/tst.manyprocs.sh
index a899470dfa0e1..f820ed231c388 100755
--- a/test/unittest/usdt/tst.manyprocs.sh
+++ b/test/unittest/usdt/tst.manyprocs.sh
@@ -82,7 +82,7 @@ done
 # should contain at most five or so DOFs, even though 512
 # processes left stale DOF around.  (Allow up to ten in
 # case the most recent cleanup is still underway.)
-if [[ $dtrace != "/usr/sbin/dtrace" ]] && [[ -n $DTRACE_OPT_DOFSTASHPATH ]]; then
+if [[ $test_libdir != "installed" ]] && [[ -n $DTRACE_OPT_DOFSTASHPATH ]]; then
     NUMDOFS="$(find $DTRACE_OPT_DOFSTASHPATH/stash/dof -type f | wc -l)"
     if [[ $NUMDOFS -gt 10 ]]; then
 	echo "DOF stash contains too many old DOFs: $NUMDOFS" >&2
diff --git a/test/unittest/usdt/tst.multitrace.sh b/test/unittest/usdt/tst.multitrace.sh
index 84cf1e8caa543..dcabde620c030 100755
--- a/test/unittest/usdt/tst.multitrace.sh
+++ b/test/unittest/usdt/tst.multitrace.sh
@@ -123,7 +123,7 @@ ONE=$!
 # if re-executed with a newer version of dtprobed with incompatible
 # parse state.  Overwrite the parsed DOF with crap first, to force
 # a failure if it simply doesn't reparse at all.
-if [[ $dtrace != "/usr/sbin/dtrace" ]] && [[ -n $dtprobed_pid ]]; then
+if [[ $test_libdir != "installed" ]] && [[ -n $dtprobed_pid ]]; then
     sleep 1
     for parsed in $DTRACE_OPT_DOFSTASHPATH/stash/dof-pid/*/*/parsed/*; do
 	echo 'a' > $parsed
-- 
2.45.1.275.g567cb0950c




More information about the DTrace-devel mailing list