test: Add USDT error tests for -w and -Z
PATCH v2 6/6 test: Add USDT error tests for -w and -Z
From: Eugene Loh <[email protected]>
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.
--- 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
test/unittest/usdt/err.Z_no-w.r new file +4 -0
@@ -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
test/unittest/usdt/err.Z_no-w.sh new file +65 -0
65 lines not on this page · raw message
test/unittest/usdt/err.no-Z.r new file +13 -0
@@ -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
test/unittest/usdt/err.no-Z.sh new file +31 -0
@@ -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
test/unittest/usdt/err.no-w.r new file +3 -0
@@ -0,0 +1,3 @@ +expected failure +-- @@stderr -- +dtrace: could not enable tracing: Destructive actions not allowed
test/unittest/usdt/err.no-w.sh new file +31 -0
@@ -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
Signature · 1 line
2.43.5
Quoted 14 lines · On Fri, Oct 04, 2024 at 12:55:08AM -0400, [email protected] wrote:
From: Eugene Loh <[email protected]>
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.
Quoted 7 lines
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 <[email protected]>
Quoted 201 lines
--- 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.shtest/unittest/usdt/err.Z_no-w.r new file +4
-0@@ -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 allowedtest/unittest/usdt/err.Z_no-w.sh new file +65
-0@@ -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 4 +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 1test/unittest/usdt/err.no-Z.r new file +13
-0@@ -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 probestest/unittest/usdt/err.no-Z.sh new file +31
-0@@ -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 0test/unittest/usdt/err.no-w.r new file +3
-0@@ -0,0 +1,3 @@ +expected failure +-- @@stderr -- +dtrace: could not enable tracing: Destructive actions not allowedtest/unittest/usdt/err.no-w.sh new file +31
-0@@ -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 0Signature · 1 line
2.43.5