]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
t/xap_helper: improve reliability of TTIN/TTOU tests
authorEric Wong <e@80x24.org>
Wed, 13 Sep 2023 09:12:42 +0000 (09:12 +0000)
committerEric Wong <e@80x24.org>
Thu, 14 Sep 2023 10:06:28 +0000 (10:06 +0000)
We need to send more parallel requests and possibly retry more
to ensure SIGTTIN/TTOU are handled due to OS scheduling delays.

$doreq was also getting too noisy with extra is() calls, so just
xbail on mismatches if somehow we get a truncated write.

t/xap_helper.t

index 54bef191d014f2f99142410403c89791c9c83584..2303301d3145261ec9667e309fde84d681854d66 100644 (file)
@@ -54,9 +54,8 @@ my $doreq = sub {
        push @fds, fileno($err) if $err;
        my $n = PublicInbox::IPC::send_cmd($s, \@fds, $buf, 0);
        $n // xbail "send: $!";
-       my $arg = "@arg";
-       $arg =~ s/\Q$tmp\E/\$TMP/gs;
-       is(length($buf), $n, "req $arg sent");
+       my $exp = length($buf);
+       $exp == $n or xbail "req @arg sent short ($n != $exp)";
        $x;
 };
 
@@ -109,15 +108,16 @@ my $test = sub {
        $tries = 0;
        my @ins = ($s, qw(test_inspect -d), $ibx_idx[0]);
        kill('TTIN', $pid);
-       until (scalar(keys %pids) >= 2 || ++$tries > 10) {
+       until (scalar(keys %pids) >= 2 || ++$tries > 100) {
                tick;
-               my @r = map { $doreq->(@ins) } (0..5);
+               my @r = map { $doreq->(@ins) } (0..100);
                for my $fh (@r) {
                        my $buf = do { local $/; <$fh> } // die "read: $!";
                        $buf =~ /\bpid=(\d+)/ and $pids{$1} = undef;
                }
        }
-       is(scalar keys %pids, 2, 'have two pids');
+       is(scalar keys %pids, 2, 'have two pids') or
+               diag 'pids='.explain(\%pids);
 
        kill('TTOU', $pid);
        %pids = ();
@@ -127,7 +127,7 @@ my $test = sub {
        tick($delay);
        until (scalar(keys %pids) == 1 || ++$tries > 100) {
                %pids = ();
-               my @r = map { $doreq->(@ins) } (0..5);
+               my @r = map { $doreq->(@ins) } (0..100);
                for my $fh (@r) {
                        my $buf = do { local $/; <$fh> } // die "read: $!";
                        $buf =~ /\bpid=(\d+)/ and $pids{$1} = undef;