[DTrace-devel] [PATCH] test: ensure processes are ready for tracing in tst.manypids.tst

Kris Van Hees kris.van.hees at oracle.com
Fri Mar 8 15:28:17 UTC 2024


This tests depends on preloading a lot of libraries which can cause the
task startup to be slower than expected.  As a result, dtrace may fail
to enable probes.  This is typically the case if the preload libraries
and executable are not in cache yet.

We explicitly invoke /usr/bin/sleep right before starting the tasks to
be traced to prime the cache.

Signed-off-by: Kris Van Hees <kris.van.hees at oracle.com>
---
 test/unittest/pid/tst.manypids.sh | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/test/unittest/pid/tst.manypids.sh b/test/unittest/pid/tst.manypids.sh
index 1a98d621..5ae3a4c5 100755
--- a/test/unittest/pid/tst.manypids.sh
+++ b/test/unittest/pid/tst.manypids.sh
@@ -20,6 +20,10 @@ for lib in `ls -1 /lib64/lib*.so.1 | grep -v libthread_db.so.1`; do
 done
 
 export LD_PRELOAD=$preload
+# Force libraries and executable to get pulled into the cache so that starting
+# the disowned processes in the loop below will go fast enough that by the time
+# dtrace is started, all tasks are ready to be traced.
+/usr/bin/sleep 1
 
 let numkids=100
 let i=0
@@ -27,7 +31,7 @@ let i=0
 tmpfile=$tmpdir/dtest.$$
 
 while [ "$i" -lt "$numkids" ]; do
-	sleep 500 &
+	/usr/bin/sleep 500 &
 	pids[$i]=$!
         disown %+
 	let i=i+1
-- 
2.43.0




More information about the DTrace-devel mailing list