test: Fix post processing of return-action override-pid tests
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
@@ -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
@@ -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
@@ -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
@@ -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
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 allowreturn()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.
Signed-off-by Eugene Loh <[email protected]>
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@@ -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@@ -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@@ -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@@ -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