[DTrace-devel] [PATCH 4/5] test, usdt: test multiple simultaneous tracers of multiple processes
Nick Alcock
nick.alcock at oracle.com
Mon Apr 24 19:08:15 UTC 2023
We start them one after the other, to determine whether starting (or
starting tracing) one process affects the same active tracepoints in
other processes currently being traced.
Signed-off-by: Nick Alcock <nick.alcock at oracle.com>
---
test/unittest/usdt/tst.multitrace.r | 10 +++
test/unittest/usdt/tst.multitrace.sh | 92 ++++++++++++++++++++++++++++
2 files changed, 102 insertions(+)
create mode 100644 test/unittest/usdt/tst.multitrace.r
create mode 100755 test/unittest/usdt/tst.multitrace.sh
diff --git a/test/unittest/usdt/tst.multitrace.r b/test/unittest/usdt/tst.multitrace.r
new file mode 100644
index 0000000000000..14888902841fe
--- /dev/null
+++ b/test/unittest/usdt/tst.multitrace.r
@@ -0,0 +1,10 @@
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+test:main:go
+test:main:go
diff --git a/test/unittest/usdt/tst.multitrace.sh b/test/unittest/usdt/tst.multitrace.sh
new file mode 100755
index 0000000000000..b0dc6c4745fa1
--- /dev/null
+++ b/test/unittest/usdt/tst.multitrace.sh
@@ -0,0 +1,92 @@
+#!/bin/bash
+#
+# Oracle Linux DTrace.
+# Copyright (c) 2006, 2023, 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.
+#
+# Test multiple simultaneous tracers, invoked successively (so there
+# are multiple dtracers and multiple processes tracing the same probe).
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+CC=/usr/bin/gcc
+CFLAGS=
+
+DIRNAME="$tmpdir/usdt-multitrace.$$.$RANDOM"
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+cat > prov.d <<EOF
+provider test_prov {
+ probe go();
+ probe exiting();
+};
+EOF
+
+$dtrace -h -s prov.d
+if [ $? -ne 0 ]; then
+ echo "failed to generate header file" >& 2
+ exit 1
+fi
+
+cat > test.c <<EOF
+#include <sys/types.h>
+#include "prov.h"
+
+int
+main(int argc, char **argv)
+{
+ size_t i;
+ sleep(3); /* until we have startup sync */
+ for (i = 0; i < 5; i++) {
+ if (TEST_PROV_GO_ENABLED())
+ TEST_PROV_GO();
+ sleep(1);
+ }
+ TEST_PROV_EXITING();
+
+ return 0;
+}
+EOF
+
+${CC} ${CFLAGS} -c test.c
+if [ $? -ne 0 ]; then
+ echo "failed to compile test.c" >& 2
+ exit 1
+fi
+$dtrace -G -s prov.d test.o
+if [ $? -ne 0 ]; then
+ echo "failed to create DOF" >& 2
+ exit 1
+fi
+${CC} ${CFLAGS} -o test test.o prov.o
+if [ $? -ne 0 ]; then
+ echo "failed to link final executable" >& 2
+ exit 1
+fi
+
+script() {
+ $dtrace -qs /dev/stdin <<EOF | grep -v '^$'| grep -v '^$'
+ test_prov$1:::go
+ {
+ printf("%s:%s:%s\n", probemod, probefunc, probename);
+ }
+ test_prov$1:::exiting
+ {
+ exit(0);
+ }
+EOF
+}
+
+./test & script $! &
+sleep 2
+./test & script $! &
+wait
+
+status=$?
+
+exit $status
--
2.39.1.268.g9de2f9a303
More information about the DTrace-devel
mailing list