Linux DTrace development list
 help / color / mirror / Atom feed
From: Kris Van Hees <kris.van.hees@oracle.com>
To: dtrace@lists.linux.dev, dtrace-devel@oss.oracle.com
Subject: [PATCH 7/8] test: improve kernel read and subroutine coverage
Date: Mon, 28 Sep 2026 18:02:07 +0000	[thread overview]
Message-ID: <8b9d322753c7742be97236428c026bcb@oracle.com> (raw)

Signed-off-by: Kris Van Hees <kris.van.hees@oracle.com>
---
 .../codegen/tst.kernel_read_deref_struct.d    |  1 +
 .../codegen/tst.kernel_read_deref_struct.r.p  | 25 +++++++++++++++++++
 test/unittest/funcs/tst.subr.d                | 17 ++++++++++---
 test/unittest/funcs/tst.subr.r                | 13 ++++++++++
 4 files changed, 52 insertions(+), 4 deletions(-)
 create mode 100755 test/unittest/codegen/tst.kernel_read_deref_struct.r.p
 create mode 100644 test/unittest/funcs/tst.subr.r

diff --git a/test/unittest/codegen/tst.kernel_read_deref_struct.d b/test/unittest/codegen/tst.kernel_read_deref_struct.d
index c8ad5d3d..ca6b83cb 100644
--- a/test/unittest/codegen/tst.kernel_read_deref_struct.d
+++ b/test/unittest/codegen/tst.kernel_read_deref_struct.d
@@ -9,6 +9,7 @@
 
 BEGIN
 {
+	trace(sizeof(struct pid));
 	trace(*(struct pid *)`cad_pid);
 	exit(0);
 }
diff --git a/test/unittest/codegen/tst.kernel_read_deref_struct.r.p b/test/unittest/codegen/tst.kernel_read_deref_struct.r.p
new file mode 100755
index 00000000..d45aefe4
--- /dev/null
+++ b/test/unittest/codegen/tst.kernel_read_deref_struct.r.p
@@ -0,0 +1,25 @@
+#!/usr/bin/gawk -f
+
+NR == 1 {
+	expected = int($1);
+	print "Expect " expected " bytes";
+	next;
+}
+
+$1 ~ /^[0-9][0-9]*:$/ {
+	sub(/  .{16}$/, "");
+	got += NF - 1;
+
+	for (i = 2; i <= NF; i++)
+		not0 += ($i != "00");
+}
+
+END {
+	print "Got " got " bytes";
+	if (not0 == 0)
+		print "All zeros - read failure?";
+	else if (expected != got)
+		print "Data size mismatch";
+	else if (not0 < got / 4)
+		print "Too many zeros - check data?";
+}
diff --git a/test/unittest/funcs/tst.subr.d b/test/unittest/funcs/tst.subr.d
index d97a0780..1b9a6263 100644
--- a/test/unittest/funcs/tst.subr.d
+++ b/test/unittest/funcs/tst.subr.d
@@ -14,8 +14,17 @@
 	BEGIN				\
 	/*DSTYLED*/			\
 	{				\
+		this->ival = (long)(x);	\
 		subr++;			\
-		@[(long)x] = sum(1);	\
+	/*DSTYLED*/			\
+	}
+
+#define AINTFUNC(x)			\
+	BEGIN				\
+	/*DSTYLED*/			\
+	{				\
+		subr++;			\
+		this->aval = (long)(x);	\
 	/*DSTYLED*/			\
 	}
 
@@ -24,7 +33,7 @@
 	/*DSTYLED*/			\
 	{				\
 		subr++;			\
-		@str[x] = sum(1);	\
+		this->sval = (x);	\
 	/*DSTYLED*/			\
 	}
 
@@ -55,14 +64,14 @@ INTFUNC(mutex_type_spin((struct mutex *)&`bpf_verifier_lock))
 INTFUNC(rw_read_held((rwlock_t *)&`tasklist_lock))
 INTFUNC(rw_write_held((rwlock_t *)&`tasklist_lock))
 INTFUNC(rw_iswriter((rwlock_t *)&`tasklist_lock))
-INTFUNC(copyin(0, 1))
+AINTFUNC(copyin(0, 1))
 STRFUNC(copyinstr(0, 1))
 INTFUNC(speculation())
 INTFUNC(progenyof($pid))
 INTFUNC(strlen("fooey"))
 VOIDFUNC(copyout)
 VOIDFUNC(copyoutstr)
-INTFUNC(alloca(10))
+AINTFUNC(alloca(10))
 VOIDFUNC(bcopy)
 VOIDFUNC(copyinto)
 /* Not implemented.
diff --git a/test/unittest/funcs/tst.subr.r b/test/unittest/funcs/tst.subr.r
new file mode 100644
index 00000000..9dfa4b0e
--- /dev/null
+++ b/test/unittest/funcs/tst.subr.r
@@ -0,0 +1,13 @@
+                   FUNCTION:NAME
+                          :BEGIN 
+
+
+                1
+
+              libdtrace.so.2.0.0`BEGIN_probe
+              {ptr}
+                1
+-- @@stderr --
+dtrace: script 'test/unittest/funcs/tst.subr.d' matched 43 probes
+dtrace: error in dt_clause_8 for probe ID 1 (dtrace:::BEGIN): invalid address ({ptr}) at BPF pc NNN
+dtrace: error in dt_clause_9 for probe ID 1 (dtrace:::BEGIN): invalid address ({ptr}) at BPF pc NNN
-- 
2.52.0


             reply	other threads:[~2026-09-28 18:03 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-28 18:02 Kris Van Hees [this message]
2026-10-03  8:42 ` [DTrace-devel] [PATCH 7/8] test: improve kernel read and subroutine coverage Elena Zannoni

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8b9d322753c7742be97236428c026bcb@oracle.com \
    --to=kris.van.hees@oracle.com \
    --cc=dtrace-devel@oss.oracle.com \
    --cc=dtrace@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox