user/dev discussion of public-inbox itself
 help / color / mirror / code / Atom feed
Search results ordered by [date|relevance]  view[summary|nested|Atom feed]
thread overview below | download mbox.gz: |
* [PATCH 1/2] t/run: support TEST_RUN_LOG to diagnose process death
  2021-04-28 19:37  5% [PATCH 0/2] "make check-run" fixed Eric Wong
@ 2021-04-28 19:37  7% ` Eric Wong
  0 siblings, 0 replies; 2+ results
From: Eric Wong @ 2021-04-28 19:37 UTC (permalink / raw)
  To: meta

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";

^ permalink raw reply related	[relevance 7%]

* [PATCH 0/2] "make check-run" fixed
@ 2021-04-28 19:37  5% Eric Wong
  2021-04-28 19:37  7% ` [PATCH 1/2] t/run: support TEST_RUN_LOG to diagnose process death Eric Wong
  0 siblings, 1 reply; 2+ results
From: Eric Wong @ 2021-04-28 19:37 UTC (permalink / raw)
  To: meta

It turns out the oneshot mode of lei was causing problems and
propagating them to other tests.  1/2 helped me finally get to
the bottom of it and fix it in 2/2.

Eric Wong (2):
  t/run: support TEST_RUN_LOG to diagnose process death
  lei: avoid close(STD{IN,OUT,ERR}) in oneshot mode

 lib/PublicInbox/LEI.pm | 18 ++++--------------
 t/lei.t                |  1 +
 t/run.perl             | 18 +++++++++++++++++-
 3 files changed, 22 insertions(+), 15 deletions(-)


^ permalink raw reply	[relevance 5%]

Results 1-2 of 2 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2021-04-28 19:37  5% [PATCH 0/2] "make check-run" fixed Eric Wong
2021-04-28 19:37  7% ` [PATCH 1/2] t/run: support TEST_RUN_LOG to diagnose process death Eric Wong

Code repositories for project(s) associated with this public inbox

	https://80x24.org/public-inbox.git

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).