Skip to contentSkip to conversation

test: Fix post processing of return-action override-pid tests

PATCH In review [email protected] 2 participants 2 messages Aug 5, 2025 – Aug 6, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: Fix post processing of return-action override-pid tests

From: Eugene Loh <[email protected]>

In commit ee8c066e8 ("rawfbt: selectively allow return() in clauses"), tests were introduced to check that return values are overwritten. A pid check value is output and used to facilitate comparisons to a .r results file.

The post processing logic was flawed in two respects:

1 The check value was being pulled from the "01" entry. Therefore,
the "00" entry, typically appearing first, would not be converted.

2 Values were not sorted. Sometimes this means the disorder just
described would be avoided and the test would pass. Mostly, it means that behavior can be erratic.

Sort results and use the "00" pid value for converting test results. Add $dt_flags to the $dtrace line while we're at it.

---
 test/unittest/actions/return/tst.override-getpid-entry.r.p  | 2 +-
 test/unittest/actions/return/tst.override-getpid-entry.sh   | 4 ++--
 test/unittest/actions/return/tst.override-getpid-return.r.p | 2 +-
 test/unittest/actions/return/tst.override-getpid-return.sh  | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)
test/unittest/actions/return/tst.override-getpid-entry.r.p +1 -1
index c838391a4..1a9b7b1bf 100755
@@ -4,7 +4,7 @@ BEGIN {
         mypid = -1
 }
 
-/^01 [1-9][0-9]*$/ {
+/^00 pid is [1-9][0-9]*$/ {
         mypid = $NF;
 }
 
test/unittest/actions/return/tst.override-getpid-entry.sh +2 -2
index 2282305e7..d9436a532 100755
@@ -38,7 +38,7 @@ fi
 
 # Trace the trigger.  On the 2nd and 5th getpid() calls, modify the result.
 
-$dtrace -c ./a.out -w -q -n '
+$dtrace $dt_flags -c ./a.out -w -q -n '
 BEGIN {
 	printf("00 pid is %d\n", $target);
 	n = 0;
@@ -58,6 +58,6 @@ rawfbt:vmlinux:__*_sys_getpid:entry
 {
 	return(55555);
 }
-'
+' | sort
 
 exit $?
test/unittest/actions/return/tst.override-getpid-return.r.p +1 -1
index c838391a4..1a9b7b1bf 100755
@@ -4,7 +4,7 @@ BEGIN {
         mypid = -1
 }
 
-/^01 [1-9][0-9]*$/ {
+/^00 pid is [1-9][0-9]*$/ {
         mypid = $NF;
 }
 
test/unittest/actions/return/tst.override-getpid-return.sh +2 -2
index 078d68a4a..835e443dd 100755
@@ -38,7 +38,7 @@ fi
 
 # Trace the trigger.  On the 2nd and 5th getpid() calls, modify the result.
 
-$dtrace -c ./a.out -w -q -n '
+$dtrace $dt_flags -c ./a.out -w -q -n '
 BEGIN {
 	printf("00 pid is %d\n", $target);
 	n = 0;
@@ -58,6 +58,6 @@ rawfbt:vmlinux:__*_sys_getpid:return
 {
 	return(55555);
 }
-'
+' | sort
 
 exit $?
Signature · 1 line
2.43.5
Reviewed-by on v1 1/1
#1 lore raw
Quoted 12 lines · On Tue, Aug 05, 2025 at 02:12:21PM -0400, [email protected] wrote:

From: Eugene Loh <[email protected]>

In commit ee8c066e8 ("rawfbt: selectively allow return() in clauses"), tests were introduced to check that return values are overwritten. A pid check value is output and used to facilitate comparisons to a .r results file.

The post processing logic was flawed in two respects:

1 The check value was being pulled from the "01" entry. Therefore,
the "00" entry, typically appearing first, would not be converted.

Quoted 8 lines

2 Values were not sorted. Sometimes this means the disorder just
described would be avoided and the test would pass. Mostly, it means that behavior can be erratic.

Sort results and use the "00" pid value for converting test results. Add $dt_flags to the $dtrace line while we're at it.

Not sure what happened - other than that I must have forgotten to add the corrected .r.p files because I did notice this issue and thought I had committed the fix for it. Oh well...

Quoted 78 lines
---
 test/unittest/actions/return/tst.override-getpid-entry.r.p  | 2 +-
 test/unittest/actions/return/tst.override-getpid-entry.sh   | 4 ++--
 test/unittest/actions/return/tst.override-getpid-return.r.p | 2 +-
 test/unittest/actions/return/tst.override-getpid-return.sh  | 4 ++--
 4 files changed, 6 insertions(+), 6 deletions(-)
test/unittest/actions/return/tst.override-getpid-entry.r.p +1 -1
index c838391a4..1a9b7b1bf 100755
@@ -4,7 +4,7 @@ BEGIN {
         mypid = -1
 }
 
-/^01 [1-9][0-9]*$/ {
+/^00 pid is [1-9][0-9]*$/ {
         mypid = $NF;
 }
 
test/unittest/actions/return/tst.override-getpid-entry.sh +2 -2
index 2282305e7..d9436a532 100755
@@ -38,7 +38,7 @@ fi
 
 # Trace the trigger.  On the 2nd and 5th getpid() calls, modify the result.
 
-$dtrace -c ./a.out -w -q -n '
+$dtrace $dt_flags -c ./a.out -w -q -n '
 BEGIN {
 	printf("00 pid is %d\n", $target);
 	n = 0;
@@ -58,6 +58,6 @@ rawfbt:vmlinux:__*_sys_getpid:entry
 {
 	return(55555);
 }
-'
+' | sort
 
 exit $?
test/unittest/actions/return/tst.override-getpid-return.r.p +1 -1
index c838391a4..1a9b7b1bf 100755
@@ -4,7 +4,7 @@ BEGIN {
         mypid = -1
 }
 
-/^01 [1-9][0-9]*$/ {
+/^00 pid is [1-9][0-9]*$/ {
         mypid = $NF;
 }
 
test/unittest/actions/return/tst.override-getpid-return.sh +2 -2
index 078d68a4a..835e443dd 100755
@@ -38,7 +38,7 @@ fi
 
 # Trace the trigger.  On the 2nd and 5th getpid() calls, modify the result.
 
-$dtrace -c ./a.out -w -q -n '
+$dtrace $dt_flags -c ./a.out -w -q -n '
 BEGIN {
 	printf("00 pid is %d\n", $target);
 	n = 0;
@@ -58,6 +58,6 @@ rawfbt:vmlinux:__*_sys_getpid:return
 {
 	return(55555);
 }
-'
+' | sort
 
 exit $?
Signature · 1 line
2.43.5