[DTrace-devel] [PATCH 3/4] Test the dtrace provider cleanup mechanism

eugene.loh at oracle.com eugene.loh at oracle.com
Fri May 29 17:10:39 PDT 2020


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

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
---
 test/unittest/providers/tst.dtrace_cleanup.sh | 43 +++++++++++++++++++
 1 file changed, 43 insertions(+)
 create mode 100755 test/unittest/providers/tst.dtrace_cleanup.sh

diff --git a/test/unittest/providers/tst.dtrace_cleanup.sh b/test/unittest/providers/tst.dtrace_cleanup.sh
new file mode 100755
index 00000000..ee4892ff
--- /dev/null
+++ b/test/unittest/providers/tst.dtrace_cleanup.sh
@@ -0,0 +1,43 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2020, 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.
+
+##
+#
+# ASSERTION:
+# The dtrace probes BEGIN and END will create pid-tagged uprobes that
+# will be cleaned up when the dtrace process exits.
+#
+##
+
+dtrace=$1
+UPROBE_EVENTS=/sys/kernel/debug/tracing/uprobe_events
+
+$dtrace $dt_flags -n 'BEGIN {trace(1234)} END {trace(4321)}' &
+pid=$!
+
+sleep 1
+BEG0=`grep -c p:dt_${pid}_dtrace/BEGIN $UPROBE_EVENTS`
+END0=`grep -c p:dt_${pid}_dtrace/END   $UPROBE_EVENTS`
+
+kill $pid
+
+sleep 1
+BEG1=`grep -c p:dt_${pid}_dtrace/BEGIN $UPROBE_EVENTS`
+END1=`grep -c p:dt_${pid}_dtrace/END   $UPROBE_EVENTS`
+
+if [[ $BEG0 != 1 || \
+     $END0 != 1 || \
+     $BEG1 != 0 || \
+     $END1 != 0 ]]; then
+	echo "problem"
+	echo "actual: $BEG0 $END0 $BEG1 $END1"
+	echo "expect: 1 1 0 0"
+	exit 1
+fi
+
+exit 0
+
-- 
2.18.2




More information about the DTrace-devel mailing list