[DTrace-devel] [PATCH v2 14/14] test: caller and stackdepth tests for lockstat provider
eugene.loh at oracle.com
eugene.loh at oracle.com
Wed Jun 25 04:21:07 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>
---
.../variables/bvar/skip_lockstat_5.10.x | 13 ++++++++++
.../variables/bvar/tst.caller-lockstat.d | 23 +++++++++++++++++
.../variables/bvar/tst.caller-lockstat.r | 1 +
.../variables/bvar/tst.caller-lockstat.r.p | 1 +
.../variables/bvar/tst.caller-lockstat.t | 3 +++
.../variables/bvar/tst.caller-lockstat.x | 1 +
.../variables/bvar/tst.stackdepth-lockstat.d | 25 +++++++++++++++++++
.../variables/bvar/tst.stackdepth-lockstat.r | 1 +
.../bvar/tst.stackdepth-lockstat.r.p | 1 +
.../variables/bvar/tst.stackdepth-lockstat.t | 3 +++
.../variables/bvar/tst.stackdepth-lockstat.x | 1 +
11 files changed, 73 insertions(+)
create mode 100755 test/unittest/variables/bvar/skip_lockstat_5.10.x
create mode 100644 test/unittest/variables/bvar/tst.caller-lockstat.d
create mode 100644 test/unittest/variables/bvar/tst.caller-lockstat.r
create mode 120000 test/unittest/variables/bvar/tst.caller-lockstat.r.p
create mode 100755 test/unittest/variables/bvar/tst.caller-lockstat.t
create mode 120000 test/unittest/variables/bvar/tst.caller-lockstat.x
create mode 100644 test/unittest/variables/bvar/tst.stackdepth-lockstat.d
create mode 100644 test/unittest/variables/bvar/tst.stackdepth-lockstat.r
create mode 120000 test/unittest/variables/bvar/tst.stackdepth-lockstat.r.p
create mode 100755 test/unittest/variables/bvar/tst.stackdepth-lockstat.t
create mode 120000 test/unittest/variables/bvar/tst.stackdepth-lockstat.x
diff --git a/test/unittest/variables/bvar/skip_lockstat_5.10.x b/test/unittest/variables/bvar/skip_lockstat_5.10.x
new file mode 100755
index 000000000..146443fd2
--- /dev/null
+++ b/test/unittest/variables/bvar/skip_lockstat_5.10.x
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+if [ $MAJOR -gt 5 ]; then
+ exit 0
+fi
+if [ $MAJOR -eq 5 -a $MINOR -ge 10 ]; then
+ exit 0
+fi
+
+echo "lockstat disabled prior to 5.10"
+exit 1
diff --git a/test/unittest/variables/bvar/tst.caller-lockstat.d b/test/unittest/variables/bvar/tst.caller-lockstat.d
new file mode 100644
index 000000000..fbd1f1ae0
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-lockstat.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
+
+lockstat:::*acquire
+/pid == $target/
+{
+ stack(2);
+ sym(caller);
+ exit(0);
+}
+
+ERROR
+{
+ printf("error encountered\n");
+ exit(1);
+}
diff --git a/test/unittest/variables/bvar/tst.caller-lockstat.r b/test/unittest/variables/bvar/tst.caller-lockstat.r
new file mode 100644
index 000000000..2e9ba477f
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-lockstat.r
@@ -0,0 +1 @@
+success
diff --git a/test/unittest/variables/bvar/tst.caller-lockstat.r.p b/test/unittest/variables/bvar/tst.caller-lockstat.r.p
new file mode 120000
index 000000000..954ca96aa
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-lockstat.r.p
@@ -0,0 +1 @@
+check_caller_to_stack2.awk
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.caller-lockstat.t b/test/unittest/variables/bvar/tst.caller-lockstat.t
new file mode 100755
index 000000000..fec0d2715
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-lockstat.t
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sleep 10s
diff --git a/test/unittest/variables/bvar/tst.caller-lockstat.x b/test/unittest/variables/bvar/tst.caller-lockstat.x
new file mode 120000
index 000000000..539f14255
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.caller-lockstat.x
@@ -0,0 +1 @@
+skip_lockstat_5.10.x
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.stackdepth-lockstat.d b/test/unittest/variables/bvar/tst.stackdepth-lockstat.d
new file mode 100644
index 000000000..de2b33dd4
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-lockstat.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
+
+lockstat:::*acquire
+/pid == $target/
+{
+ 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-lockstat.r b/test/unittest/variables/bvar/tst.stackdepth-lockstat.r
new file mode 100644
index 000000000..3bd29b8ed
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-lockstat.r
@@ -0,0 +1 @@
+Stack depth OK
diff --git a/test/unittest/variables/bvar/tst.stackdepth-lockstat.r.p b/test/unittest/variables/bvar/tst.stackdepth-lockstat.r.p
new file mode 120000
index 000000000..e50f12822
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-lockstat.r.p
@@ -0,0 +1 @@
+check_stackdepth_to_stack.awk
\ No newline at end of file
diff --git a/test/unittest/variables/bvar/tst.stackdepth-lockstat.t b/test/unittest/variables/bvar/tst.stackdepth-lockstat.t
new file mode 100755
index 000000000..fec0d2715
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-lockstat.t
@@ -0,0 +1,3 @@
+#!/bin/sh
+
+sleep 10s
diff --git a/test/unittest/variables/bvar/tst.stackdepth-lockstat.x b/test/unittest/variables/bvar/tst.stackdepth-lockstat.x
new file mode 120000
index 000000000..539f14255
--- /dev/null
+++ b/test/unittest/variables/bvar/tst.stackdepth-lockstat.x
@@ -0,0 +1 @@
+skip_lockstat_5.10.x
\ No newline at end of file
--
2.43.5
More information about the DTrace-devel
mailing list