Skip to contentSkip to conversation

test: Remove unneeded skip for trigger

PATCH New [email protected] 1 participant 5 messages Dec 20, 2024

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 test: Remove unneeded skip for trigger

From: Eugene Loh <[email protected]>

---
 test/triggers/usdt-tst-multiprovider-prov.d | 2 --
 1 file changed, 2 deletions(-)
test/triggers/usdt-tst-multiprovider-prov.d +0 -2
index 530693ea7..aba458042 100644
@@ -5,8 +5,6 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
-/* @@skip: provider declaration - not a test */
-
 provider prova { probe entrya(); };
 provider provb { probe entryb(); probe entryc(int a, char *b) : (char * b, int a); };
 provider provc { probe entryd(); };
Signature · 1 line
2.43.5
#1 lore raw

PATCH 2/5 test: Embellish the USDT multiprovider test

From: Eugene Loh <[email protected]>

Add a probe to two providers, each probe with the same name but different arguments.

Do so in a new, separate test since the older test used to trigger some crashes, and we would like to continue to catch such problems.

Add -v to these probe-list tests to check attributes and arguments.

---
 test/triggers/Build                           |  5 +-
 .../usdt-tst-multiprov-dupprobe-prov.d        | 10 ++
 test/triggers/usdt-tst-multiprov-dupprobe.c   | 25 +++++
 test/unittest/usdt/tst.multiprov-dupprobe.r   | 93 +++++++++++++++++++
 test/unittest/usdt/tst.multiprov-dupprobe.r.p |  5 +
 test/unittest/usdt/tst.multiprov-dupprobe.sh  | 11 +++
 test/unittest/usdt/tst.multiprovider.r        | 65 ++++++++++++-
 test/unittest/usdt/tst.multiprovider.r.p      |  5 +-
 test/unittest/usdt/tst.multiprovider.sh       |  6 +-
 9 files changed, 214 insertions(+), 11 deletions(-)
 create mode 100644 test/triggers/usdt-tst-multiprov-dupprobe-prov.d
 create mode 100644 test/triggers/usdt-tst-multiprov-dupprobe.c
 create mode 100644 test/unittest/usdt/tst.multiprov-dupprobe.r
 create mode 100755 test/unittest/usdt/tst.multiprov-dupprobe.r.p
 create mode 100755 test/unittest/usdt/tst.multiprov-dupprobe.sh
test/triggers/Build +4 -1
index c50c265cc..3b5df3ece 100644
@@ -14,7 +14,7 @@ EXTERNAL_64BIT_TRIGGERS = testprobe readwholedir mmap bogus-ioctl open delaydie
     visible-constructor visible-constructor-static visible-constructor-static-unstripped
 
 EXTERNAL_64BIT_SDT_TRIGGERS = usdt-tst-argmap usdt-tst-args usdt-tst-forker usdt-tst-defer \
-    usdt-tst-multiprovider usdt-tst-special
+    usdt-tst-multiprovider usdt-tst-multiprov-dupprobe usdt-tst-special
 EXTERNAL_64BIT_TRIGGERS += $(EXTERNAL_64BIT_SDT_TRIGGERS)
 
 EXTERNAL_32BIT_TRIGGERS := visible-constructor-32
@@ -210,6 +210,9 @@ usdt-tst-defer_PROV := usdt-tst-defer-prov.d
 # usdt-tst-multiprovider calls USDT probes based on dtrace -h
 usdt-tst-multiprovider_PROV := usdt-tst-multiprovider-prov.d
 
+# usdt-tst-multiprov-dupprobe calls USDT probes based on dtrace -h
+usdt-tst-multiprov-dupprobe_PROV := usdt-tst-multiprov-dupprobe-prov.d
+
 # usdt-tst-special calls USDT probes based on dtrace -h
 usdt-tst-special_CFLAGS := -fno-inline -O2
 usdt-tst-special_PROV := usdt-tst-special-prov.d
test/triggers/usdt-tst-multiprov-dupprobe-prov.d new file +10 -0
new file mode 100644
index 000000000..04ef7245b
@@ -0,0 +1,10 @@
+/*
+ * 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.
+ */
+
+provider prova { probe entrya(); probe entrye(int a, char *b); };
+provider provb { probe entryb(); probe entryc(int a, char *b) : (char * b, int a); };
+provider provc { probe entryd(); probe entrye(char *a, int b); };
test/triggers/usdt-tst-multiprov-dupprobe.c new file +25 -0
new file mode 100644
index 000000000..2d5fa5fb5
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+/*
+ * A trigger with multiple providers in it.
+ */
+#include <stdio.h>
+#include <unistd.h>
+#include "usdt-tst-multiprov-dupprobe-prov.h"
+
+int main(int argc, char **argv)
+{
+	PROVA_ENTRYA();
+	PROVA_ENTRYE(123, "bar");
+	PROVB_ENTRYB();
+	PROVB_ENTRYC(666, "foo");
+	PROVC_ENTRYD();
+	PROVC_ENTRYE("baz", 456);
+	usleep(5 * 1000 * 1000);
+	return 0;
+}
test/unittest/usdt/tst.multiprov-dupprobe.r new file +93 -0

