From: Michael Stapelberg Date: Tue, 15 Nov 2011 23:30:17 +0000 (+0000) Subject: complete-run: implement --strace, make --valgrind log to test-specific file X-Git-Tag: 4.2~251 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=77a9e4b18f391574896099e966eea5786a598350;p=i3%2Fi3 complete-run: implement --strace, make --valgrind log to test-specific file --- diff --git a/testcases/complete-run.pl b/testcases/complete-run.pl index c43fbf07..e85f5bbb 100755 --- a/testcases/complete-run.pl +++ b/testcases/complete-run.pl @@ -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. +C. + +=item B<--strace> + +Runs i3 under strace to trace system calls. The output will be available in +C. =item B<--coverage-testing> diff --git a/testcases/lib/SocketActivation.pm b/testcases/lib/SocketActivation.pm index 38220547..bdcb40e7 100644 --- a/testcases/lib/SocketActivation.pm +++ b/testcases/lib/SocketActivation.pm @@ -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; diff --git a/testcases/lib/i3test.pm b/testcases/lib/i3test.pm index 7473b617..33193905 100644 --- a/testcases/lib/i3test.pm +++ b/testcases/lib/i3test.pm @@ -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, );