From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.2 required=3.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF shortcircuit=no autolearn=ham autolearn_force=no version=3.4.6 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5B9791F568 for ; Wed, 13 Sep 2023 09:12:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=80x24.org; s=selector1; t=1694596363; bh=9sv1QTzGW29iqz2ROcHPLJkq8Q3HYoZksyFk7gj6Aok=; h=From:To:Subject:Date:In-Reply-To:References:From; b=eFT+CuA7eLW/nRiay1gHbCPj7U62L1ubypbvbnjR88sAuiZ1ODPMY/y8zFeY5pzGa KFYJQddvXNwMrsdNQU9u5qbDyBYGwVigcYoQH2/OVFK9vj8/PyjJl8V4KkQnShQK6o 6FBQ69zAupPeBXgHD8lOAmbefkPa8vcpPENhblno= From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 5/5] t/xap_helper: improve reliability of TTIN/TTOU tests Date: Wed, 13 Sep 2023 09:12:42 +0000 Message-ID: <20230913091242.1827709-6-e@80x24.org> In-Reply-To: <20230913091242.1827709-1-e@80x24.org> References: <20230913091242.1827709-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: 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 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/t/xap_helper.t b/t/xap_helper.t index 54bef191..2303301d 100644 --- a/t/xap_helper.t +++ b/t/xap_helper.t @@ -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;