93 lines not on this page · raw message

test/unittest/usdt/tst.multiprov-dupprobe.r.p new file +5 -0
new file mode 100755
index 000000000..5d11db2d4
@@ -0,0 +1,5 @@
+#!/bin/sh
+
+# Remove banner.
+# Replace numerical values with generic PRID and PID labels.
+grep -v '^ *ID' | sed 's,^[0-9][0-9]*,PRID,; s,prov\(.\)[0-9]*,prov\1PID,; s,  *, ,g'
test/unittest/usdt/tst.multiprov-dupprobe.sh new file +11 -0
new file mode 100755
index 000000000..80b147974
@@ -0,0 +1,11 @@
+#!/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.
+#
+
+dtrace=$1
+
+exec $dtrace $dt_flags -lv -P 'prov*' -c `pwd`/test/triggers/usdt-tst-multiprov-dupprobe
test/unittest/usdt/tst.multiprovider.r +61 -4

65 lines not on this page · raw message

test/unittest/usdt/tst.multiprovider.r.p +4 -1
index ae8493e3d..5d11db2d4 100755
@@ -1,2 +1,5 @@
 #!/bin/sh
-grep -v '^ *ID' | sed 's,^[0-9]*,ID,; s,prov\(.\)[0-9]*,prov\1PID,; s,  *, ,g'
+
+# Remove banner.
+# Replace numerical values with generic PRID and PID labels.
+grep -v '^ *ID' | sed 's,^[0-9][0-9]*,PRID,; s,prov\(.\)[0-9]*,prov\1PID,; s,  *, ,g'
test/unittest/usdt/tst.multiprovider.sh +1 -5
index d5b72c2be..e84a24b7e 100755
@@ -5,11 +5,7 @@
 # Licensed under the Universal Permissive License v 1.0 as shown at
 # http://oss.oracle.com/licenses/upl.
 #
