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
my $result = GetOptions(
"coverage-testing" => \$coverage_testing,
"valgrind" => \$valgrind,
+ "strace" => \$strace,
"display=s" => \@displays,
"parallel=i" => \$parallel,
"help|?" => \$help,
display => $display,
configfile => $tmpfile,
outdir => $outdir,
- logpath => $logpath,
+ testname => $basename,
valgrind => $valgrind,
+ strace => $strace,
cv => $activate_cv
);
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,
});
=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>
# 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;
display => $ENV{DISPLAY},
configfile => $tmpfile,
outdir => $ENV{OUTDIR},
- logpath => $ENV{LOGPATH},
+ testname => $ENV{TESTNAME},
valgrind => $ENV{VALGRIND},
+ strace => $ENV{STRACE},
cv => $cv,
);