Skip to contentSkip to conversation

test: Turn char[16] into string to ignore garbage bytes

PATCH In review [email protected] 2 participants 10 messages Oct 6, 2025 – Oct 7, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 test: Turn char[16] into string to ignore garbage bytes

From: Eugene Loh <[email protected]>

In commit 308e996c0 ("cg, agg: fix alignment of key components"), a new test test/unittest/aggs/tst.chararray-key.d used a char[16] as an agg key. The problem is that the char array, curpsinfo->pr_fname, could have garbage bytes after the first NUL byte, polluting test output.

Since we do not care about any such garbage bytes, convert to a string.

---
 test/unittest/aggs/tst.chararray-key.d | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/aggs/tst.chararray-key.d +1 -1
index af45d4a5e..2bb638372 100644
@@ -15,7 +15,7 @@
 
 BEGIN
 {
-	@[curpsinfo->pr_fname] = count();
+	@[(string)curpsinfo->pr_fname] = count();
 	exit(0);
 }
 
Signature · 1 line
2.47.3
#1 lore raw

PATCH 2/4 test: Use syscall in case of no execveat() wrapper

From: Eugene Loh <[email protected]>

While execveat() appeared in kernel 3.19, GNU C library support came later. We are still testing on some systems with older libc.

Do not assume libc has an execveat() wrapper: use syscall().

---
 test/unittest/proc/tst.exec-execveat.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/unittest/proc/tst.exec-execveat.sh +2 -2
index db68a5043..e4b9dfa5e 100755
@@ -17,7 +17,7 @@ cd $DIRNAME
 cat << EOF > parent.c
 #include <stdio.h>
 #include <linux/fcntl.h>      /* Definition of AT_* constants */
