Skip to contentSkip to conversation

test: stack_fbt

PATCH In review [email protected] 2 participants 6 messages Nov 7, 2024 – Nov 20, 2024

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 test: stack_fbt

From: Eugene Loh <[email protected]>

The test was being skipped on UEKR7 systems because __vfs_write was no longer traceable. The expected stack on UEKR6 x86_64 was out of date.

Switch to fbt::vfs_write:entry. Convert to a .sh test, so that different stacks can be expected depending both on machine type and release number.

---
 test/unittest/stack/tst.stack3_fbt.aarch64.r |  11 --
 test/unittest/stack/tst.stack3_fbt.d         |  25 ----
 test/unittest/stack/tst.stack3_fbt.x         |   1 -
 test/unittest/stack/tst.stack3_fbt.x86_64.r  |  11 --
 test/unittest/stack/tst.stack_fbt.aarch64.r  |  14 ---
 test/unittest/stack/tst.stack_fbt.d          |  25 ----
 test/unittest/stack/tst.stack_fbt.sh         | 122 +++++++++++++++++++
 test/unittest/stack/tst.stack_fbt.x          |  10 --
 test/unittest/stack/tst.stack_fbt.x86_64.r   |  13 --
 9 files changed, 122 insertions(+), 110 deletions(-)
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.aarch64.r
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.d
 delete mode 120000 test/unittest/stack/tst.stack3_fbt.x
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.x86_64.r
 delete mode 100644 test/unittest/stack/tst.stack_fbt.aarch64.r
 delete mode 100644 test/unittest/stack/tst.stack_fbt.d
 create mode 100755 test/unittest/stack/tst.stack_fbt.sh
 delete mode 100755 test/unittest/stack/tst.stack_fbt.x
 delete mode 100644 test/unittest/stack/tst.stack_fbt.x86_64.r