-if [ $# != 1 ]; then
-	echo expected one argument: '<'dtrace-path'>'
-	exit 2
-fi
 
 dtrace=$1
 
-exec $dtrace $dt_flags -l -P 'prov*' -c `pwd`/test/triggers/usdt-tst-multiprovider
+exec $dtrace $dt_flags -lv -P 'prov*' -c `pwd`/test/triggers/usdt-tst-multiprovider
Signature · 1 line
2.43.5
#2 lore raw

PATCH 3/5 test: Add USDT multiprovider tests that fire probes

In reply to [email protected]

From: Eugene Loh <[email protected]>

The multiprovider tests simply list probes. Add new tests that fire probes.

---
 test/unittest/usdt/tst.multiprov-dupprobe-fire.r | 10 ++++++++++
 .../usdt/tst.multiprov-dupprobe-fire.r.p         |  2 ++
 .../unittest/usdt/tst.multiprov-dupprobe-fire.sh | 16 ++++++++++++++++
 test/unittest/usdt/tst.multiprovider-fire.r      |  6 ++++++
 test/unittest/usdt/tst.multiprovider-fire.r.p    |  2 ++
 test/unittest/usdt/tst.multiprovider-fire.sh     | 14 ++++++++++++++
 6 files changed, 50 insertions(+)
 create mode 100644 test/unittest/usdt/tst.multiprov-dupprobe-fire.r
 create mode 100755 test/unittest/usdt/tst.multiprov-dupprobe-fire.r.p
 create mode 100755 test/unittest/usdt/tst.multiprov-dupprobe-fire.sh
 create mode 100644 test/unittest/usdt/tst.multiprovider-fire.r
 create mode 100755 test/unittest/usdt/tst.multiprovider-fire.r.p
 create mode 100755 test/unittest/usdt/tst.multiprovider-fire.sh
test/unittest/usdt/tst.multiprov-dupprobe-fire.r new file +10 -0
new file mode 100644
index 000000000..9563f80ff
@@ -0,0 +1,10 @@
+provaPID:usdt-tst-multiprov-dupprobe:main:entrya
+provaPID:usdt-tst-multiprov-dupprobe:main:entrye
+provaPID: 123 bar
+provbPID:usdt-tst-multiprov-dupprobe:main:entryb
+provbPID:usdt-tst-multiprov-dupprobe:main:entryc
+provbPID: foo 666
+provcPID:usdt-tst-multiprov-dupprobe:main:entryd
+provcPID:usdt-tst-multiprov-dupprobe:main:entrye
+provcPID: baz 456
+
test/unittest/usdt/tst.multiprov-dupprobe-fire.r.p new file +2 -0
new file mode 100755
index 000000000..bdbce0189
@@ -0,0 +1,2 @@
+#!/bin/sh
+sed 's,prov\(.\)[0-9]*,prov\1PID,; s,  *, ,g'
test/unittest/usdt/tst.multiprov-dupprobe-fire.sh new file +16 -0
new file mode 100755
index 000000000..d72724f4a
@@ -0,0 +1,16 @@
+#!/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.
+#
+
+dtrace=$1
+
+$dtrace $dt_flags -c `pwd`/test/triggers/usdt-tst-multiprov-dupprobe -qn '
+prov*::: { printf("%s:%s:%s:%s\n", probeprov, probemod, probefunc, probename); }
+prova$target:::entrye { printf("%s: %d %s\n", probeprov, arg0, stringof(arg1)); }
+provb$target:::entryc { printf("%s: %s %d\n", probeprov, stringof(arg0), arg1); }
+provc$target:::entrye { printf("%s: %s %d\n", probeprov, stringof(arg0), arg1); }
+'
test/unittest/usdt/tst.multiprovider-fire.r new file +6 -0
new file mode 100644
index 000000000..ea54cdbe6
@@ -0,0 +1,6 @@
+provaPID:usdt-tst-multiprovider:main:entrya
+provbPID:usdt-tst-multiprovider:main:entryb
+provbPID:usdt-tst-multiprovider:main:entryc
+provbPID: foo 666
+provcPID:usdt-tst-multiprovider:main:entryd
+
test/unittest/usdt/tst.multiprovider-fire.r.p new file +2 -0
new file mode 100755
index 000000000..bdbce0189
@@ -0,0 +1,2 @@
+#!/bin/sh
+sed 's,prov\(.\)[0-9]*,prov\1PID,; s,  *, ,g'
test/unittest/usdt/tst.multiprovider-fire.sh new file +14 -0
new file mode 100755
index 000000000..71337aa90
@@ -0,0 +1,14 @@
+#!/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.
+#
+
+dtrace=$1
+
+$dtrace $dt_flags -c `pwd`/test/triggers/usdt-tst-multiprovider -qn '
+prov*::: { printf("%s:%s:%s:%s\n", probeprov, probemod, probefunc, probename); }
+provb$target:::entryc { printf("%s: %s %d\n", probeprov, stringof(arg0), arg1); }
+'
Signature · 1 line
2.43.5
#3 lore raw

PATCH 4/5 test: USDT probes with multiple providers and shared libs

In reply to [email protected]

From: Eugene Loh <[email protected]>

A simple executable links in two shared libraries. There is a different USDT provider for the executable and for each of the two libraries. Each provider has probes named the same as for the other providers, but the probes differ in arguments.

Run dtrace on the executable. The D script first dumps the target pid for later post-processing. All USDT probes are traced and their argument values tested.

---
 .../usdt/tst.multiprov-dupprobe-shlibs.r      |  20 ++
 .../usdt/tst.multiprov-dupprobe-shlibs.r.p    |   7 +
 .../usdt/tst.multiprov-dupprobe-shlibs.sh     | 180 ++++++++++++++++++
 3 files changed, 207 insertions(+)
 create mode 100644 test/unittest/usdt/tst.multiprov-dupprobe-shlibs.r
 create mode 100755 test/unittest/usdt/tst.multiprov-dupprobe-shlibs.r.p
 create mode 100755 test/unittest/usdt/tst.multiprov-dupprobe-shlibs.sh
test/unittest/usdt/tst.multiprov-dupprobe-shlibs.r new file +20 -0
new file mode 100644
index 000000000..c3b21177d
@@ -0,0 +1,20 @@
+provmain$target:main:main:third
+provmain$target:::third abcdef 1234
+provliba$target:liba.so:libafunc:third
+provliba$target:::third 123 abc
+provliba$target:liba.so:libafunc:second
+provliba$target:::second 456
+provliba$target:liba.so:libafunc:first
+provliba$target:::first 789 def
+provmain$target:main:main:second
+provmain$target:::second 56 78 90
+provlibb$target:libb.so:libbfunc:third
+provlibb$target:::third 12 AB
+provlibb$target:libb.so:libbfunc:second
+provlibb$target:::second 34 CD
+provlibb$target:libb.so:libbfunc:first
+provlibb$target:::first 56
+provmain$target:main:main:first
+provmain$target:::first
+
+success
test/unittest/usdt/tst.multiprov-dupprobe-shlibs.r.p new file +7 -0
new file mode 100755
index 000000000..ff7128a2a
@@ -0,0 +1,7 @@
+#!/usr/bin/gawk -f
+
+# first line: get the target pid
+/^target = [0-9]*$/ { tgt = $3; next }
+
+# other lines: substitute the target pid with "$target"
+{ gsub(tgt, "$target"); print }
test/unittest/usdt/tst.multiprov-dupprobe-shlibs.sh new file +180 -0

180 lines not on this page · raw message

Signature · 1 line
2.43.5
#4 lore raw

PATCH 5/5 test: Disown child pid for cleaner stderr

In reply to [email protected]

From: Eugene Loh <[email protected]>

Extend commit 9546afc22 ("test: Disown child pid for cleaner stderr") to include another test.

---
 test/unittest/usdt/tst.dlclose4.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/usdt/tst.dlclose4.sh +1 -1
index c13404caf..a84e34600 100755
@@ -192,6 +192,7 @@ function unload_lib() {
 
 ./main &
 pid=$!
+disown %+
 sleep 2
 
 # Check.
@@ -204,7 +205,6 @@ unload_lib
 # Clean up.
 
 kill -s KILL $pid
-wait $pid >& /dev/null
 
 echo success
 exit 0
Signature · 1 line
2.43.5