All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] test: Allow duplicate usym/umod/uaddr if for different pids
@ 2024-12-05 19:13 eugene.loh
  2025-01-06 21:04 ` Kris Van Hees
  0 siblings, 1 reply; 5+ messages in thread
From: eugene.loh @ 2024-12-05 19:13 UTC (permalink / raw)
  To: dtrace, dtrace-devel

From: Eugene Loh <eugene.loh@oracle.com>

In 83da884cbdc5 ("Preface usym/umod/uaddr with pid"), a bug was fixed
in which addresses in the same module (or function) might be mapped to
multiple agg entries.  This fix helped the associated tests run much
more successfully.  Nonetheless, tests would sometimes still fail.

Another problem is that the tests themselves were overly narrow.  It
is fine for a module (or function) to appear multiple times in the
aggregation output... if those entries correspond to different pids.

Further, odd behaviors can result for some of the processes running on
a system.

Change the tests to add a "pid" agg key.  Filter on only a few, select
pids.  Distinguish agg entries by pid.

There are still occasional time outs observed with these tests,
presumably because the tick-2s probe is not firing (when profile-1234hz
is running).

Signed-off-by: Eugene Loh <eugene.loh@oracle.com>
---
 test/unittest/profile-n/tst.ufunc.sh | 12 ++++++++----
 test/unittest/profile-n/tst.umod.sh  | 11 ++++++++---
 test/unittest/profile-n/tst.usym.sh  | 11 ++++++++---
 3 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/test/unittest/profile-n/tst.ufunc.sh b/test/unittest/profile-n/tst.ufunc.sh
index 243822407..f5174a1e2 100755
--- a/test/unittest/profile-n/tst.ufunc.sh
+++ b/test/unittest/profile-n/tst.ufunc.sh
@@ -11,10 +11,14 @@ tmpfile=$tmpdir/tst.profile_ufunc.$$
 script()
 {
 	$dtrace $dt_flags -qs /dev/stdin <<EOF
+	BEGIN
+	{
+		printf("dtrace is %d\n", \$pid);
+	}
 	profile-1234hz
 	/arg1 != 0/
 	{
-		@[ufunc(arg1)] = count();
+		@[ufunc(arg1), pid] = count();
 	}
 
 	tick-2s
@@ -52,9 +56,9 @@ if ! grep -q 'bash`[a-zA-Z_]' $tmpfile; then
 	status=1
 fi
 
-# Check that functions are unique.  (Exclude shared libraries and unresolved addresses.)
-if gawk '!/^ *(ld-linux-|lib|([^`]*`)?0x)/ {print $1}' $tmpfile | \
-     sort | uniq -c | grep -qv " 1 "; then
+# Check that functions are unique for each pid that interests us.
+dtpid=`awk '/^dtrace is [0-9]*$/ { print $3 }' $tmpfile`
+if gawk '$2 == '$child' || $2 == '$dtpid' {print $1, $2}' $tmpfile | sort | uniq -c | grep -qv " 1 "; then
 	echo ERROR: duplicate ufunc
 	status=1
 fi
diff --git a/test/unittest/profile-n/tst.umod.sh b/test/unittest/profile-n/tst.umod.sh
index 45d2b1e9b..7cfe2a073 100755
--- a/test/unittest/profile-n/tst.umod.sh
+++ b/test/unittest/profile-n/tst.umod.sh
@@ -11,10 +11,14 @@ tmpfile=$tmpdir/tst.profile_umod.$$
 script()
 {
 	$dtrace $dt_flags -qs /dev/stdin <<EOF
+	BEGIN
+	{
+		printf("dtrace is %d\n", \$pid);
+	}
 	profile-1234hz
 	/arg1 != 0/
 	{
-		@[umod(arg1)] = count();
+		@[umod(arg1), pid] = count();
 	}
 
 	tick-2s
@@ -52,8 +56,9 @@ if ! grep -wq 'bash' $tmpfile; then
 	status=1
 fi
 
-# Check that modules are unique.  (Exclude shared libraries and unresolved addresses.)
-if gawk '!/^ *lib/ && !/^ *ld-.*\.so / && !/^ *0x/ {print $1}' $tmpfile | sort | uniq -c | grep -qv " 1 "; then
+# Check that modules are unique for each pid that interests us.
+dtpid=`awk '/^dtrace is [0-9]*$/ { print $3 }' $tmpfile`
+if gawk '$2 == '$child' || $2 == '$dtpid' {print $1, $2}' $tmpfile | sort | uniq -c | grep -qv " 1 "; then
 	echo ERROR: duplicate umod
 	status=1
 fi
diff --git a/test/unittest/profile-n/tst.usym.sh b/test/unittest/profile-n/tst.usym.sh
index 634e633b3..8e373b976 100755
--- a/test/unittest/profile-n/tst.usym.sh
+++ b/test/unittest/profile-n/tst.usym.sh
@@ -11,10 +11,14 @@ tmpfile=$tmpdir/tst.profile_usym.$$
 script()
 {
 	$dtrace $dt_flags -qs /dev/stdin <<EOF
+	BEGIN
+	{
+		printf("dtrace is %d\n", \$pid);
+	}
 	profile-1234hz
 	/arg1 != 0/
 	{
-		@[usym(arg1)] = count();
+		@[usym(arg1), pid] = count();
 	}
 
 	tick-2s
@@ -52,8 +56,9 @@ if ! grep -q 'bash`[a-zA-Z_]' $tmpfile; then
 	status=1
 fi
 
-# Check that symbols are unique.  (Exclude shared libraries and unresolved addresses.)
-if gawk '!/^ *lib/ && !/^ *0x/ {print $1}' $tmpfile | sort | uniq -c | grep -qv " 1 "; then
+# Check that symbols are unique for each pid that interests us.
+dtpid=`awk '/^dtrace is [0-9]*$/ { print $3 }' $tmpfile`
+if gawk '$2 == '$child' || $2 == '$dtpid' {print $1, $2}' $tmpfile | sort | uniq -c | grep -qv " 1 "; then
 	echo ERROR: duplicate usym
 	status=1
 fi
-- 
2.43.5


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-02-27 21:44 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-05 19:13 [PATCH] test: Allow duplicate usym/umod/uaddr if for different pids eugene.loh
2025-01-06 21:04 ` Kris Van Hees
2025-01-06 23:44   ` Kris Van Hees
2025-02-25 21:09     ` Kris Van Hees
2025-02-27 21:32       ` Eugene Loh

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.