From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: X-Spam-Status: No, score=-4.0 required=3.0 tests=ALL_TRUSTED,BAYES_00 shortcircuit=no autolearn=ham autolearn_force=no version=3.4.2 Received: from localhost (dcvr.yhbt.net [127.0.0.1]) by dcvr.yhbt.net (Postfix) with ESMTP id 5218B1F934 for ; Wed, 28 Apr 2021 19:37:29 +0000 (UTC) From: Eric Wong To: meta@public-inbox.org Subject: [PATCH 1/2] t/run: support TEST_RUN_LOG to diagnose process death Date: Wed, 28 Apr 2021 19:37:28 +0000 Message-Id: <20210428193729.32288-2-e@80x24.org> In-Reply-To: <20210428193729.32288-1-e@80x24.org> References: <20210428193729.32288-1-e@80x24.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Knowing which process ran what before dying unexpectedly helps with debugging. --- t/run.perl | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/t/run.perl b/t/run.perl index 2fbe4033..acd60ff5 100755 --- a/t/run.perl +++ b/t/run.perl @@ -19,6 +19,7 @@ use Getopt::Long qw(:config gnu_getopt no_ignore_case auto_abbrev); use Errno qw(EINTR); use Fcntl qw(:seek); use POSIX qw(_POSIX_PIPE_BUF WNOHANG); +use File::Temp (); my $jobs = 1; my $repeat = 1; $| = 1; @@ -39,6 +40,15 @@ open my $OLDERR, '>&STDERR' or die "dup STDERR: $!"; $OLDOUT->autoflush(1); $OLDERR->autoflush(1); +my ($run_log, $tmp_rl); +my $rl = $ENV{TEST_RUN_LOG}; +unless ($rl) { + $tmp_rl = File::Temp->new(CLEANUP => 1); + $rl = $tmp_rl->filename; +} +open $run_log, '+>>', $rl or die "open $rl: $!"; +$run_log->autoflush(1); # one reader, many writers + key2sub($_) for @tests; # precache my ($for_destroy, $lei_env, $lei_daemon_pid, $owner_pid); @@ -120,6 +130,7 @@ END { test_status() if (defined($worker_test) && $worker == $$) } sub run_test ($) { my ($test) = @_; + syswrite($run_log, "$$ $test\n"); my $log_fh; if ($log_suffix ne '') { my $log = $test; @@ -205,7 +216,12 @@ for (my $i = $repeat; $i != 0; $i--) { push @err, "reaped unknown $pid ($?)"; next; } - push @err, "job[$j] ($?)" if $?; + if ($?) { + seek($run_log, 0, SEEK_SET); + chomp(my @t = grep(/^$pid /, <$run_log>)); + $t[0] //= "$pid unknown"; + push @err, "job[$j] ($?) PID=$t[-1]"; + } # skip_all can exit(0), respawn if needed: if (!$eof) { print $OLDERR "# respawning job[$j]\n";