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;
$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);
-if (!$ENV{TEST_LEI_DAEMON_PERSIST_DIR} &&
+
+# I get ECONNRESET from lei on FreeBSD 11.3 even with
+# kern.ipc.soacceptqueue=1073741823, so persistent lei-daemon in tests
+# is Linux-only for now:
+if ($^O eq 'linux' && !$ENV{TEST_LEI_DAEMON_PERSIST_DIR} &&
(PublicInbox::Spawn->can('recv_cmd4') ||
eval { require Socket::MsgHdr })) {
$lei_env = {};
sub run_test ($) {
my ($test) = @_;
+ syswrite($run_log, "$$ $test\n");
my $log_fh;
if ($log_suffix ne '') {
my $log = $test;
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";