[DTrace-devel] [PATCH v2 09/14] test: caller and stackdepth tests for profile provider

eugene.loh at oracle.com eugene.loh at oracle.com
Wed Jun 25 04:21:02 UTC 2025


From: Eugene Loh <eugene.loh at oracle.com>

Signed-off-by: Eugene Loh <eugene.loh at oracle.com>
Reviewed-by: Nick Alcock <nick.alcock at oracle.com>
---
 test/unittest/builtinvar/tst.caller1.d        | 29 -------------------
 .../variables/bvar/tst.caller-profile.d       | 23 +++++++++++++++
 .../variables/bvar/tst.caller-profile.r       |  1 +
 .../variables/bvar/tst.caller-profile.r.p     |  1 +
 .../variables/bvar/tst.stackdepth-profile.d   | 25 ++++++++++++++++
 .../variables/bvar/tst.stackdepth-profile.r   |  1 +
 .../variables/bvar/tst.stackdepth-profile.r.p |  1 +
 7 files changed, 52 insertions(+), 29 deletions(-)
 delete mode 100644 test/unittest/builtinvar/tst.caller1.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-profile.d
 create mode 100644 test/unittest/variables/bvar/tst.caller-profile.r
 create mode 120000 test/unittest/variables/bvar/tst.caller-profile.r.p
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-profile.d
 create mode 100644 test/unittest/variables/bvar/tst.stackdepth-profile.r
 create mode 120000 test/unittest/variables/bvar/tst.stackdepth-profile.r.p

diff --git a/test/unittest/builtinvar/tst.caller1.d b/test/unittest/builtinvar/tst.caller1.d
deleted file mode 100644
index ca0f098f3..000000000
--- a/test/unittest/builtinvar/tst.caller1.d
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 2006, 2021, 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: To print caller from profile and make sure it succeeds.
- *
- * SECTION: Variables/Built-in Variables
- */
-
-#pragma D option quiet
-
-BEGIN
-{
-}
-
-tick-10ms
-{
-	printf("The caller is %u\n", caller);
-	exit (0);
-}
-
-ERROR
-{
-	exit(1);
-}
diff --git a/test/unittest/variables/bvar/tst.caller-profile.d b/test/unittest/variables/bvar/tst.caller-profile.d
new file mode 100644
index 000000000..82d21f784
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-profile.d
@@ -0,0 +1,23 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'caller' is consistent with stack(). */
+
+#pragma D option quiet
+
+profile:::tick-50ms
+/stackdepth > 1/
+{
+	stack(2);
+	sym(caller);
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
diff --git a/test/unittest/variables/bvar/tst.caller-profile.r b/test/unittest/variables/bvar/tst.caller-profile.r
new file mode 100644
index 000000000..2e9ba477f
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-profile.r
@@ -0,0 +1 @@
+success
diff --git a/test/unittest/variables/bvar/tst.caller-profile.r.p b/test/unittest/variables/bvar/tst.caller-profile.r.p
new file mode 120000
index 000000000..954ca96aa
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-profile.r.p
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.stackdepth-profile.d b/test/unittest/variables/bvar/tst.stackdepth-profile.d
new file mode 100644
index 000000000..614c43a08
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-profile.d
@@ -0,0 +1,25 @@
+/*
+ * Oracle Linux DTrace.
+ * Copyright (c) 2025, 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.
+ */
+/* Check that 'stackdepth' is consistent with stack(). */
+
+#pragma D option quiet
+
+profile:::tick-50ms
+/stackdepth > 1/
+{
+	printf("DEPTH %d\n", stackdepth);
+	printf("TRACE BEGIN\n");
+	stack(100);
+	printf("TRACE END\n");
+	exit(0);
+}
+
+ERROR
+{
+	printf("error encountered\n");
+	exit(1);
+}
diff --git a/test/unittest/variables/bvar/tst.stackdepth-profile.r b/test/unittest/variables/bvar/tst.stackdepth-profile.r
new file mode 100644
index 000000000..3bd29b8ed
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-profile.r
@@ -0,0 +1 @@
+Stack depth OK
diff --git a/test/unittest/variables/bvar/tst.stackdepth-profile.r.p b/test/unittest/variables/bvar/tst.stackdepth-profile.r.p
new file mode 120000
index 000000000..e50f12822
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-profile.r.p
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
-- 
2.43.5




More information about the DTrace-devel mailing list