[DTrace-devel] [PATCH v2 9/9] test: work when relocated
Nick Alcock
nick.alcock at oracle.com
Thu Aug 1 13:21:56 UTC 2024
We do this by adding a variable to the pkg-config files that points at
the dtrace binary, then using that. To make this work when the prefix
is changed, runtest.sh sets its own PKG_CONFIG_PATH to a directory
relative to the testsuite. This will fail if the pkg-config install
path is also changed, but in that case presumably the person installing
it has arranged for pkg-config to find the pkg-config files in the
installed location. 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>
---
runtest.sh | 13 +++++++++++--
test/unittest/usdt/tst.manyprocs.sh | 2 +-
test/unittest/usdt/tst.multitrace.sh | 2 +-
uts/Build | 3 ++-
uts/dtrace.pc.in | 1 +
uts/dtrace_sdt.pc.in | 1 +
6 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/runtest.sh b/runtest.sh
index 16a1a77bd394..792b2f4f25c7 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)"
@@ -574,7 +575,15 @@ if [[ -z $USE_INSTALLED ]]; then
export dtprobed_pid=$!
ZAPTHESE+=($dtprobed_pid)
else
- dtrace="/usr/sbin/dtrace"
+ # If we don't have a pkg-config path, try to point at a plausible
+ # one given DTrace's default install paths. This will fail if
+ # the pkg-config path is changed as well: in that case, presumably
+ # the person changing that path has pointed pkg-config at it anyway.
+ if [[ -z $PKG_CONFIG_PATH ]]; then
+ export PKG_CONFIG_PATH="$(pwd)/../../../share/pkgconfig"
+ fi
+
+ dtrace="$(pkg-config --variable=dtrace dtrace)"
test_libdir="installed"
test_ldflags=""
test_cppflags="-DARCH_$arch $(pkg-config --cflags dtrace_sdt) $(pkg-config --cflags dtrace)"
@@ -584,8 +593,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 a899470dfa0e..f820ed231c38 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 84cf1e8caa54..dcabde620c03 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
diff --git a/uts/Build b/uts/Build
index 7948e9f2d084..181819410624 100644
--- a/uts/Build
+++ b/uts/Build
@@ -37,6 +37,7 @@ install::
(cd $(uts_DIR) && \
sed -e 's, at SDTINCLUDEDIR@,$(SDTINCLUDEDIR),g;' \
-e 's, at INCLUDEDIR@,$(INCLUDEDIR),g;' \
- -e 's, at VERSION@,$(VERSION),g' < \
+ -e 's, at VERSION@,$(VERSION),g;' \
+ -e 's, at DTRACE@,$(SBINDIR)/dtrace,g' < \
$${name}.in > $(INSTPKGCONFIGDIR)/$$name;) \
done
diff --git a/uts/dtrace.pc.in b/uts/dtrace.pc.in
index 58aa46fc75c9..9977082c5a7c 100644
--- a/uts/dtrace.pc.in
+++ b/uts/dtrace.pc.in
@@ -1,5 +1,6 @@
includedir = @INCLUDEDIR@
libdir = @LIBDIR@
+dtrace = @DTRACE@
Name: DTrace
Description: DTrace consumer headers
diff --git a/uts/dtrace_sdt.pc.in b/uts/dtrace_sdt.pc.in
index c5506f9355d9..32474bc3f75d 100644
--- a/uts/dtrace_sdt.pc.in
+++ b/uts/dtrace_sdt.pc.in
@@ -1,4 +1,5 @@
sdtincludedir = @SDTINCLUDEDIR@
+dtrace = @DTRACE@
Name: DTrace SDT
Description: DTrace raw SDT headers
--
2.46.0.277.ge12b8151ed
More information about the DTrace-devel
mailing list