From: Eric Wong <e@80x24.org>
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 [thread overview]
Message-ID: <20210428193729.32288-2-e@80x24.org> (raw)
In-Reply-To: <20210428193729.32288-1-e@80x24.org>
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";
next prev parent reply other threads:[~2021-04-28 19:37 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-28 19:37 [PATCH 0/2] "make check-run" fixed Eric Wong
2021-04-28 19:37 ` Eric Wong [this message]
2021-04-28 19:37 ` [PATCH 2/2] lei: avoid close(STD{IN,OUT,ERR}) in oneshot mode Eric Wong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://public-inbox.org/README
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210428193729.32288-2-e@80x24.org \
--to=e@80x24.org \
--cc=meta@public-inbox.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).