-#define __USE_GNU             /* so unistd.h will find execveat */
+#include <sys/syscall.h>      /* Definition of SYS_* constants */
 #include <unistd.h>
 
 int main(int c, char **v) {
@@ -26,7 +26,7 @@ int main(int c, char **v) {
   int rc;
 
   printf("exec\n");
-  rc = execveat(AT_FDCWD, "bogus_direc/bogus_exec", argv, envp, 0);
+  rc = syscall(__NR_execveat, AT_FDCWD, "bogus_direc/bogus_exec", argv, envp, 0);
 
   return 0;
 }
Signature · 1 line
2.47.3
Reviewed-by on v1 2/4
#2 lore raw

Re: [DTrace-devel] [PATCH 2/4] test: Use syscall in case of no execveat() wrapper

Quoted 4 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

While execveat() appeared in kernel 3.19, GNU C library support came later. We are still testing on some systems with older libc.

Wow, we do? I am curious where...

Quoted 3 lines

Do not assume libc has an execveat() wrapper: use syscall().

Quoted 34 lines
---
 test/unittest/proc/tst.exec-execveat.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
test/unittest/proc/tst.exec-execveat.sh +2 -2
index db68a5043..e4b9dfa5e 100755
@@ -17,7 +17,7 @@ cd $DIRNAME
 cat << EOF > parent.c
 #include <stdio.h>
 #include <linux/fcntl.h>      /* Definition of AT_* constants */
-#define __USE_GNU             /* so unistd.h will find execveat */
+#include <sys/syscall.h>      /* Definition of SYS_* constants */
 #include <unistd.h>
 
 int main(int c, char **v) {
@@ -26,7 +26,7 @@ int main(int c, char **v) {
   int rc;
 
   printf("exec\n");
-  rc = execveat(AT_FDCWD, "bogus_direc/bogus_exec", argv, envp, 0);
+  rc = syscall(__NR_execveat, AT_FDCWD, "bogus_direc/bogus_exec", argv, envp, 0);
 
   return 0;
 }
Signature · 7 lines
2.47.3


_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
author
#3 lore raw

Re: [DTrace-devel] [PATCH 2/4] test: Use syscall in case of no execveat() wrapper

Quoted 6 lines · Kris Van Hees
Quoted 4 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

While execveat() appeared in kernel 3.19, GNU C library support came later. We are still testing on some systems with older libc.

Wow, we do?

Yeah, I know.

Quoted 1 line

I am curious where...

E.g., I just launched a fresh OCI OL8 instance.

$ uname -r
5.15.0-312.187.5.1.el8uek.x86_64
$ ls -l /usr/lib64/libc.so*
-rw-r--r--. 1 root root 253 Aug  5 17:05 /usr/lib64/libc.so
lrwxrwxrwx. 1 root root  12 Aug  5 17:06 /usr/lib64/libc.so.6 -> libc-2.28.so
$ nm /usr/lib64/libc.so.6 |& grep execve
00000000000388d0 t __execve
00000000000388d0 W execve
0000000000108500 T fexecve
00000000000388d0 t __GI___execve
00000000000388d0 t __GI_execve

On an OL9 instance I get:

$ ls -l /usr/lib64/libc.*
-rw-r--r--. 1 root root 7000662 Aug  5 08:18 /usr/lib64/libc.a
-rw-r--r--. 1 root root     253 Aug  5 08:15 /usr/lib64/libc.so
-rwxr-xr-x. 1 root root 2544448 Aug  5 08:18 /usr/lib64/libc.so.6
$ nm /usr/lib64/libc.so.6 | grep execve
00000000000d9eb0 t __execve
00000000000d9eb0 W execve
00000000000fd300 T execveat
00000000000d9ee0 T fexecve
00000000000d9eb0 t __GI___execve
00000000000d9eb0 t __GI_execve
$ ldd --version
ldd (GNU libc) 2.34
Quoted 4 lines
Quoted 3 lines

Do not assume libc has an execveat() wrapper: use syscall().

Thanks.

#4 lore raw

PATCH 3/4 test: Supply XFAIL for tests that use vtimestamp

In reply to [email protected]

From: Eugene Loh <[email protected]>

---
 test/stress/fbtsafety/tst.index.d             | 2 ++
 test/stress/fbtsafety/tst.strjoin.d           | 2 ++
 test/stress/fbtsafety/tst.strstr.d            | 2 ++
 test/stress/fbtsafety/tst.strtok.d            | 2 ++
 test/stress/fbtsafety/tst.substr.d            | 2 ++
 test/unittest/variables/bvar/tst.vtimestamp.d | 2 +-
 6 files changed, 11 insertions(+), 1 deletion(-)
test/stress/fbtsafety/tst.index.d +2 -0
index e30b94c0a..3a2e40567 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.strjoin.d +2 -0
index a22cc7943..4192bdf9e 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.strstr.d +2 -0
index 13f4a9245..ee8512f0f 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.strtok.d +2 -0
index bc0a707eb..0c5d586fb 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.substr.d +2 -0
index 8cd021176..ee7234473 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/unittest/variables/bvar/tst.vtimestamp.d +1 -1
index b72eb8a7f..7d92bf4cc 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 need vtimestamp support */
+/* @@xfail: dtv2: need vtimestamp support */
 
 /*
  * ASSERTION: The 'vtimestamp' variable can be accessed and is not -1.
Signature · 1 line
2.47.3
#5 lore raw

Re: [DTrace-devel] [PATCH 3/4] test: Supply XFAIL for tests that use vtimestamp

Given that vtimestamp is used here in a way that is not actually depending on its meaning, I'd rather you just change the tests to not depend on vtimestamp, but instead use something else (e.g. timestamp).

XFAILing them does not seem to e right since vtimestamp is not relevant here.

Quoted 98 lines · eugene.loh--- via DTrace-devel

From: Eugene Loh <[email protected]>

---
 test/stress/fbtsafety/tst.index.d             | 2 ++
 test/stress/fbtsafety/tst.strjoin.d           | 2 ++
 test/stress/fbtsafety/tst.strstr.d            | 2 ++
 test/stress/fbtsafety/tst.strtok.d            | 2 ++
 test/stress/fbtsafety/tst.substr.d            | 2 ++
 test/unittest/variables/bvar/tst.vtimestamp.d | 2 +-
 6 files changed, 11 insertions(+), 1 deletion(-)
test/stress/fbtsafety/tst.index.d +2 -0
index e30b94c0a..3a2e40567 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.strjoin.d +2 -0
index a22cc7943..4192bdf9e 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.strstr.d +2 -0
index 13f4a9245..ee8512f0f 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.strtok.d +2 -0
index bc0a707eb..0c5d586fb 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/stress/fbtsafety/tst.substr.d +2 -0
index 8cd021176..ee7234473 100644
@@ -5,6 +5,8 @@
  * http://oss.oracle.com/licenses/upl.
  */
 
+/* @@xfail: dtv2: need vtimestamp support */
+
 #pragma D option bufsize=1000
 #pragma D option bufpolicy=ring
 #pragma D option statusrate=10ms
test/unittest/variables/bvar/tst.vtimestamp.d +1 -1
index b72eb8a7f..7d92bf4cc 100644
@@ -4,7 +4,7 @@
  * Licensed under the Universal Permissive License v 1.0 as shown at
  * http://oss.oracle.com/licenses/upl.
  */
-/* @@xfail: dtv2 need vtimestamp support */
+/* @@xfail: dtv2: need vtimestamp support */
 
 /*
  * ASSERTION: The 'vtimestamp' variable can be accessed and is not -1.
Signature · 7 lines
2.47.3


_______________________________________________
DTrace-devel mailing list
[email protected]
https://oss.oracle.com/mailman/listinfo/dtrace-devel
author
#6 lore raw

Re: [DTrace-devel] [PATCH 3/4] test: Supply XFAIL for tests that use vtimestamp

Okay.  I'm withdrawing this patch.  An alternative will be posted shortly.

Quoted 5 lines · Kris Van Hees

Given that vtimestamp is used here in a way that is not actually depending on its meaning, I'd rather you just change the tests to not depend on vtimestamp, but instead use something else (e.g. timestamp).

XFAILing them does not seem to e right since vtimestamp is not relevant here.

#7 lore raw

PATCH 4/4 test: Skip D return() action if kernel not configured right

In reply to [email protected]

From: Eugene Loh <[email protected]>

Most of the err.* tests can still be run, since they test other failure modes.

---
 .../unittest/actions/return/err.destructive.x |  1 +
 .../unittest/actions/return/tst.destructive.x | 67 +++++++++++++++++++
 .../return/tst.override-getpid-entry.x        |  1 +
 .../return/tst.override-getpid-return.x       |  1 +
 4 files changed, 70 insertions(+)
 create mode 120000 test/unittest/actions/return/err.destructive.x
 create mode 100755 test/unittest/actions/return/tst.destructive.x
 create mode 120000 test/unittest/actions/return/tst.override-getpid-entry.x
 create mode 120000 test/unittest/actions/return/tst.override-getpid-return.x
test/unittest/actions/return/err.destructive.x new file +1 -0
new file mode 120000
index 000000000..2cb5b1159
@@ -0,0 +1 @@
+tst.destructive.s
\ No newline at end of file
test/unittest/actions/return/tst.destructive.x new file +67 -0

67 lines not on this page · raw message

test/unittest/actions/return/tst.override-getpid-entry.x new file +1 -0
new file mode 120000
index 000000000..36e160027
@@ -0,0 +1 @@
+tst.destructive.x
\ No newline at end of file
test/unittest/actions/return/tst.override-getpid-return.x new file +1 -0
new file mode 120000
index 000000000..36e160027
@@ -0,0 +1 @@
+tst.destructive.x
\ No newline at end of file
Signature · 1 line
2.47.3
#8 lore raw

Re: [PATCH 4/4] test: Skip D return() action if kernel not configured right

Why not just check /sys/kernel/debug/error_injection/list?

Quoted 117 lines · On Mon, Oct 06, 2025 at 05:57:26PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

Most of the err.* tests can still be run, since they test other failure modes.

---
 .../unittest/actions/return/err.destructive.x |  1 +
 .../unittest/actions/return/tst.destructive.x | 67 +++++++++++++++++++
 .../return/tst.override-getpid-entry.x        |  1 +
 .../return/tst.override-getpid-return.x       |  1 +
 4 files changed, 70 insertions(+)
 create mode 120000 test/unittest/actions/return/err.destructive.x
 create mode 100755 test/unittest/actions/return/tst.destructive.x
 create mode 120000 test/unittest/actions/return/tst.override-getpid-entry.x
 create mode 120000 test/unittest/actions/return/tst.override-getpid-return.x
test/unittest/actions/return/err.destructive.x new file +1 -0
new file mode 120000
index 000000000..2cb5b1159
@@ -0,0 +1 @@
+tst.destructive.s
\ No newline at end of file
test/unittest/actions/return/tst.destructive.x new file +67 -0
new file mode 100755
index 000000000..d54bbb2fa
@@ -0,0 +1,67 @@
+#!/bin/bash
+#
+# 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.
+
+# For us to use the return() action, the kernel needs to be configured
+# properly.  In /usr/include/linux/bpf.h, we see that bpf_override_return()
+# needs both CONFIG_BPF_KPROBE_OVERRIDE and CONFIG_FUNCTION_ERROR_INJECTION.
+
+# To check kernel configuration parameters, check
+# https://docs.rockylinux.org/10/gemstones/core/view_kernel_conf/
+
+# Look for a file with kernel configuration parameters.
+
+file=""
+for x in \
+    /boot/config-$(uname -r) \
+    /lib/modules/$(uname -r)/config \
+    /lib/modules/$(uname -r)/build/.config \
+    /usr/src/kernels/$(uname -r)/.config \
+; do
+	if [ -e $x ]; then
+		file=$x
+	fi
+done
+
+# If such a file is found, look for the necessary parameters.
+
+if [ $file != "" ]; then
+	if ! grep -q CONFIG_BPF_KPROBE_OVERRIDE=y      $file; then
+		echo need CONFIG_BPF_KPROBE_OVERRIDE=y for D return action, not found in $file
+		exit 2
+	fi
+	if ! grep -q CONFIG_FUNCTION_ERROR_INJECTION=y $file; then
+		echo need CONFIG_FUNCTION_ERROR_INJECTION=y for D return action, not found in $file
+		exit 2
+	fi
+
+	exit 0
+fi
+
+# Some distributions, like Gentoo and Arch, use the configs kernel module to provide
+# /proc/config.gz by default instead.
+
+if [ -e /proc/config.gz ]; then
+	echo try gentoo
+   #    zcat /proc/config.gz | grep -i <keyword>
+   #    zgrep <keyword> /proc/config.gz
+	if ! zgrep -q CONFIG_BPF_KPROBE_OVERRIDE=y           /proc/config.gz; then
+		echo need CONFIG_BPF_KPROBE_OVERRIDE=y for D return action
+		exit 2
+	fi
+	if ! zgrep -q grep CONFIG_FUNCTION_ERROR_INJECTION=y /proc/config.gz; then
+		echo need CONFIG_FUNCTION_ERROR_INJECTION=y for D return action
+		exit 2
+	fi
+
+	exit 0
+fi
+
+
+# We cannot figure out the kernel configuration parameters.
+# Go ahead, run the test, and hope for the best.
+
+exit 0
test/unittest/actions/return/tst.override-getpid-entry.x new file +1 -0
new file mode 120000
index 000000000..36e160027
@@ -0,0 +1 @@
+tst.destructive.x
\ No newline at end of file
test/unittest/actions/return/tst.override-getpid-return.x new file +1 -0
new file mode 120000
index 000000000..36e160027
@@ -0,0 +1 @@
+tst.destructive.x
\ No newline at end of file
Signature · 1 line
2.47.3
Reviewed-by on v1 1/4
#9 lore raw
In reply to [email protected]
Quoted 10 lines · On Mon, Oct 06, 2025 at 05:57:23PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

In commit 308e996c0 ("cg, agg: fix alignment of key components"), a new test test/unittest/aggs/tst.chararray-key.d used a char[16] as an agg key. The problem is that the char array, curpsinfo->pr_fname, could have garbage bytes after the first NUL byte, polluting test output.

Since we do not care about any such garbage bytes, convert to a string.

Quoted 20 lines
---
 test/unittest/aggs/tst.chararray-key.d | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/aggs/tst.chararray-key.d +1 -1
index af45d4a5e..2bb638372 100644
@@ -15,7 +15,7 @@
 
 BEGIN
 {
-	@[curpsinfo->pr_fname] = count();
+	@[(string)curpsinfo->pr_fname] = count();
 	exit(0);
 }
 
Signature · 1 line
2.47.3