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

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Jun 3 10:46:21 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 | 44 +++++++++++++++++++
 1 file changed, 44 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..ea5b8101
--- /dev/null
+++ b/test/unittest/providers/tst.dtrace_cleanup.sh
@@ -0,0 +1,44 @@
+#!/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
+
+out=/tmp/output.$$
+$dtrace $dt_flags -n BEGIN -n END &>> $out &
+pid=$!
+
+tail -F $out | awk '/matched [1-9] probe/ { exit; }'
+
+BEG0=`grep -c p:dt_${pid}_dtrace/BEGIN $UPROBE_EVENTS`
+END0=`grep -c p:dt_${pid}_dtrace/END   $UPROBE_EVENTS`
+
+kill $pid
+wait $pid
+
+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 "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