complete-run: implement --strace, make --valgrind log to test-specific file

This commit is contained in:
Michael Stapelberg 2011-11-15 23:30:17 +00:00
parent 5b4f8eb7e2
commit 77a9e4b18f
3 changed files with 31 additions and 7 deletions

View File

@ -51,6 +51,7 @@ sub Log { say $log "@_" }
my $coverage_testing = 0;
my $valgrind = 0;
my $strace = 0;
my $help = 0;
# Number of tests to run in parallel. Important to know how many Xdummy
# instances we need to start (unless @displays are given). Defaults to
@ -62,6 +63,7 @@ my @childpids = ();
my $result = GetOptions(
"coverage-testing" => \$coverage_testing,
"valgrind" => \$valgrind,
"strace" => \$strace,
"display=s" => \@displays,
"parallel=i" => \$parallel,
"help|?" => \$help,
@ -171,8 +173,9 @@ sub take_job {
display => $display,
configfile => $tmpfile,
outdir => $outdir,
logpath => $logpath,
testname => $basename,
valgrind => $valgrind,
strace => $strace,
cv => $activate_cv
);
@ -239,7 +242,7 @@ sub take_job {
my $output;
open(my $spool, '>', \$output);
my $parser = TAP::Parser->new({
exec => [ 'sh', '-c', qq|DISPLAY=$display LOGPATH="$logpath" OUTDIR="$outdir" VALGRIND=$valgrind /usr/bin/perl -Ilib $test| ],
exec => [ 'sh', '-c', qq|DISPLAY=$display TESTNAME="$basename" OUTDIR="$outdir" VALGRIND=$valgrind STRACE=$strace /usr/bin/perl -Ilib $test| ],
spool => $spool,
merge => 1,
});
@ -354,7 +357,12 @@ complete-run.pl will start (num_cores * 2) Xdummy instances.
=item B<--valgrind>
Runs i3 under valgrind to find memory problems. The output will be available in
C<latest/valgrind.log>.
C<latest/valgrind-for-$test.log>.
=item B<--strace>
Runs i3 under strace to trace system calls. The output will be available in
C<latest/strace-for-$test.log>.
=item B<--coverage-testing>

View File

@ -75,16 +75,31 @@ sub activate_i3 {
# the interactive signalhandler to make it crash immediately instead.
my $i3cmd = abs_path("../i3") . " -V -d all --disable-signalhandler";
# For convenience:
my $outdir = $args{outdir};
my $test = $args{testname};
if ($args{valgrind}) {
$i3cmd =
qq|valgrind -v --log-file="$args{outdir}/valgrind.log" | .
qq|valgrind -v --log-file="$outdir/valgrind-for-$test.log" | .
qq|--leak-check=full --track-origins=yes --num-callers=20 | .
qq|--tool=memcheck -- $i3cmd|;
}
# Append to $args{logpath} instead of overwriting because i3 might be
my $logfile = "$outdir/i3-log-for-$test";
# Append to $logfile instead of overwriting because i3 might be
# run multiple times in one testcase.
my $cmd = "exec $i3cmd -c $args{configfile} >>$args{logpath} 2>&1";
my $cmd = "exec $i3cmd -c $args{configfile} >>$logfile 2>&1";
if ($args{strace}) {
my $out = "$outdir/strace-for-$test.log";
# We overwrite LISTEN_PID with the correct process ID to make
# socket activation work (LISTEN_PID has to match getpid(),
# otherwise the LISTEN_FDS will be treated as a left-over).
$cmd = qq|strace -fF -s2048 -v -o "$out" -- | .
'sh -c "export LISTEN_PID=\$\$; ' . $cmd . '"';
}
# We need to use the shell due to using output redirections.
exec '/bin/sh', '-c', $cmd;

View File

@ -434,8 +434,9 @@ sub launch_with_config {
display => $ENV{DISPLAY},
configfile => $tmpfile,
outdir => $ENV{OUTDIR},
logpath => $ENV{LOGPATH},
testname => $ENV{TESTNAME},
valgrind => $ENV{VALGRIND},
strace => $ENV{STRACE},
cv => $cv,
);