Skip to contentSkip to conversation

test: Suppress some white space

PATCH In review [email protected] 2 participants 4 messages Jun 9, 2025 – Jul 22, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 test: Suppress some white space

From: Eugene Loh <[email protected]>

The test suite turns pointers into "{ptr}" so that results comparisons will not be sensitive to particular pointer offset values.

If these offsets change in width -- say, from 0xf0 to 0x100 -- the amount of white space in the postprocessed output can change.

Add additional postprocessing to a test that sometimes fails due to this problem.

---
 test/unittest/aggs/tst.ustack.r   | 32 +++++++++++++++----------------
 test/unittest/aggs/tst.ustack.r.p |  3 +++
 2 files changed, 19 insertions(+), 16 deletions(-)
 create mode 100755 test/unittest/aggs/tst.ustack.r.p
test/unittest/aggs/tst.ustack.r +16 -16
index ed26cc5f3..271a0b30c 100644
@@ -1,18 +1,18 @@
-  ustack-tst-basic`myfunc_y+{ptr}                     
-  ustack-tst-basic`myfunc_y                         
-  ustack-tst-basic                                  
-  ustack-tst-basic`myfunc_y                         
+ ustack-tst-basic`myfunc_y+{ptr} 
+ ustack-tst-basic`myfunc_y 
+ ustack-tst-basic 
+ ustack-tst-basic`myfunc_y 
 
-              ustack-tst-basic`myfunc_z+{ptr}
-              ustack-tst-basic`myfunc_y+{ptr}
-              ustack-tst-basic`myfunc_x+{ptr}
-              ustack-tst-basic`myfunc_w+{ptr}
-              ustack-tst-basic`myfunc_v+{ptr}
+ ustack-tst-basic`myfunc_z+{ptr}
+ ustack-tst-basic`myfunc_y+{ptr}
+ ustack-tst-basic`myfunc_x+{ptr}
+ ustack-tst-basic`myfunc_w+{ptr}
+ ustack-tst-basic`myfunc_v+{ptr}
 
-       97  ustack-tst-basic`myfunc_y+{ptr}                       ustack-tst-basic`myfunc_y                           ustack-tst-basic                                    ustack-tst-basic`myfunc_y                         
-              ustack-tst-basic`myfunc_z+{ptr}
-              ustack-tst-basic`myfunc_y+{ptr}
-              ustack-tst-basic`myfunc_x+{ptr}
-              ustack-tst-basic`myfunc_w+{ptr}
-              ustack-tst-basic`myfunc_v+{ptr}
-        4             1234
+ 97 ustack-tst-basic`myfunc_y+{ptr} ustack-tst-basic`myfunc_y ustack-tst-basic ustack-tst-basic`myfunc_y 
+ ustack-tst-basic`myfunc_z+{ptr}
+ ustack-tst-basic`myfunc_y+{ptr}
+ ustack-tst-basic`myfunc_x+{ptr}
+ ustack-tst-basic`myfunc_w+{ptr}
+ ustack-tst-basic`myfunc_v+{ptr}
+ 4 1234
test/unittest/aggs/tst.ustack.r.p new file +3 -0
new file mode 100755
index 000000000..16a0451c4
@@ -0,0 +1,3 @@
+#!/usr/bin/gawk -f
+
+{ gsub(/ +/, " "); print; }
Signature · 1 line
2.43.5
#1 lore raw

On 9 Jun 2025, eugene loh spake thusly:

Quoted 11 lines

From: Eugene Loh <[email protected]>

The test suite turns pointers into "{ptr}" so that results comparisons will not be sensitive to particular pointer offset values.

If these offsets change in width -- say, from 0xf0 to 0x100 -- the amount of white space in the postprocessed output can change.

Add additional postprocessing to a test that sometimes fails due to this problem.

Hmm... this would work for this test, but maybe we should change the {ptr} substitution in runtest.sh itself so that it gets this right in the general case?

Something like

runtest.sh +1 -1
index 156e7dec8a1c3..c5703a81bc6d4 100755
@@ -509,7 +509,7 @@ postprocess()
     # TODO: may need adjustment or making optional if scripts emit hex
     # values which are not continuously variable.
 
