From: William Lyu <[email protected]>

Fixes [YOCTO #15136]

This fix addresses the intermittent failure of the Perl ptest
t/op/sigsystem.t.

Signed-off-by: William Lyu <[email protected]>
Signed-off-by: Randy MacLeod <[email protected]>
Reported-by: Alexandre Belloni <[email protected]>
---
 ...ent-failure-of-test-t-op-sigsystem.t.patch | 77 +++++++++++++++++++
 meta/recipes-devtools/perl/perl_5.38.0.bb     |  1 +
 2 files changed, 78 insertions(+)
 create mode 100644 
meta/recipes-devtools/perl/files/0001-Fix-intermittent-failure-of-test-t-op-sigsystem.t.patch

diff --git 
a/meta/recipes-devtools/perl/files/0001-Fix-intermittent-failure-of-test-t-op-sigsystem.t.patch
 
b/meta/recipes-devtools/perl/files/0001-Fix-intermittent-failure-of-test-t-op-sigsystem.t.patch
new file mode 100644
index 0000000000..86fd42cd3d
--- /dev/null
+++ 
b/meta/recipes-devtools/perl/files/0001-Fix-intermittent-failure-of-test-t-op-sigsystem.t.patch
@@ -0,0 +1,77 @@
+From 75d974a58c461b3b5d35280e497810e46abae4ca Mon Sep 17 00:00:00 2001
+From: William Lyu <[email protected]>
+Date: Wed, 4 Oct 2023 08:58:41 -0400
+Subject: [PATCH] Fix intermittent failure of test t/op/sigsystem.t
+
+[Perl issue #21546] -- https://github.com/Perl/perl5/issues/21546
+
+This fix addresses the intermittent failure of the test
+t/op/sigsystem.t by improving its robustness. Before the fix, this
+test waits a hard-coded amount of time in the parent process for the
+child process to exit, and the child process may not be able to exit
+soon enough. With this fix, the parent process in this test polls for
+whether the SIGCHLD handler reaped the child process for at most 25
+seconds.
+
+Upstream-Status: Backport [commit ID: 75d974a]
+
+Signed-off-by: William Lyu <[email protected]>
+Signed-off-by: Randy MacLeod <[email protected]>
+Reported-by: Alexandre Belloni <[email protected]>
+
+Committer: William Lyu is now a Perl author.
+---
+ AUTHORS          |  1 +
+ t/op/sigsystem.t | 17 ++++++++++++++---
+ 2 files changed, 15 insertions(+), 3 deletions(-)
+
+diff --git a/AUTHORS b/AUTHORS
+index 21948bfdc7..527dd992fd 100644
+--- a/AUTHORS
++++ b/AUTHORS
+@@ -1443,6 +1443,7 @@ Wayne Scott                    <[email protected]>
+ Wayne Thompson                 <[email protected]>
+ Wilfredo Sánchez               <[email protected]>
+ William J. Middleton           <[email protected]>
++William Lyu                    <[email protected]>
+ William Mann                   <[email protected]>
+ William Middleton              <[email protected]>
+ William R Ward                 <[email protected]>
+diff --git a/t/op/sigsystem.t b/t/op/sigsystem.t
+index 25da854902..831feefb0f 100644
+--- a/t/op/sigsystem.t
++++ b/t/op/sigsystem.t
+@@ -37,7 +37,15 @@ SKIP: {
+     test_system('with reaper');
+ 
+     note("Waiting briefly for SIGCHLD...");
+-    Time::HiRes::sleep(0.500);
++
++    # Wait at most 50 * 0.500 = 25.0 seconds for the child process to be 
++    # reaped. If the child process exits and gets reaped early, this polling
++    # loop will exit early. 
++
++    for (1..50) {
++      last if @pids;
++      Time::HiRes::sleep(0.500);
++    }
+ 
+     ok(@pids == 1, 'Reaped only one process');
+     ok($pids[0] == $pid, "Reaped the right process.") or diag(Dumper(\@pids));
+@@ -50,8 +58,11 @@ sub test_system {
+     my $got_zeroes      = 0;
+ 
+     # This test is looking for a race between system()'s waitpid() and a
+-    # signal handler.    Looping a few times increases the chances of
+-    # catching the error.
++    # signal handler. The system() call is expected to not interfere with the 
++    # SIGCHLD signal handler. In particular, the wait() called within 
system() 
++    # is expected to reap the child process forked by system() before the 
++    # SIGCHLD signal handler is called. 
++    # Looping a few times increases the chances of catching the error.
+ 
+     for (1..$expected_zeroes) {
+       $got_zeroes++ unless system(TRUE);
+-- 
+2.25.1
+
diff --git a/meta/recipes-devtools/perl/perl_5.38.0.bb 
b/meta/recipes-devtools/perl/perl_5.38.0.bb
index 956e4d64d7..639664e355 100644
--- a/meta/recipes-devtools/perl/perl_5.38.0.bb
+++ b/meta/recipes-devtools/perl/perl_5.38.0.bb
@@ -17,6 +17,7 @@ SRC_URI = 
"https://www.cpan.org/src/5.0/perl-${PV}.tar.gz;name=perl \
            file://0002-Constant-Fix-up-shebang.patch \
            file://determinism.patch \
            
file://0001-cpan-Sys-Syslog-Makefile.PL-Fix-_PATH_LOG-for-determ.patch \
+           file://0001-Fix-intermittent-failure-of-test-t-op-sigsystem.t.patch 
\
            "
 SRC_URI:append:class-native = " \
            file://perl-configpm-switch.patch \
-- 
2.25.1

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#188897): 
https://lists.openembedded.org/g/openembedded-core/message/188897
Mute This Topic: https://lists.openembedded.org/mt/101875704/21656
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub 
[[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to