test/unittest/stack/tst.stack3_fbt.aarch64.r deleted +0 -11
deleted file mode 100644
index 5c8bfaed2..000000000
@@ -1,11 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__arm64_sys_write+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack3_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack3_fbt.d deleted +0 -25
deleted file mode 100644
index 1a2eaf582..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 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: Test the stack action with depth 3.
- *
- * SECTION: Output Formatting/printf()
- */
-
-#pragma D option destructive
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::__vfs_write:entry
-{
-	stack(3);
-	exit(0);
-}
test/unittest/stack/tst.stack3_fbt.x deleted +0 -1
deleted file mode 120000
index fe0d493c5..000000000
@@ -1 +0,0 @@
-tst.stack_fbt.x
\ No newline at end of file
test/unittest/stack/tst.stack3_fbt.x86_64.r deleted +0 -11
deleted file mode 100644
index f24c8cba5..000000000
@@ -1,11 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write+{ptr}
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__x64_sys_write+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack3_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack_fbt.aarch64.r deleted +0 -14
deleted file mode 100644
index 3a2896c48..000000000
@@ -1,14 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__arm64_sys_write+{ptr}
-              vmlinux`el0_svc_common+{ptr}
-              vmlinux`el0_svc_handler+{ptr}
-              vmlinux`el0_svc+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack_fbt.d deleted +0 -25
deleted file mode 100644
index 27db21164..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 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: Test the stack action with the default stack depth.
- *
- * SECTION: Output Formatting/printf()
- */
-
-#pragma D option destructive
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::__vfs_write:entry
-{
-	stack();
-	exit(0);
-}
test/unittest/stack/tst.stack_fbt.sh new file +122 -0

122 lines not on this page · raw message

test/unittest/stack/tst.stack_fbt.x deleted +0 -10
deleted file mode 100755
index 4561df8bb..000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
-
-if [ $MAJOR -eq 5 -a $MINOR -lt 8 ]; then
-	exit 0
-else
-	echo "Function __vfs_write no longer exists starting in 5.8"
-	exit 2
-fi
test/unittest/stack/tst.stack_fbt.x86_64.r deleted +0 -13
deleted file mode 100644
index 792ce80ad..000000000
@@ -1,13 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write+{ptr}
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__x64_sys_write+{ptr}
-              vmlinux`do_syscall_64+{ptr}
-              vmlinux`entry_SYSCALL_64+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
Signature · 1 line
2.43.5
Reviewed-by on v2 1/1
#1 lore raw
Quoted 11 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

The test was being skipped on UEKR7 systems because __vfs_write was no longer traceable. The expected stack on UEKR6 x86_64 was out of date.

Switch to fbt::vfs_write:entry. Convert to a .sh test, so that different stacks can be expected depending both on machine type and release number.

... with small changes as shown below.

Quoted 151 lines
---
 test/unittest/stack/tst.stack3_fbt.aarch64.r |  11 --
 test/unittest/stack/tst.stack3_fbt.d         |  25 ----
 test/unittest/stack/tst.stack3_fbt.x         |   1 -
 test/unittest/stack/tst.stack3_fbt.x86_64.r  |  11 --
 test/unittest/stack/tst.stack_fbt.aarch64.r  |  14 ---
 test/unittest/stack/tst.stack_fbt.d          |  25 ----
 test/unittest/stack/tst.stack_fbt.sh         | 122 +++++++++++++++++++
 test/unittest/stack/tst.stack_fbt.x          |  10 --
 test/unittest/stack/tst.stack_fbt.x86_64.r   |  13 --
 9 files changed, 122 insertions(+), 110 deletions(-)
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.aarch64.r
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.d
 delete mode 120000 test/unittest/stack/tst.stack3_fbt.x
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.x86_64.r
 delete mode 100644 test/unittest/stack/tst.stack_fbt.aarch64.r
 delete mode 100644 test/unittest/stack/tst.stack_fbt.d
 create mode 100755 test/unittest/stack/tst.stack_fbt.sh
 delete mode 100755 test/unittest/stack/tst.stack_fbt.x
 delete mode 100644 test/unittest/stack/tst.stack_fbt.x86_64.r
test/unittest/stack/tst.stack3_fbt.aarch64.r deleted +0 -11
deleted file mode 100644
index 5c8bfaed2..000000000
@@ -1,11 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__arm64_sys_write+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack3_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack3_fbt.d deleted +0 -25
deleted file mode 100644
index 1a2eaf582..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 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: Test the stack action with depth 3.
- *
- * SECTION: Output Formatting/printf()
- */
-
-#pragma D option destructive
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::__vfs_write:entry
-{
-	stack(3);
-	exit(0);
-}
test/unittest/stack/tst.stack3_fbt.x deleted +0 -1
deleted file mode 120000
index fe0d493c5..000000000
@@ -1 +0,0 @@
-tst.stack_fbt.x
\ No newline at end of file
test/unittest/stack/tst.stack3_fbt.x86_64.r deleted +0 -11
deleted file mode 100644
index f24c8cba5..000000000
@@ -1,11 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write+{ptr}
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__x64_sys_write+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack3_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack_fbt.aarch64.r deleted +0 -14
deleted file mode 100644
index 3a2896c48..000000000
@@ -1,14 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__arm64_sys_write+{ptr}
-              vmlinux`el0_svc_common+{ptr}
-              vmlinux`el0_svc_handler+{ptr}
-              vmlinux`el0_svc+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack_fbt.d deleted +0 -25
deleted file mode 100644
index 27db21164..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 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: Test the stack action with the default stack depth.
- *
- * SECTION: Output Formatting/printf()
- */
-
-#pragma D option destructive
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::__vfs_write:entry
-{
-	stack();
-	exit(0);
-}
test/unittest/stack/tst.stack_fbt.sh new file +0 -0
new file mode 100755
index 000000000..e60c519c8

test/unittest/stack/tst.stack_fbt.sh line 8

Quoted 8 lines
test/unittest/stack/tst.stack_fbt.sh new file +8 -0
@@ -0,0 +1,122 @@
+#!/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 the nusdtprobes option.

Surely this is a copy'n'paste error and should be removed? Or rather, it should be replaced with a message that actually states what this test exercises/verifies?

Shall I make it:

Test the stack action with default stack depth and depth 3.

test/unittest/stack/tst.stack_fbt.sh line 20

Quoted 12 lines
test/unittest/stack/tst.stack_fbt.sh new file +12 -0
+
+dtrace=$1
+
+# Set up test directory.
+
+DIRNAME=$tmpdir/stack_fbt.$$.$RANDOM
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# Use DTrace to capture stack() at vfs_write:entry.
+
+$dtrace $dt_flags $nusdt -wqn '

I assume $nusdt should not be used here.