-    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*,{ptr},g' \
+    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*\([ \t]*\),{ptr}\1,g' \
 	-e 's,at BPF pc [1-9][0-9]*,at BPF pc NNN,' < $tmpdir/pp.out > $final
 
     return $retval

might work. (Obviously the lines would no longer line up, but the number of spaces would remain the same as they were before the substitution.)

Lots and lots of expected results would need regenerating after this, of course...

Signature · 1 line
NULL && (void)
author
#2 lore raw
Quoted 33 lines · Nick Alcock

On 9 Jun 2025, eugene loh spake thusly:

Quoted 11 lines

From: Eugene Loh <[email protected]>

The test suite turns pointers into "{ptr}" so that results comparisons will not be sensitive to particular pointer offset values.

If these offsets change in width -- say, from 0xf0 to 0x100 -- the amount of white space in the postprocessed output can change.

Add additional postprocessing to a test that sometimes fails due to this problem.

Hmm... this would work for this test, but maybe we should change the {ptr} substitution in runtest.sh itself so that it gets this right in the general case?

Something like

runtest.sh +1 -1
index 156e7dec8a1c3..c5703a81bc6d4 100755
@@ -509,7 +509,7 @@ postprocess()
      # TODO: may need adjustment or making optional if scripts emit hex
      # values which are not continuously variable.
 
-    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*,{ptr},g' \
+    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*\([ \t]*\),{ptr}\1,g' \
  	-e 's,at BPF pc [1-9][0-9]*,at BPF pc NNN,' < $tmpdir/pp.out > $final
 
      return $retval
Quoted 5 lines

might work. (Obviously the lines would no longer line up, but the number of spaces would remain the same as they were before the substitution.)

Lots and lots of expected results would need regenerating after this, of course...

I agree that one can make a case for a broader change, but I'm not convinced that that would be the better way.  FWIW, there were these two commits 6f398f229 test: Make tests more resilient to different prid widths
        72a79b784 test: Improve resilience of tests to ptr widths
that took the narrower, more tactical approach to such a problem.

I vote for the expedient route:  a "Reviewed-by" and we move on. But then, in this case, my vote doesn't count!

Reviewed-by
#3 lore raw

On 23 Jun 2025, Eugene Loh outgrape:

Quoted 45 lines · Nick Alcock
Quoted 35 lines

On 9 Jun 2025, eugene loh spake thusly:

Quoted 11 lines

From: Eugene Loh <[email protected]>

The test suite turns pointers into "{ptr}" so that results comparisons will not be sensitive to particular pointer offset values.

If these offsets change in width -- say, from 0xf0 to 0x100 -- the amount of white space in the postprocessed output can change.

Add additional postprocessing to a test that sometimes fails due to this problem.

Hmm... this would work for this test, but maybe we should change the {ptr} substitution in runtest.sh itself so that it gets this right in the general case?

Something like

runtest.sh +1 -0
index 156e7dec8a1c3..c5703a81bc6d4 100755
@@ -509,7 +509,7 @@ postprocess()
      # TODO: may need adjustment or making optional if scripts emit hex
      # values which are not continuously variable.
  -    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*,{ptr},g' \
+    sed -e '/^==[0-9][0-9]*== /!s,0x[0-9a-f][0-9a-f]*\([ \t]*\),{ptr}\1,g' \
  	-e 's,at BPF pc [1-9][0-9]*,at BPF pc NNN,' < $tmpdir/pp.out > $final
        return $retval
 

might work. (Obviously the lines would no longer line up, but the number of spaces would remain the same as they were before the substitution.)

Quoted 2 lines

Lots and lots of expected results would need regenerating after this, of course...

I agree that one can make a case for a broader change, but I'm not convinced that that would be the better way.  FWIW, there were these two commits
        6f398f229 test: Make tests more resilient to different prid widths
        72a79b784 test: Improve resilience of tests to ptr widths
that took the narrower, more tactical approach to such a problem.

Quoted 1 line

I vote for the expedient route:  a "Reviewed-by" and we move on. But then, in this case, my vote doesn't count!

I think doing the narrow approach for now makes sense, but doing the wider one makes more sense in future :) I tried and it's a nest of thorns, though, unlike hex number replacement there are many places where we don't want to totally ignore the amount of whitespace in use. So...

Signature · 1 line
NULL && (void)