TT#111150 When testing the daemon keep the stdout and stderr on failures

To be able to ease diagnosing problems in the functional tests, we
should not remove the log files storing stdout and stderr, otherwise
debugging issue from a failed or crashing daemon turn to be rather
brittle.

Change-Id: Id285049da7ad030ef7b041f7e2dde86e97ef6487
pull/1252/head
Guillem Jover 4 years ago
parent 07695d2abb
commit 2b4c4d02a5

@ -42,8 +42,14 @@ sub autotest_start {
ok -x $ENV{RTPE_BIN}, 'RTPE_BIN points to executable';
}
$rtpe_stdout = File::Temp::tempfile() or die;
$rtpe_stderr = File::Temp::tempfile() or die;
$rtpe_stdout = File::Temp->new(
TEMPLATE => 'rtpe-out.XXXXXXXXXX',
TMPDIR => 1,
) or die;
$rtpe_stderr = File::Temp->new(
TEMPLATE => 'rtpe-err.XXXXXXXXXX',
TMPDIR => 1,
) or die;
SKIP: {
skip 'daemon is running externally', 1 if $ENV{RTPE_TEST_NO_LAUNCH};
local $ENV{GLIB_SLICE} = 'debug-blocks';
@ -248,11 +254,22 @@ sub new_tt {
$tt = $tag_iter++ . "-test-totag" . $tag_suffix;
}
sub terminate {
my $msg = shift;
$rtpe_stdout->unlink_on_destroy(0);
$rtpe_stderr->unlink_on_destroy(0);
print "hint: rtpe stdout output is at $rtpe_stdout\n";
print "hint: rtpe stderr output is at $rtpe_stderr\n";
die "error: $msg\n";
}
END {
if ($rtpe_pid) {
kill('INT', $rtpe_pid) or die;
kill('INT', $rtpe_pid) or terminate("cannot interrupt rtpe");
# wait for daemon to terminate
my $status = -1;
for (1 .. 50) {
@ -261,8 +278,8 @@ END {
Time::HiRes::usleep(100000); # 100 ms x 50 = 5 sec
}
kill('KILL', $rtpe_pid) if $status == 0;
$status == $rtpe_pid or die;
$? == 0 or die;
$status == $rtpe_pid or terminate("cannot wait for process $rtpe_pid: $status: $!");
$? == 0 or terminate("process exited with $?");
}
}

Loading…
Cancel
Save