From: eugene.loh@oracle.com
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 6/6] test: Add USDT error tests for -w and -Z
Date: Fri, 27 Sep 2024 22:21:58 -0400 [thread overview]
Message-ID: <20240928022158.9206-6-eugene.loh@oracle.com> (raw)
In-Reply-To: <20240928022158.9206-1-eugene.loh@oracle.com>
From: Eugene Loh <eugene.loh@oracle.com>
Error checking for USDT probes can be different from other probes.
So add specific USDT tests for -Z and -w. Specifically:
err.no-Z No USDT process yet when dtrace is launched
and -Z is not specified. Therefore, dtrace
will not start up.
err.no-w A USDT process is running when dtrace is
launched, so -Z is not needed. However, the
action is destructive and -w is not specified.
Therefore, dtrace will not start up.
err.Z_no-w No USDT process yet when dtrace is launched,
but -Z is specified. So, dtrace starts
successfully. But the action is destructive
and -w is not specified. So when the USDT
process starts, dtrace fails.
Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
test/unittest/usdt/err.Z_no-w.r | 4 ++
test/unittest/usdt/err.Z_no-w.sh | 65 ++++++++++++++++++++++++++++++++
test/unittest/usdt/err.no-Z.r | 13 +++++++
test/unittest/usdt/err.no-Z.sh | 31 +++++++++++++++
test/unittest/usdt/err.no-w.r | 3 ++
test/unittest/usdt/err.no-w.sh | 31 +++++++++++++++
6 files changed, 147 insertions(+)
create mode 100644 test/unittest/usdt/err.Z_no-w.r
create mode 100755 test/unittest/usdt/err.Z_no-w.sh
create mode 100644 test/unittest/usdt/err.no-Z.r
create mode 100755 test/unittest/usdt/err.no-Z.sh
create mode 100644 test/unittest/usdt/err.no-w.r
create mode 100755 test/unittest/usdt/err.no-w.sh
diff --git a/test/unittest/usdt/err.Z_no-w.r b/test/unittest/usdt/err.Z_no-w.r
new file mode 100644
index 000000000..b81622481
--- /dev/null
+++ b/test/unittest/usdt/err.Z_no-w.r
@@ -0,0 +1,4 @@
+dtrace is running so start the trigger
+dtrace died as expected after trigger started
+-- @@stderr --
+dtrace: processing aborted: Destructive actions not allowed
diff --git a/test/unittest/usdt/err.Z_no-w.sh b/test/unittest/usdt/err.Z_no-w.sh
new file mode 100755
index 000000000..39b99c691
--- /dev/null
+++ b/test/unittest/usdt/err.Z_no-w.sh
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2024, 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.
+#
+# This test verifies that dtrace will not run a destructive script
+# for USDT probes if -w is not specified.
+#
+# Specifically, the script is launched with -Z and no USDT processes are
+# initially present. Only once a USDT process is detected does dtrace
+# fail due to the destructive action.
+
+dtrace=$1
+trigger=`pwd`/test/triggers/usdt-tst-defer
+
+# Set up test directory.
+
+DIRNAME=$tmpdir/Z_no-w.$$.$RANDOM
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# Make a private copy of the trigger executable so that we get our
+# own DOF stash.
+
+cp $trigger main
+
+# Run dtrace.
+
+$dtrace $dt_flags -Zq -o dtrace.out -n '
+testprov*:::foo
+{
+ raise(SIGUSR1);
+}' &
+dtpid=$!
+sleep 2
+if [[ ! -d /proc/$dtpid ]]; then
+ echo ERROR dtrace died prematurely
+ exit 1
+fi
+
+# Start a trigger process.
+
+echo dtrace is running so start the trigger
+./main > main.out &
+pid=$!
+
+# Check again if dtrace is still running.
+
+sleep 2
+if [[ ! -d /proc/$dtpid ]]; then
+ echo dtrace died as expected after trigger started
+else
+ echo dtrace is unexpectedly still running
+ kill -9 $dtpid
+ wait $dtpid
+fi
+
+# Tell the trigger to proceed to completion.
+
+kill -USR1 $pid
+wait $pid
+
+exit 1
diff --git a/test/unittest/usdt/err.no-Z.r b/test/unittest/usdt/err.no-Z.r
new file mode 100644
index 000000000..52d9492ab
--- /dev/null
+++ b/test/unittest/usdt/err.no-Z.r
@@ -0,0 +1,13 @@
+expected failure
+-- @@stderr --
+dtrace: invalid probe specifier
+BEGIN
+{
+ exit(0);
+}
+
+testprov*:::foo
+{
+ raise(SIGUSR1);
+ exit(0);
+}: probe description testprov*:::foo does not match any probes
diff --git a/test/unittest/usdt/err.no-Z.sh b/test/unittest/usdt/err.no-Z.sh
new file mode 100755
index 000000000..29d63d9ce
--- /dev/null
+++ b/test/unittest/usdt/err.no-Z.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2024, 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.
+#
+# This test verifies that dtrace will not wait for USDT processes to
+# appear if -Z is not used.
+
+dtrace=$1
+
+$dtrace $dt_flags -qn '
+BEGIN
+{
+ exit(0);
+}
+
+testprov*:::foo
+{
+ raise(SIGUSR1);
+ exit(0);
+}'
+if [ $? -ne 0 ]; then
+ echo expected failure
+ exit 1
+fi
+
+echo unexpected success
+
+exit 0
diff --git a/test/unittest/usdt/err.no-w.r b/test/unittest/usdt/err.no-w.r
new file mode 100644
index 000000000..7a4d60cd0
--- /dev/null
+++ b/test/unittest/usdt/err.no-w.r
@@ -0,0 +1,3 @@
+expected failure
+-- @@stderr --
+dtrace: could not enable tracing: Destructive actions not allowed
diff --git a/test/unittest/usdt/err.no-w.sh b/test/unittest/usdt/err.no-w.sh
new file mode 100755
index 000000000..407654981
--- /dev/null
+++ b/test/unittest/usdt/err.no-w.sh
@@ -0,0 +1,31 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2024, 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.
+#
+# This test verifies that dtrace will not run a destructive script
+# for USDT probes if -w is not specified.
+
+dtrace=$1
+
+$dtrace $dt_flags -c test/triggers/usdt-tst-defer -qn '
+BEGIN
+{
+ exit(0);
+}
+
+testprov*:::foo
+{
+ raise(SIGUSR1);
+ exit(0);
+}'
+if [ $? -ne 0 ]; then
+ echo expected failure
+ exit 1
+fi
+
+echo unexpected success
+
+exit 0
--
2.43.5
prev parent reply other threads:[~2024-09-28 2:22 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-28 2:21 [PATCH 1/6] Deferred attach of underlying USDT probes eugene.loh
2024-09-28 2:21 ` [PATCH 2/6] test: Correct long-standing dt_flags typo eugene.loh
2024-10-25 20:48 ` Kris Van Hees
2024-09-28 2:21 ` [PATCH 3/6] test: Remove some outdated and unhelpful comments eugene.loh
2024-10-25 20:53 ` Kris Van Hees
2024-09-28 2:21 ` [PATCH 4/6] test: Add a USDT "deferred" test trigger eugene.loh
2024-10-28 20:32 ` Kris Van Hees
2024-09-28 2:21 ` [PATCH 5/6] test: Add USDT tests for deferred detection eugene.loh
2024-09-28 2:21 ` eugene.loh [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240928022158.9206-6-eugene.loh@oracle.com \
--to=eugene.loh@oracle.com \
--cc=dtrace-devel@oss.oracle.com \
--cc=dtrace@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox