X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=testcases%2Flib%2FSocketActivation.pm;h=5a5a4484262b349e7c8c808b9711e9f84222441c;hb=db0add0f11995d4273c76c3c1ad3ab131cea6a99;hp=361977940e33c6f0c7a7279607914579e9fdc259;hpb=db174234ce41c3ac317ef25d5fff323540295e9a;p=i3%2Fi3 diff --git a/testcases/lib/SocketActivation.pm b/testcases/lib/SocketActivation.pm index 36197794..5a5a4484 100644 --- a/testcases/lib/SocketActivation.pm +++ b/testcases/lib/SocketActivation.pm @@ -49,18 +49,24 @@ sub activate_i3 { die "could not fork()"; } if ($pid == 0) { + # Start a process group so that in the parent, we can kill the entire + # process group and immediately kill i3bar and any other child + # processes. + setpgrp; + $ENV{LISTEN_PID} = $$; $ENV{LISTEN_FDS} = 1; delete $ENV{DESKTOP_STARTUP_ID}; + delete $ENV{I3SOCK}; + # $SHELL could be set to fish, which will horribly break running shell + # commands via i3’s exec feature. This happened e.g. when having + # “set-option -g default-shell "/usr/bin/fish"” in ~/.tmux.conf + delete $ENV{SHELL}; + unless ($args{dont_create_temp_dir}) { + $ENV{XDG_RUNTIME_DIR} = '/tmp/i3-testsuite/'; + mkdir $ENV{XDG_RUNTIME_DIR}; + } $ENV{DISPLAY} = $args{display}; - $ENV{PATH} = join(':', - '../i3-nagbar', - '../i3-msg', - '../i3-config-wizard', - '../i3bar', - '..', - $ENV{PATH} - ); # We are about to exec, but we did not modify $^F to include $socket # when creating the socket (because the file descriptor could have a @@ -85,16 +91,35 @@ sub activate_i3 { # Construct the command to launch i3. Use maximum debug level, disable # the interactive signalhandler to make it crash immediately instead. - # Also disable logging to SHM since we want to redirect the logs anyways. - my $i3cmd = abs_path("../i3") . " -V -d all --disable-signalhandler --shmlog-size=0"; + # Also disable logging to SHM since we redirect the logs anyways. + # Force Xinerama because we use Xdmx for multi-monitor tests. + my $i3cmd = q|i3 --shmlog-size=0 --disable-signalhandler|; + if (!defined($args{inject_randr15})) { + $i3cmd .= q| --force-xinerama|; + } + if (!$args{validate_config}) { + # We only set logging if i3 is actually started, but not if we only + # validate the config file. This is to keep logging to a minimum as + # such a test will likely want to inspect the log file. + $i3cmd .= q| -V -d all|; + } # For convenience: my $outdir = $args{outdir}; my $test = $args{testname}; + if ($args{restart}) { + $i3cmd .= ' -L ' . abs_path('restart-state.golden'); + } + + if ($args{validate_config}) { + $i3cmd .= ' -C'; + } + if ($args{valgrind}) { $i3cmd = - qq|valgrind -v --log-file="$outdir/valgrind-for-$test.log" | . + qq|valgrind --log-file="$outdir/valgrind-for-$test.log" | . + qq|--suppressions="./valgrind.supp" | . qq|--leak-check=full --track-origins=yes --num-callers=20 | . qq|--tool=memcheck -- $i3cmd|; } @@ -114,6 +139,26 @@ sub activate_i3 { 'sh -c "export LISTEN_PID=\$\$; ' . $cmd . '"'; } + if ($args{xtrace}) { + my $out = "$outdir/xtrace-for-$test.log"; + + # See comment in $args{strace} branch. + $cmd = qq|xtrace -n -o "$out" -- | . + 'sh -c "export LISTEN_PID=\$\$; ' . $cmd . '"'; + } + + if ($args{inject_randr15}) { + # See comment in $args{strace} branch. + $cmd = 'test.inject_randr15 --getmonitors_reply="' . + $args{inject_randr15} . '" ' . + ($args{inject_randr15_outputinfo} + ? '--getoutputinfo_reply="' . + $args{inject_randr15_outputinfo} . '" ' + : '') . + '-- ' . + 'sh -c "export LISTEN_PID=\$\$; ' . $cmd . '"'; + } + # We need to use the shell due to using output redirections. exec '/bin/sh', '-c', $cmd; @@ -125,6 +170,11 @@ sub activate_i3 { # descriptor on the listening socket. $socket->close; + if ($args{validate_config}) { + $args{cv}->send(1); + return $pid; + } + # We now connect (will succeed immediately) and send a request afterwards. # As soon as the reply is there, i3 is considered ready. my $cl = IO::Socket::UNIX->new(Peer => $args{unix_socket_path});