Skip to content

Commit 3ba588d

Browse files
committed
Fix sporadic failures in t/01_run.t
Wait until all sub processes have been forked before stopping the main sub process. This may help to avoid sporatic failure we sometimes see on OBS on ppc64le and aarch64 builds (probably because those machines tend to be slow). Related ticket: https://progress.opensuse.org/issues/178183
1 parent 9905ee9 commit 3ba588d

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

t/01_run.t

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,6 +467,10 @@ subtest 'process code()' => sub {
467467
is $p->read_all, '', 'stdout is empty';
468468
};
469469

470+
sub _number_of_process_in_group {
471+
scalar(split "\n", qx{pgrep -g @_} or die "Unable to run pgrep: $!");
472+
}
473+
470474
subtest stop_whole_process_group_gracefully => sub {
471475
my $test_script = check_bin("$FindBin::Bin/data/simple_fork.pl");
472476

@@ -497,9 +501,13 @@ subtest stop_whole_process_group_gracefully => sub {
497501
# stop would also stop the test itself.
498502
my $test_gpid = getpgrp(0);
499503
my $sub_process_pid = $sub_process->pid;
500-
sleep 0.1 while $test_gpid == getpgrp($sub_process_pid);
504+
my $sub_process_gid;
505+
note 'waiting until process group has been created';
506+
sleep 0.01 while $test_gpid == ($sub_process_gid = getpgrp($sub_process_pid));
501507
note "test pid: $$, gpid: $test_gpid";
502-
note "sub process pid: $sub_process_pid, gpid: " . getpgrp($sub_process_pid);
508+
note "sub process pid: $sub_process_pid, gpid: $sub_process_gid";
509+
note 'waiting until all sub processes have been forked';
510+
sleep 0.01 until _number_of_process_in_group($sub_process_gid) == 3;
503511

504512
$sub_process->stop();
505513
is $sub_process->is_running, 0, 'process is shut down via kill_whole_group';

0 commit comments

Comments
 (0)