[DTrace-devel] test: allow tests to verify whether a provider is loaded

Kris Van Hees kris.van.hees at oracle.com
Tue Mar 17 14:44:20 PDT 2020


The DTrace v1 testsuite kept a lsit of loaded providers so that tests
could use the check_provider function to determine if a certain provider
was loaded.  The generation of the list of providers was implemented in
the routine that handled loading the DTrace kernel modules.  Since we no
longer use kernel modules for DTrace v2, the code to generate the provider
list was accidentally removed as well.

This patch brings back code to generate the provider list.  It also fixes
the interpreter specification in one .x file.  It must use the Bourne
Again shell (bash) to have access to the check_provider function.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 runtest.sh              | 16 +++++++++++++++-
 test/unittest/ip/test.x |  2 +-
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/runtest.sh b/runtest.sh
index 5f3e80e2..ca2bce77 100755
--- a/runtest.sh
+++ b/runtest.sh
@@ -25,7 +25,7 @@ arch="$(uname -m)"
 
 #
 # Utility function to ensure a given provider is present.
-# Uses the providers list written out at module-load time.
+# Uses the providers list written out at start time.
 #
 check_provider()
 {
@@ -575,6 +575,20 @@ if [[ "x$test_libdir" != "xinstalled" ]]; then
     export DTRACE_OPT_SYSLIBDIR="$test_libdir"
 fi
 
+# Determine the list of available providers
+for dt in $dtrace; do
+    # Look for our shared libraries in the right place.
+    if [[ "x$test_libdir" != "xinstalled" ]]; then
+        export LD_LIBRARY_PATH="$(dirname $dt)"
+    fi
+
+    # Write out a list of loaded providers.
+    DTRACE_DEBUG= $dt -l | tail -n +2 | awk '{print $2;}' | sort -u > $tmpdir/providers
+
+    unset LD_LIBRARY_PATH
+    break
+done
+
 # Initialize test coverage.
 
 if [[ -n $NOBADDOF ]]; then
diff --git a/test/unittest/ip/test.x b/test/unittest/ip/test.x
index 19ad7a29..588e8cc9 100755
--- a/test/unittest/ip/test.x
+++ b/test/unittest/ip/test.x
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
-- 
2.25.0




More information about the DTrace-devel mailing list