[DTrace-devel] [PATCH 02/12] Check correctly for status of DTrace job

eugene.loh at oracle.com eugene.loh at oracle.com
Fri May 28 11:35:06 PDT 2021


From: Eugene Loh <eugene.loh at oracle.com>

A test launched a DTrace job in the background and was incorrectly
checking its status.  Specifically, it was passing spuriously.  Fix,
and for now mark XFAIL.

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 .../tst.jstack_unprintable-bug26045010.sh     | 29 ++++++++++++-------
 1 file changed, 19 insertions(+), 10 deletions(-)

diff --git a/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh b/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
index 9f6f6812..f81e1d33 100755
--- a/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
+++ b/test/unittest/ustack/tst.jstack_unprintable-bug26045010.sh
@@ -1,10 +1,11 @@
 #!/bin/bash
 #
 # Oracle Linux DTrace.
-# Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
+# @@xfail: dtv2
 if [ $# != 1 ]; then
 	echo expected one argument: '<'dtrace-path'>'
 	exit 2
@@ -45,19 +46,27 @@ EOF
 file=out.txt
 rm -f $file
 $dtrace -q $dt_flags -n 'profile-9 /execname == "java" && arg1/ { jstack(4); }' -o $file &
-sleep 1
+
+# confirm that the DTrace job is running successfully
+for nsecs in `seq 10`; do
+	sleep 1
+	jobs
+	if [ `jobs | wc -l` -eq 0 ]; then
+		echo DTrace job aborted early
+		cat $file
+		exit 1
+	fi
+done
+
+# run the Java job
 /usr/bin/java bug26045010
+
+# kill the DTrace job
 sleep 1
 kill %1
-sleep 1
-
-status=$?
-if [ "$status" -ne 0 ]; then
-        echo $tst: dtrace failed
-        rm -f $file
-        exit $status
-fi
+wait
 
+# check results
 n=`sed 's/[[:print:]]//g' $file | awk 'BEGIN {x = 0}; NF>0 {x += 1}; END {print x}'`
 if [ $n -gt 0 ]; then
         echo $tst: $n lines have unprintable characters
-- 
2.18.4




More information about the DTrace-devel mailing list