gawk: improve randtest stability
PATCH 1/1 gawk: improve randtest stability
Backport upstream fix to improve stability of randtest.sh by retrying when sigma is too small, avoiding intermittent failures.
[YOCTO #16254]
--- .../gawk/files/randtest-fix.patch | 138 ++++++++++++++++++ meta/recipes-extended/gawk/gawk_5.4.0.bb | 1 + 2 files changed, 139 insertions(+) create mode 100644 meta/recipes-extended/gawk/files/randtest-fix.patch
meta/recipes-extended/gawk/files/randtest-fix.patch new file +138 -0
@@ -0,0 +1,138 @@ +From f2250f4bc864913437619af7a9834a1c24915acd Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" <[email protected]> +Date: Thu, 28 May 2026 09:52:41 -0400 +Subject: Improve test/randtest.sh. + +Upstream-Status: Backport +https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=f2250f4bc864913437619af7a9834a1c24915acd + +Signed-off-by: Aditya GS <[email protected]> + +--- + +diff --git a/test/randtest.sh b/test/randtest.sh +index 597376a8..6ae6f830 100755 +--- a/test/randtest.sh ++++ b/test/randtest.sh +@@ -45,68 +45,77 @@ $AWK 'BEGIN{ + nsamples=('$NSAMPLES'); + max_allowed_sigma=('$MAX_ALLOWED_SIGMA'); + nruns=('$NRUNS'); +- for(tau=0;tau<nsamples/2;tau++) corr[tau]=0; ++ max_retries=5 + +- for(run=0;run<nruns;run++) { +- sum=0; ++ for (retry=0; retry<max_retries; retry++) { ++ for(tau=0; tau<nsamples/2; tau++) corr[tau]=0; + +- # Fill an array with a sequence of samples that are a +- # function of pairs of rand() values. ++ for(run=0; run<nruns; run++) { ++ sum=0; + +- for(i=0;i<nsamples;i++) { +- samp[i]=((rand()-0.5)*(rand()-0.5))^2; +- sum=sum+samp[i]; +- } ++ # Fill an array with a sequence of samples that are a ++ # function of pairs of rand() values. + +- # Subtract off the mean of the sequence: ++ for(i=0; i<nsamples; i++) { ++ samp[i]=((rand()-0.5)*(rand()-0.5))^2; ++ sum=sum+samp[i]; ++ } + +- mean=sum/nsamples; +- for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; ++ # Subtract off the mean of the sequence: + +- # Calculate an autocorrelation function on the sequence. +- # Because the values of rand() should be independent, there +- # should be no peaks in the autocorrelation. ++ mean=sum/nsamples; ++ for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; + +- for(tau=0;tau<nsamples/2;tau++) { +- sum=0; +- for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; +- corr[tau]=corr[tau]+sum; +- } ++ # Calculate an autocorrelation function on the sequence. ++ # Because the values of rand() should be independent, there ++ # should be no peaks in the autocorrelation. + +- } +- # Normalize the autocorrelation to the tau=0 value. ++ for(tau=0; tau<nsamples/2; tau++) { ++ sum=0; ++ for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; ++ corr[tau]=corr[tau]+sum; ++ } + +- max_corr=corr[0]; +- for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; ++ } ++ # Normalize the autocorrelation to the tau=0 value. + +- # OPTIONALLY Print out the autocorrelation values: ++ max_corr=corr[0]; ++ for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; + +- # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] > "pairpower_corr.data"; ++ # OPTIONALLY Print out the autocorrelation values: + +- # Calculate the sigma for the non-zero tau values: ++ # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] > "pairpower_corr.data"; + +- power_sum=0; ++ # Calculate the sigma for the non-zero tau values: + +- for(tau=1;tau<nsamples/2;tau++) power_sum=power_sum+(corr[tau])^2; ++ power_sum=0; + +- sigma=sqrt(power_sum/(nsamples/2-1)); ++ for(tau=1;tau<nsamples/2;tau++) power_sum=power_sum+(corr[tau])^2; + +- # See if any of the correlations exceed a reasonable number of sigma: ++ sigma=sqrt(power_sum/(nsamples/2-1)); + +- passed=1; +- for(tau=1;tau<nsamples/2;tau++) { +- if ( abs(corr[tau])/sigma > max_allowed_sigma ) { +- print "Tau=", tau ", Autocorr=", corr[tau]/sigma, "sigma"; +- passed=0; +- } ++ if (sigma < 1e-6) { ++ print "Sigma too small, retrying run", retry ++ continue + } +- if(!passed) { +- print "Test failed." +- exit(1); ++ ++ # See if any of the correlations exceed a reasonable number of sigma: ++ ++ for(tau=1;tau<nsamples/2;tau++) { ++ if (abs(corr[tau])/sigma > max_allowed_sigma) { ++ print "Tau=", tau ", Autocorr=", corr[tau]/sigma, "sigma"; ++ print "Test failed." ++ exit 1 ++ } + } +- else exit (0); ++ ++ exit 0 + } + ++ print "Test failed after retries due to unstable sigma" ++ exit 1 ++} ++ + function abs(abs_input) { return(sqrt(abs_input^2)) ; } + ' + +-- +2.34.1 +
meta/recipes-extended/gawk/gawk_5.4.0.bb +1 -0
@@ -28,6 +28,7 @@ PACKAGECONFIG[pma-if-64bit] = "--enable-pma,--disable-pma, " SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.xz \ file://run-ptest \ file://0001-configure.ac-re-enable-disabled-printf-features.patch \ + file://randtest-fix.patch \ " SRC_URI[sha256sum] = "3dd430f0cd3b4428c6c3f6afc021b9cd3c1f8c93f7a688dc268ca428a90b4ac1"
Signature · 1 line
2.34.1
Hello Aditya,
an earlier version of the patch was already fixed up and merged; the patch review participants decided that it's better to fix the frustrating CI failures quicker than do more review-fix-resend cycles:
https://git.openembedded.org/openembedded-core/commit/?id=ccabae3036a713cac8b08731b765ff1dc3ed93eb
I'd suggest you rebase the latest commit on top of current oe-core master with 'git rebase', and send any remaining differences (e.g. the missing signed-off-by) as a separate patch (remember to also edit the commit message so it matches the patch content).
Alex
Quoted 172 lines · Aditya GS
Backport upstream fix to improve stability of
randtest.shby retrying when sigma is too small, avoiding intermittent failures.[YOCTO #16254]
Signed-off-by Aditya GS <[email protected]>--- .../gawk/files/randtest-fix.patch | 138 ++++++++++++++++++ meta/recipes-extended/gawk/gawk_5.4.0.bb | 1 + 2 files changed, 139 insertions(+) create mode 100644 meta/recipes-extended/gawk/files/randtest-fix.patchmeta/recipes-extended/gawk/files/randtest-fix.patch new file +138
-0@@ -0,0 +1,138 @@ +From f2250f4bc864913437619af7a9834a1c24915acd Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" <[email protected]> +Date: Thu, 28 May 2026 09:52:41 -0400 +Subject: Improve test/randtest.sh. + +Upstream-Status: Backport +https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=f2250f4bc864913437619af7a9834a1c24915acd + +Signed-off-by: Aditya GS <[email protected]> + +--- + +diff --git a/test/randtest.sh b/test/randtest.sh +index 597376a8..6ae6f830 100755 +--- a/test/randtest.sh ++++ b/test/randtest.sh +@@ -45,68 +45,77 @@ $AWK 'BEGIN{ + nsamples=('$NSAMPLES'); + max_allowed_sigma=('$MAX_ALLOWED_SIGMA'); + nruns=('$NRUNS'); +- for(tau=0;tau<nsamples/2;tau++) corr[tau]=0; ++ max_retries=5 + +- for(run=0;run<nruns;run++) { +- sum=0; ++ for (retry=0; retry<max_retries; retry++) { ++ for(tau=0; tau<nsamples/2; tau++) corr[tau]=0; + +- # Fill an array with a sequence of samples that are a +- # function of pairs of rand() values. ++ for(run=0; run<nruns; run++) { ++ sum=0; + +- for(i=0;i<nsamples;i++) { +- samp[i]=((rand()-0.5)*(rand()-0.5))^2; +- sum=sum+samp[i]; +- } ++ # Fill an array with a sequence of samples that are a ++ # function of pairs of rand() values. + +- # Subtract off the mean of the sequence: ++ for(i=0; i<nsamples; i++) { ++ samp[i]=((rand()-0.5)*(rand()-0.5))^2; ++ sum=sum+samp[i]; ++ } + +- mean=sum/nsamples; +- for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; ++ # Subtract off the mean of the sequence: + +- # Calculate an autocorrelation function on the sequence. +- # Because the values of rand() should be independent, there +- # should be no peaks in the autocorrelation. ++ mean=sum/nsamples; ++ for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; + +- for(tau=0;tau<nsamples/2;tau++) { +- sum=0; +- for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; +- corr[tau]=corr[tau]+sum; +- } ++ # Calculate an autocorrelation function on the sequence. ++ # Because the values of rand() should be independent, there ++ # should be no peaks in the autocorrelation. + +- } +- # Normalize the autocorrelation to the tau=0 value. ++ for(tau=0; tau<nsamples/2; tau++) { ++ sum=0; ++ for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; ++ corr[tau]=corr[tau]+sum; ++ } + +- max_corr=corr[0]; +- for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; ++ } ++ # Normalize the autocorrelation to the tau=0 value. + +- # OPTIONALLY Print out the autocorrelation values: ++ max_corr=corr[0]; ++ for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; + +- # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] > "pairpower_corr.data"; ++ # OPTIONALLY Print out the autocorrelation values: + +- # Calculate the sigma for the non-zero tau values: ++ # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] > "pairpower_corr.data"; + +- power_sum=0; ++ # Calculate the sigma for the non-zero tau values: + +- for(tau=1;tau<nsamples/2;tau++) power_sum=power_sum+(corr[tau])^2; ++ power_sum=0; + +- sigma=sqrt(power_sum/(nsamples/2-1)); ++ for(tau=1;tau<nsamples/2;tau++) power_sum=power_sum+(corr[tau])^2; + +- # See if any of the correlations exceed a reasonable number of sigma: ++ sigma=sqrt(power_sum/(nsamples/2-1)); + +- passed=1; +- for(tau=1;tau<nsamples/2;tau++) { +- if ( abs(corr[tau])/sigma > max_allowed_sigma ) { +- print "Tau=", tau ", Autocorr=", corr[tau]/sigma, "sigma"; +- passed=0; +- } ++ if (sigma < 1e-6) { ++ print "Sigma too small, retrying run", retry ++ continue + } +- if(!passed) { +- print "Test failed." +- exit(1); ++ ++ # See if any of the correlations exceed a reasonable number of sigma: ++ ++ for(tau=1;tau<nsamples/2;tau++) { ++ if (abs(corr[tau])/sigma > max_allowed_sigma) { ++ print "Tau=", tau ", Autocorr=", corr[tau]/sigma, "sigma"; ++ print "Test failed." ++ exit 1 ++ } + } +- else exit (0); ++ ++ exit 0 + } + ++ print "Test failed after retries due to unstable sigma" ++ exit 1 ++} ++ + function abs(abs_input) { return(sqrt(abs_input^2)) ; } + ' + +-- +2.34.1 +meta/recipes-extended/gawk/gawk_5.4.0.bb +1
-1@@ -28,6 +28,7 @@ PACKAGECONFIG[pma-if-64bit] = "--enable-pma,--disable-pma, " SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.xz \ file://run-ptest \ file://0001-configure.ac-re-enable-disabled-printf-features.patch \ + file://randtest-fix.patch \ " SRC_URI[sha256sum] = "3dd430f0cd3b4428c6c3f6afc021b9cd3c1f8c93f7a688dc268ca428a90b4ac1" --2.34.1
Hi Alex,
Thanks for the update.
I've reviewed the merged commit and verified that the fix is already present and complete, including the required metadata.
My latest submission (v11) also included the missing Signed-off-by, so I believe there are no remaining differences to address.
Thanks again for reviewing and integrating the fix.
Regards,
Aditya
Quoted 201 lines · Alexander Kanavin
Hello Aditya,
an earlier version of the patch was already fixed up and merged; the patch review participants decided that it's better to fix the frustrating CI failures quicker than do more review-fix-resend cycles:
https://git.openembedded.org/openembedded-core/commit/?id=ccabae3036a713cac8b08731b765ff1dc3ed93eb
I'd suggest you rebase the latest commit on top of current oe-core master with 'git rebase', and send any remaining differences (e.g. the missing signed-off-by) as a separate patch (remember to also edit the commit message so it matches the patch content).
Alex
Quoted 6 lines · Aditya GS
Backport upstream fix to improve stability of
randtest.shby retrying when sigma is too small, avoiding intermittent failures.[YOCTO #16254]
Review
Quoted 8 lines
Signed-off-by Aditya GS <[email protected]>--- .../gawk/files/randtest-fix.patch | 138 ++++++++++++++++++ meta/recipes-extended/gawk/gawk_5.4.0.bb | 1 + 2 files changed, 139 insertions(+) create mode 100644 meta/recipes-extended/gawk/files/randtest-fix.patch(quoted diff) +0
-0
b/meta/recipes-extended/gawk/files/randtest-fix.patchmeta/recipes-extended/gawk/files/randtest-fix.patch line 7
Quoted 12 lines
new file mode 100644
index 0000000000..0aafa0f282meta/recipes-extended/gawk/files/randtest-fix.patch new file +7
-0@@ -0,0 +1,138 @@ +From f2250f4bc864913437619af7a9834a1c24915acd Mon Sep 17 00:00:00 2001 +From: "Arnold D. Robbins" <[email protected]> +Date: Thu, 28 May 2026 09:52:41 -0400 +Subject: Improve test/randtest.sh. + +Upstream-Status: Backport +https://cgit.git.savannah.gnu.org/cgit/gawk.git/commit/?id=f2250f4bc864913437619af7a9834a1c24915acd
Quoted 66 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +66
-0+ +Signed-off-by: Aditya GS <[email protected]> + +--- + +diff --git a/test/randtest.sh b/test/randtest.sh +index 597376a8..6ae6f830 100755 +--- a/test/randtest.sh ++++ b/test/randtest.sh +@@ -45,68 +45,77 @@ $AWK 'BEGIN{ + nsamples=('$NSAMPLES'); + max_allowed_sigma=('$MAX_ALLOWED_SIGMA'); + nruns=('$NRUNS'); +- for(tau=0;tau<nsamples/2;tau++) corr[tau]=0; ++ max_retries=5 + +- for(run=0;run<nruns;run++) { +- sum=0; ++ for (retry=0; retry<max_retries; retry++) { ++ for(tau=0; tau<nsamples/2; tau++) corr[tau]=0; + +- # Fill an array with a sequence of samples that are a +- # function of pairs of rand() values. ++ for(run=0; run<nruns; run++) { ++ sum=0; + +- for(i=0;i<nsamples;i++) { +- samp[i]=((rand()-0.5)*(rand()-0.5))^2; +- sum=sum+samp[i]; +- } ++ # Fill an array with a sequence of samples that are a ++ # function of pairs of rand() values. + +- # Subtract off the mean of the sequence: ++ for(i=0; i<nsamples; i++) { ++ samp[i]=((rand()-0.5)*(rand()-0.5))^2; ++ sum=sum+samp[i]; ++ } + +- mean=sum/nsamples; +- for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; ++ # Subtract off the mean of the sequence: + +- # Calculate an autocorrelation function on the sequence. +- # Because the values of rand() should be independent, there +- # should be no peaks in the autocorrelation. ++ mean=sum/nsamples; ++ for(i=0;i<nsamples;i++) samp[i]=samp[i]-mean; + +- for(tau=0;tau<nsamples/2;tau++) { +- sum=0; +- for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; +- corr[tau]=corr[tau]+sum; +- } ++ # Calculate an autocorrelation function on the sequence. ++ # Because the values of rand() should be independent, there ++ # should be no peaks in the autocorrelation. + +- } +- # Normalize the autocorrelation to the tau=0 value. ++ for(tau=0; tau<nsamples/2; tau++) { ++ sum=0; ++ for(i=0;i<nsamples/2;i++) sum=sum+samp[i]*samp[i+tau]; ++ corr[tau]=corr[tau]+sum; ++ } +meta/recipes-extended/gawk/files/randtest-fix.patch
Quoted 10 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +10
-0+- max_corr=corr[0]; +- for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; ++ } ++ # Normalize the autocorrelation to the tau=0 value. + +- # OPTIONALLY Print out the autocorrelation values: ++ max_corr=corr[0]; ++ for(tau=0;tau<nsamples/2;tau++) corr[tau]=corr[tau]/max_corr; + +- # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] >"pairpower_corr.data";
meta/recipes-extended/gawk/files/randtest-fix.patch
Quoted 4 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +4
-0++ # OPTIONALLY Print out the autocorrelation values: + +- # Calculate the sigma for the non-zero tau values: ++ # for(tau=0;tau<nsamples/2;tau++) print tau, corr[tau] >"pairpower_corr.data";
meta/recipes-extended/gawk/files/randtest-fix.patch
Quoted 9 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +9
-0+ +- power_sum=0; ++ # Calculate the sigma for the non-zero tau values: + +- for(tau=1;tau<nsamples/2;tau++) power_sum=power_sum+(corr[tau])^2; ++ power_sum=0; + +- sigma=sqrt(power_sum/(nsamples/2-1)); ++ for(tau=1;tau<nsamples/2;tau++)power_sum=power_sum+(corr[tau])^2;
meta/recipes-extended/gawk/files/randtest-fix.patch line 98
Quoted 2 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +2
-0+ +- # See if any of the correlations exceed a reasonable number ofsigma:
Quoted 7 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +7
-0++ sigma=sqrt(power_sum/(nsamples/2-1)); + +- passed=1; +- for(tau=1;tau<nsamples/2;tau++) { +- if ( abs(corr[tau])/sigma > max_allowed_sigma ) { +- print "Tau=", tau ", Autocorr=", corr[tau]/sigma, "sigma"; +- passed=0;meta/recipes-extended/gawk/files/randtest-fix.patch
Quoted 10 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +10
-0+- } ++ if (sigma < 1e-6) { ++ print "Sigma too small, retrying run", retry ++ continue + } +- if(!passed) { +- print "Test failed." +- exit(1); ++ ++ # See if any of the correlations exceed a reasonable number ofsigma:
meta/recipes-extended/gawk/files/randtest-fix.patch
Quoted 4 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +4
-0++ ++ for(tau=1;tau<nsamples/2;tau++) { ++ if (abs(corr[tau])/sigma > max_allowed_sigma) { ++ print "Tau=", tau ", Autocorr=", corr[tau]/sigma,"sigma";
Review
Quoted 20 lines
meta/recipes-extended/gawk/files/randtest-fix.patch new file +19
-0++ print "Test failed." ++ exit 1 ++ } + } +- else exit (0); ++ ++ exit 0 + } + ++ print "Test failed after retries due to unstable sigma" ++ exit 1 ++} ++ + function abs(abs_input) { return(sqrt(abs_input^2)) ; } + ' + +-- +2.34.1 +(quoted diff) +0
-0b/meta/recipes-extended/gawk/gawk_5.4.0.bb
meta/recipes-extended/gawk/gawk_5.4.0.bb PACKAGECONFIG[pma-if-64bit] =
Quoted 4 lines
index
d7211f28f3..71e7ddb31f100644meta/recipes-extended/gawk/gawk_5.4.0.bb +0
-0@@ -28,6 +28,7 @@ PACKAGECONFIG[pma-if-64bit] ="--enable-pma,--disable-pma, "
meta/recipes-extended/gawk/gawk_5.4.0.bb PACKAGECONFIG[pma-if-64bit] = "--enable-pma,--disable-pma, " · line 33
Quoted 3 lines
meta/recipes-extended/gawk/gawk_5.4.0.bb +0
-0SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.xz \ file://run-ptest \file://0001-configure.ac-re-enable-disabled-printf-features.patch \
meta/recipes-extended/gawk/gawk_5.4.0.bb PACKAGECONFIG[pma-if-64bit] = "--enable-pma,--disable-pma, "
Quoted 4 lines
meta/recipes-extended/gawk/gawk_5.4.0.bb +1
-0+ file://randtest-fix.patch \ " SRC_URI[sha256sum] ="
3dd430f0cd3b4428c6c3f6afc021b9cd3c1f8c93f7a688dc268ca428a90b4ac1"Quoted 3 lines
--
2.34.1
Quoted 3 lines · Aditya G.S
I've reviewed the merged commit and verified that the fix is already present and complete, including the required metadata.
My latest submission (v11) also included the missing Signed-off-by, so I believe there are no remaining differences to address.
Your latest submission has the signed-off-by, but the version that got merged in master does not. So you can rebase your latest submission on top of master branch (use 'git rebase'), and it would reduce it to just adding the signed-off-by, and then you can re-submit just that change.
Alex
Hi Alex,
Thanks for the clarification.
I've rebased on top of master and submitted a follow-up patch that adds the missing Signed-off-by to the previously merged change.
Thanks,
Aditya
Quoted 15 lines · Alexander Kanavin
Quoted 1 line · Aditya G.S
I've reviewed the merged commit and verified that the fix is already
present and complete, including the required metadata.
Quoted 2 lines
My latest submission (v11) also included the missing Signed-off-by, so I
believe there are no remaining differences to address.
Your latest submission has the signed-off-by, but the version that got merged in master does not. So you can rebase your latest submission on top of master branch (use 'git rebase'), and it would reduce it to just adding the signed-off-by, and then you can re-submit just that change.
Alex