Quoted 145 lines
test/unittest/stack/tst.stack_fbt.sh new file +102 -0
+BEGIN
+{
+	system("echo write something > /dev/null");
+}
+
+fbt::vfs_write:entry
+{
+	stack();
+	printf("first 3 frames\n");
+	stack(3);
+	exit(0);
+}' >& dtrace.out
+
+if [ $? -ne 0 ]; then
+	echo ERROR: dtrace failed
+	cat dtrace.out
+	exit 1
+fi
+
+# Strip out blank lines and pointer values.
+
+awk 'NF != 0 { sub(/+0x[0-9a-f]*$/, "+{ptr}"); print }' dtrace.out > dtrace.post
+if [ $? -ne 0 ]; then
+	echo ERROR: awk failed
+	cat dtrace.out
+	exit 1
+fi
+
+# Figure out what stack to expect.
+
+read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+if [ $MAJOR -eq 5 -a $MINOR -lt 8 ]; then
+	# up to 5.8
+	KERVER="A"
+else
+	# starting at 5.8
+	KERVER="B"
+fi
+
+if [ $(uname -m) == "x86_64" -a $KERVER == "A" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write+{ptr}
+              vmlinux\`__x64_sys_write+{ptr}
+              vmlinux\`x64_sys_call+{ptr}
+              vmlinux\`do_syscall_64+{ptr}
+              vmlinux\`entry_SYSCALL_64+{ptr}
+EOF
+elif [ $(uname -m) == "aarch64" -a $KERVER == "A" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write
+              vmlinux\`__arm64_sys_write+{ptr}
+              vmlinux\`el0_svc_common+{ptr}
+              vmlinux\`el0_svc_handler+{ptr}
+              vmlinux\`el0_svc+{ptr}
+EOF
+elif [ $(uname -m) == "x86_64" -a $KERVER == "B" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write+{ptr}
+              vmlinux\`ksys_write+{ptr}
+              vmlinux\`do_syscall_64+{ptr}
+              vmlinux\`entry_SYSCALL_64+{ptr}
+EOF
+elif [ $(uname -m) == "aarch64" -a $KERVER == "B" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write
+              vmlinux\`__arm64_sys_write+{ptr}
+              vmlinux\`invoke_syscall+{ptr}
+              vmlinux\`el0_svc_common+{ptr}
+              vmlinux\`do_el0_svc+{ptr}
+              vmlinux\`el0_svc+{ptr}
+              vmlinux\`el0t_64_sync_handler+{ptr}
+              vmlinux\`el0t_64_sync+{ptr}
+EOF
+else
+	echo ERROR: unrecognized platform
+	uname -r
+	uname -m
+	exit 1
+fi
+
+# Add the first 3 frames a second time.
+
+head -3 dtrace.cmp > dtrace.tmp
+echo first 3 frames >> dtrace.cmp
+cat dtrace.tmp >> dtrace.cmp
+
+# Compare results.
+
+if ! diff -q dtrace.cmp dtrace.post; then
+	echo ERROR: results do not match
+	diff dtrace.cmp dtrace.post
+	echo "==== expect"
+	cat dtrace.cmp
+	echo "==== actual"
+	cat dtrace.out
+	exit 1
+fi
+
+echo success
+
+exit 0
test/unittest/stack/tst.stack_fbt.x deleted +0 -10
deleted file mode 100755
index 4561df8bb..000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
-
-if [ $MAJOR -eq 5 -a $MINOR -lt 8 ]; then
-	exit 0
-else
-	echo "Function __vfs_write no longer exists starting in 5.8"
-	exit 2
-fi
test/unittest/stack/tst.stack_fbt.x86_64.r deleted +0 -13
deleted file mode 100644
index 792ce80ad..000000000
@@ -1,13 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write+{ptr}
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__x64_sys_write+{ptr}
-              vmlinux`do_syscall_64+{ptr}
-              vmlinux`entry_SYSCALL_64+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
Signature · 7 lines
2.43.5


_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
#2 lore raw
Quoted 11 lines · Kris Van Hees
Quoted 10 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

The test was being skipped on UEKR7 systems because __vfs_write was no longer traceable. The expected stack on UEKR6 x86_64 was out of date.

Switch to fbt::vfs_write:entry. Convert to a .sh test, so that different stacks can be expected depending both on machine type and release number.

Quoted 5 lines
Quoted 1 line

... with small changes as shown below.

Also... the full stack output comparison is riddled with issues because the low level entry point handling for syscalls is an atrea that has changed a lot and still changes. E.g. this test fails now on a 6.8.8 upstream kernel because of the following difference:

< vmlinux`entry_SYSCALL_64+{ptr}
---

Quoted 1 line
              vmlinux`entry_SYSCALL_64_after_hwframe+{ptr}

Maybe it would be better to not bother trying to test the full stack trace because it is bound to keep changing and we'll keep needing to update the test to deal with various kernel versions. After all, we do need to be able to pass tests with upstream kernels also.

Quoted 328 lines
Quoted 151 lines
---
 test/unittest/stack/tst.stack3_fbt.aarch64.r |  11 --
 test/unittest/stack/tst.stack3_fbt.d         |  25 ----
 test/unittest/stack/tst.stack3_fbt.x         |   1 -
 test/unittest/stack/tst.stack3_fbt.x86_64.r  |  11 --
 test/unittest/stack/tst.stack_fbt.aarch64.r  |  14 ---
 test/unittest/stack/tst.stack_fbt.d          |  25 ----
 test/unittest/stack/tst.stack_fbt.sh         | 122 +++++++++++++++++++
 test/unittest/stack/tst.stack_fbt.x          |  10 --
 test/unittest/stack/tst.stack_fbt.x86_64.r   |  13 --
 9 files changed, 122 insertions(+), 110 deletions(-)
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.aarch64.r
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.d
 delete mode 120000 test/unittest/stack/tst.stack3_fbt.x
 delete mode 100644 test/unittest/stack/tst.stack3_fbt.x86_64.r
 delete mode 100644 test/unittest/stack/tst.stack_fbt.aarch64.r
 delete mode 100644 test/unittest/stack/tst.stack_fbt.d
 create mode 100755 test/unittest/stack/tst.stack_fbt.sh
 delete mode 100755 test/unittest/stack/tst.stack_fbt.x
 delete mode 100644 test/unittest/stack/tst.stack_fbt.x86_64.r
test/unittest/stack/tst.stack3_fbt.aarch64.r deleted +0 -11
deleted file mode 100644
index 5c8bfaed2..000000000
@@ -1,11 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__arm64_sys_write+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack3_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack3_fbt.d deleted +0 -25
deleted file mode 100644
index 1a2eaf582..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 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: Test the stack action with depth 3.
- *
- * SECTION: Output Formatting/printf()
- */
-
-#pragma D option destructive
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::__vfs_write:entry
-{
-	stack(3);
-	exit(0);
-}
test/unittest/stack/tst.stack3_fbt.x deleted +0 -1
deleted file mode 120000
index fe0d493c5..000000000
@@ -1 +0,0 @@
-tst.stack_fbt.x
\ No newline at end of file
test/unittest/stack/tst.stack3_fbt.x86_64.r deleted +0 -11
deleted file mode 100644
index f24c8cba5..000000000
@@ -1,11 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write+{ptr}
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__x64_sys_write+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack3_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack_fbt.aarch64.r deleted +0 -14
deleted file mode 100644
index 3a2896c48..000000000
@@ -1,14 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__arm64_sys_write+{ptr}
-              vmlinux`el0_svc_common+{ptr}
-              vmlinux`el0_svc_handler+{ptr}
-              vmlinux`el0_svc+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
test/unittest/stack/tst.stack_fbt.d deleted +0 -25
deleted file mode 100644
index 27db21164..000000000
@@ -1,25 +0,0 @@
-/*
- * Oracle Linux DTrace.
- * Copyright (c) 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: Test the stack action with the default stack depth.
- *
- * SECTION: Output Formatting/printf()
- */
-
-#pragma D option destructive
-
-BEGIN
-{
-	system("echo write something > /dev/null");
-}
-
-fbt::__vfs_write:entry
-{
-	stack();
-	exit(0);
-}
test/unittest/stack/tst.stack_fbt.sh new file +0 -0
new file mode 100755
index 000000000..e60c519c8

test/unittest/stack/tst.stack_fbt.sh line 8

Quoted 8 lines
test/unittest/stack/tst.stack_fbt.sh new file +8 -0
@@ -0,0 +1,122 @@
+#!/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 the nusdtprobes option.

Surely this is a copy'n'paste error and should be removed? Or rather, it should be replaced with a message that actually states what this test exercises/verifies?

Shall I make it:

Test the stack action with default stack depth and depth 3.

test/unittest/stack/tst.stack_fbt.sh line 20

Quoted 12 lines
test/unittest/stack/tst.stack_fbt.sh new file +12 -0
+
+dtrace=$1
+
+# Set up test directory.
+
+DIRNAME=$tmpdir/stack_fbt.$$.$RANDOM
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# Use DTrace to capture stack() at vfs_write:entry.
+
+$dtrace $dt_flags $nusdt -wqn '

I assume $nusdt should not be used here.

Quoted 145 lines
test/unittest/stack/tst.stack_fbt.sh new file +102 -0
+BEGIN
+{
+	system("echo write something > /dev/null");
+}
+
+fbt::vfs_write:entry
+{
+	stack();
+	printf("first 3 frames\n");
+	stack(3);
+	exit(0);
+}' >& dtrace.out
+
+if [ $? -ne 0 ]; then
+	echo ERROR: dtrace failed
+	cat dtrace.out
+	exit 1
+fi
+
+# Strip out blank lines and pointer values.
+
+awk 'NF != 0 { sub(/+0x[0-9a-f]*$/, "+{ptr}"); print }' dtrace.out > dtrace.post
+if [ $? -ne 0 ]; then
+	echo ERROR: awk failed
+	cat dtrace.out
+	exit 1
+fi
+
+# Figure out what stack to expect.
+
+read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
+
+if [ $MAJOR -eq 5 -a $MINOR -lt 8 ]; then
+	# up to 5.8
+	KERVER="A"
+else
+	# starting at 5.8
+	KERVER="B"
+fi
+
+if [ $(uname -m) == "x86_64" -a $KERVER == "A" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write+{ptr}
+              vmlinux\`__x64_sys_write+{ptr}
+              vmlinux\`x64_sys_call+{ptr}
+              vmlinux\`do_syscall_64+{ptr}
+              vmlinux\`entry_SYSCALL_64+{ptr}
+EOF
+elif [ $(uname -m) == "aarch64" -a $KERVER == "A" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write
+              vmlinux\`__arm64_sys_write+{ptr}
+              vmlinux\`el0_svc_common+{ptr}
+              vmlinux\`el0_svc_handler+{ptr}
+              vmlinux\`el0_svc+{ptr}
+EOF
+elif [ $(uname -m) == "x86_64" -a $KERVER == "B" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write+{ptr}
+              vmlinux\`ksys_write+{ptr}
+              vmlinux\`do_syscall_64+{ptr}
+              vmlinux\`entry_SYSCALL_64+{ptr}
+EOF
+elif [ $(uname -m) == "aarch64" -a $KERVER == "B" ]; then
+cat << EOF > dtrace.cmp
+              vmlinux\`vfs_write
+              vmlinux\`__arm64_sys_write+{ptr}
+              vmlinux\`invoke_syscall+{ptr}
+              vmlinux\`el0_svc_common+{ptr}
+              vmlinux\`do_el0_svc+{ptr}
+              vmlinux\`el0_svc+{ptr}
+              vmlinux\`el0t_64_sync_handler+{ptr}
+              vmlinux\`el0t_64_sync+{ptr}
+EOF
+else
+	echo ERROR: unrecognized platform
+	uname -r
+	uname -m
+	exit 1
+fi
+
+# Add the first 3 frames a second time.
+
+head -3 dtrace.cmp > dtrace.tmp
+echo first 3 frames >> dtrace.cmp
+cat dtrace.tmp >> dtrace.cmp
+
+# Compare results.
+
+if ! diff -q dtrace.cmp dtrace.post; then
+	echo ERROR: results do not match
+	diff dtrace.cmp dtrace.post
+	echo "==== expect"
+	cat dtrace.cmp
+	echo "==== actual"
+	cat dtrace.out
+	exit 1
+fi
+
+echo success
+
+exit 0
test/unittest/stack/tst.stack_fbt.x deleted +0 -10
deleted file mode 100755
index 4561df8bb..000000000
@@ -1,10 +0,0 @@
-#!/bin/bash
-
-read MAJOR MINOR <<< `uname -r | grep -Eo '^[0-9]+\.[0-9]+' | tr '.' ' '`
-
-if [ $MAJOR -eq 5 -a $MINOR -lt 8 ]; then
-	exit 0
-else
-	echo "Function __vfs_write no longer exists starting in 5.8"
-	exit 2
-fi
test/unittest/stack/tst.stack_fbt.x86_64.r deleted +0 -13
deleted file mode 100644
index 792ce80ad..000000000
@@ -1,13 +0,0 @@
-                   FUNCTION:NAME
-                          :BEGIN 
-               __vfs_write:entry 
-              vmlinux`__vfs_write+{ptr}
-              vmlinux`ksys_write+{ptr}
-              vmlinux`__x64_sys_write+{ptr}
-              vmlinux`do_syscall_64+{ptr}
-              vmlinux`entry_SYSCALL_64+{ptr}
-
-
--- @@stderr --
-dtrace: script 'test/unittest/stack/tst.stack_fbt.d' matched 2 probes
-dtrace: allowing destructive actions
Signature · 7 lines
2.43.5


_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
author
#3 lore raw
Quoted 13 lines · Kris Van Hees
Quoted 7 lines · Kris Van Hees
Quoted 3 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

... with small changes as shown below.

Also... the full stack output comparison is riddled with issues because the low level entry point handling for syscalls is an atrea that has changed a lot and still changes. E.g. this test fails now on a 6.8.8 upstream kernel because of the following difference:

Quoted 7 lines

< vmlinux`entry_SYSCALL_64+{ptr}
---

Quoted 1 line
               vmlinux`entry_SYSCALL_64_after_hwframe+{ptr}

Maybe it would be better to not bother trying to test the full stack trace because it is bound to keep changing and we'll keep needing to update the test to deal with various kernel versions. After all, we do need to be able to pass tests with upstream kernels also.

Maybe.  Or we just bite the bullet and add more cases as they become needed.  After all, there is a framework here for being able to add new cases in the future.  There is the usual tension between simpler tests and more rigorous testing.

#4 lore raw
Quoted 23 lines · Eugene Loh
Quoted 13 lines · Kris Van Hees
Quoted 7 lines · Kris Van Hees
Quoted 3 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

... with small changes as shown below.

Also... the full stack output comparison is riddled with issues because the low level entry point handling for syscalls is an atrea that has changed a lot and still changes. E.g. this test fails now on a 6.8.8 upstream kernel because of the following difference:

Quoted 7 lines

< vmlinux`entry_SYSCALL_64+{ptr}
---

Quoted 1 line
               vmlinux`entry_SYSCALL_64_after_hwframe+{ptr}

Maybe it would be better to not bother trying to test the full stack trace because it is bound to keep changing and we'll keep needing to update the test to deal with various kernel versions. After all, we do need to be able to pass tests with upstream kernels also.

Quoted 4 lines

Maybe.  Or we just bite the bullet and add more cases as they become needed.  After all, there is a framework here for being able to add new cases in the future.  There is the usual tension between simpler tests and more rigorous testing.

Yes, my challenge right now is that I really do not want to try this test on a large variety of kernel versions to ensure that we cover the "most likely cases" of kernels people might be wanting to use (and test) DTrace on. That is a recipe for fa massive headache.

author
#5 lore raw
In reply to Kris Van Hees
Quoted 8 lines · Kris Van Hees
Quoted 3 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

... with small changes as shown below.

Quoted 7 lines

test/unittest/stack/tst.stack_fbt.sh line 3

Quoted 6 lines
test/unittest/stack/tst.stack_fbt.sh new file +3 -0
new file mode 100755
@@ -0,0 +1,122 @@
+#!/bin/bash
+#
+# This test verifies the nusdtprobes option.

Surely this is a copy'n'paste error and should be removed?

Goodness.  Yes.  Good thing that at least one of us is reading this stuff!  Oops.

Quoted 7 lines

Or rather, it
should be replaced with a message that actually states what this test exercises/verifies?

Shall I make it:

Test the stack action with default stack depth and depth 3.

Thanks.  Well put.

Quoted 5 lines
Quoted 5 lines
test/unittest/stack/tst.stack_fbt.sh new file +5 -0
+
+dtrace=$1
+
+# Set up test directory.
+
Quoted 8 lines

test/unittest/stack/tst.stack_fbt.sh line 20

Quoted 7 lines
test/unittest/stack/tst.stack_fbt.sh new file +7 -0
+DIRNAME=$tmpdir/stack_fbt.$$.$RANDOM
+mkdir -p $DIRNAME
+cd $DIRNAME
+
+# Use DTrace to capture stack() at vfs_write:entry.
+
+$dtrace $dt_flags $nusdt -wqn '

I assume $nusdt should not be used here.

Sigh.  Right.