]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
FreeBSD regtest: add an amd64 test that max nb args to a syscall get passed correctly
authorPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 20 Sep 2025 17:16:38 +0000 (19:16 +0200)
committerPaul Floyd <pjfloyd@wanadoo.fr>
Sat, 20 Sep 2025 17:18:05 +0000 (19:18 +0200)
.gitignore
memcheck/tests/amd64-freebsd/filter_arg_check [new file with mode: 0755]
memcheck/tests/amd64-freebsd/scalar_arg_check.c [new file with mode: 0644]
memcheck/tests/amd64-freebsd/scalar_arg_check.stderr.exp [new file with mode: 0644]
memcheck/tests/amd64-freebsd/scalar_arg_check.vgtest [new file with mode: 0644]

index d548fb7bab3f52c80b72c218c32b4e37a44630b6..75675b1310aae48b9af13b747fcf075a5592ec9b 100644 (file)
 /memcheck/tests/amd64-freebsd/posix_fallocate
 /memcheck/tests/amd64-freebsd/reallocarray
 /memcheck/tests/amd64-freebsd/reallocf
+/memcheck/tests/amd64-freebsd/scalar_arg_check
 
 # /memcheck/tests/x86-freebsd
 /memcheck/tests/x86-freebsd/*.stderr.diff
diff --git a/memcheck/tests/amd64-freebsd/filter_arg_check b/memcheck/tests/amd64-freebsd/filter_arg_check
new file mode 100755 (executable)
index 0000000..334a326
--- /dev/null
@@ -0,0 +1,22 @@
+#! /bin/sh
+
+# Only one test uses this which calls syscall(SYS_sendfile)
+# which is the only amd64 syscall that uses 7 arguments
+# The output includes --trace-syscalls=yes which is very verbose
+# but we only want to see the sendfile line
+
+# the libc signature for sendfile is
+#     int sendfile(int fd, int s, off_t offset, size_t nbytes,
+#                  struct sf_hdtr *hdtr, off_t *sbytes, int flags);
+# The testcase uses values from 101 to 107 for the arguments
+# (to make it easy to match the testcase to the log output)
+# Some of the arguments are printed as hex, not too bad.
+# Argument 6 is an offset which seems to get added to some
+# variable length base address before being sent to the syscall.
+# I've checked with truss and ktrace, this doesn't come from Valgrind
+
+grep "SYSCALL.*sendfile" |
+sed 's/==.*//' |
+awk '{l=length($9);$9="0x"substr($9, l-2, l);print}' |
+sed -E 's/\[[0-9]{5}/[xxxxx/'
+
diff --git a/memcheck/tests/amd64-freebsd/scalar_arg_check.c b/memcheck/tests/amd64-freebsd/scalar_arg_check.c
new file mode 100644 (file)
index 0000000..cfa6d4e
--- /dev/null
@@ -0,0 +1,8 @@
+#include "../freebsd/scalar.h"
+
+int main(void)
+{
+   /* sendfile uses 7 args */
+   SY(SYS_sendfile, 101, 102, 103, 104, 105, 106, 107);
+}
+
diff --git a/memcheck/tests/amd64-freebsd/scalar_arg_check.stderr.exp b/memcheck/tests/amd64-freebsd/scalar_arg_check.stderr.exp
new file mode 100644 (file)
index 0000000..7b9fc63
--- /dev/null
@@ -0,0 +1 @@
+SYSCALL[xxxxx,1](393) sys_sendfile ( 101, 102, 103, 104, 0x69, 0x6a, 107 )
diff --git a/memcheck/tests/amd64-freebsd/scalar_arg_check.vgtest b/memcheck/tests/amd64-freebsd/scalar_arg_check.vgtest
new file mode 100644 (file)
index 0000000..b5c1520
--- /dev/null
@@ -0,0 +1,3 @@
+prog: scalar_arg_check
+vgopts: -q --trace-syscalls=yes
+stderr_filter: filter_arg_check