Skip to contentSkip to conversation

gawk: backport randtest stability fix

PATCH In review Aditya GS 3 participants 6 messages May 28 – Jun 1

lore
Share & tools
lore

Aditya GS

author
#0 lore raw

PATCH 1/1 gawk: backport randtest stability fix

Backport upstream fix to improve stability of randtest.sh by retrying when sigma is too small, avoiding intermittent failures.

https://bugzilla.yoctoproject.org/show_bug.cgi?id=16254

---
 .../gawk/files/randtest-fix.patch             | 138 ++++++++++++++++++
 meta/recipes-extended/gawk/gawk_5.3.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
new file mode 100644
index 0000000000..b909d52263
@@ -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: [PATCH] Improve test/randtest.sh.
+
+Backport upstream fix to improve stability of randtest.sh by retrying
+when sigma is too small, avoiding intermittent failures.
+
+Upstream-Status: Backport [f2250f4bc864913437619af7a9834a1c24915acd]
+
+---
+
+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.3.0.bb +1 -0
index ac9d8500d6..a6bf793e65 100644
@@ -19,6 +19,7 @@ SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \
            file://0001-m4-readline-add-missing-includes.patch \
            file://run-ptest \
            "
+SRC_URI += "file://randtest-fix.patch"
 
 SRC_URI[sha256sum] = "378f8864ec21cfceaa048f7e1869ac9b4597b449087caf1eb55e440d30273336"
 
Signature · 1 line
2.34.1
#1 lore raw
Quoted 1 line · Aditya GS

+Upstream-Status: Backport [f2250f4bc864913437619af7a9834a1c24915acd]

This still has the commit id instead of the link.

meta/recipes-extended/gawk/gawk_5.3.0.bb SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \ · line 22

Quoted 5 lines
meta/recipes-extended/gawk/gawk_5.3.0.bb +1 -0
@@ -19,6 +19,7 @@ SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \
            file://0001-m4-readline-add-missing-includes.patch \
            file://run-ptest \
            "
+SRC_URI += "file://randtest-fix.patch"

This also hasn't changed since the first version of the patch.

Did you forget to run 'git add' before 'git commit --amend' ? (another option is to use 'git commit -a --amend' which auto-adds everything that's already known by git)

Alex

author
#2 lore raw

Hi Alex,

Thanks for catching that.

You're right I had updated the files but missed staging them before amending the commit. I've now corrected that and included all the requested changes.

I'll resend the updated patch shortly.

Thanks,
Aditya

Quoted 19 lines · Alexander Kanavin
Quoted 1 line · Aditya GS

+Upstream-Status: Backport [f2250f4bc864913437619af7a9834a1c24915acd]

This still has the commit id instead of the link.

meta/recipes-extended/gawk/gawk_5.3.0.bb SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \ · line 22

Quoted 5 lines
meta/recipes-extended/gawk/gawk_5.3.0.bb +1 -0
@@ -19,6 +19,7 @@ SRC_URI = "${GNU_MIRROR}/gawk/gawk-${PV}.tar.gz \
            file://0001-m4-readline-add-missing-includes.patch \
            file://run-ptest \
            "
+SRC_URI += "file://randtest-fix.patch"

This also hasn't changed since the first version of the patch.

Did you forget to run 'git add' before 'git commit --amend' ? (another option is to use 'git commit -a --amend' which auto-adds everything that's already known by git)

Alex

#3 lore raw

Patchtest results for [PATCH] gawk: backport randtest stability fix

In reply to Aditya GS

Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:

---
Testing patch /home/patchtest/share/mboxes/gawk-backport-randtest-stability-fix.patch

FAIL: test Signed-off-by presence: A patch file has been added without a Signed-off-by tag: 'randtest-fix.patch' (test_patch.TestPatch.test_signed_off_by_presence)

PASS: test CVE tag format (test_patch.TestPatch.test_cve_tag_format)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test Upstream-Status presence (test_patch.TestPatch.test_upstream_status_presence_format)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!

#4 lore raw

Re: [OE-core] Patchtest results for [PATCH] gawk: backport randtest stability fix

Quoted 1 line · Patchtest via lists.openembedded.org

FAIL: test Signed-off-by presence: A patch file has been added without a Signed-off-by tag: 'randtest-fix.patch' (test_patch.TestPatch.test_signed_off_by_presence)

Right, this needs to be addressed too. Now you can use a -vN when re-sending :)

Added Signed-off-by must always contain your identity, and not anyone else.

Alex

author
#5 lore raw

Re: [OE-core] Patchtest results for [PATCH] gawk: backport randtest stability fix

Hi Alex,

Thanks for the feedback and suggestions.

I've now addressed the patchtest issue by adding the missing Signed-off-by to the backported patch file, and updated the patch accordingly.

Resending as v3.

Thanks,
Aditya

Quoted 13 lines · Alexander Kanavin
Quoted 1 line · Patchtest via lists.openembedded.org

FAIL: test Signed-off-by presence: A patch file has been added without a

Signed-off-by tag: 'randtest-fix.patch' (test_patch.TestPatch.test_signed_off_by_presence)

Right, this needs to be addressed too. Now you can use a -vN when re-sending :)

Added Signed-off-by must always contain your identity, and not anyone else.

Alex