]> git.sur5r.net Git - i3/i3/blobdiff - testcases/lib/SocketActivation.pm
Merge branch 'master' into next
[i3/i3] / testcases / lib / SocketActivation.pm
index 36560a8d5113471f0b33f1a5d051fc69bd6f4af2..8f52bddc4a3eb8a92a3ba37ae8363a29cfd9b779 100644 (file)
@@ -7,6 +7,7 @@ use IO::Socket::UNIX; # core
 use Cwd qw(abs_path); # core
 use POSIX qw(:fcntl_h); # core
 use AnyEvent::Handle; # not core
+use AnyEvent::Util; # not core
 use Exporter 'import';
 use v5.10;
 
@@ -51,6 +52,10 @@ sub activate_i3 {
         $ENV{LISTEN_PID} = $$;
         $ENV{LISTEN_FDS} = 1;
         delete $ENV{DESKTOP_STARTUP_ID};
+        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',
@@ -75,16 +80,28 @@ sub activate_i3 {
         if (fileno($socket) != 3) {
             POSIX::close(3);
             POSIX::dup2(fileno($socket), 3);
+            POSIX::close(fileno($socket));
         }
 
+        # Make sure no file descriptors are open. Strangely, I got an open file
+        # descriptor pointing to AnyEvent/Impl/EV.pm when testing.
+        AnyEvent::Util::close_all_fds_except(0, 1, 2, 3);
+
         # Construct the command to launch i3. Use maximum debug level, disable
         # the interactive signalhandler to make it crash immediately instead.
-        my $i3cmd = abs_path("../i3") . " -V -d all --disable-signalhandler";
+        # Also disable logging to SHM since we redirect the logs anyways.
+        # Force Xinerama because we use Xdmx for multi-monitor tests.
+        my $i3cmd = abs_path("../i3") . q| -V -d all --disable-signalhandler| .
+                                        q| --shmlog-size=0 --force-xinerama|;
 
         # For convenience:
         my $outdir = $args{outdir};
         my $test = $args{testname};
 
+        if ($args{restart}) {
+            $i3cmd .= ' -L ' . abs_path('restart-state.golden');
+        }
+
         if ($args{valgrind}) {
             $i3cmd =
                 qq|valgrind -v --log-file="$outdir/valgrind-for-$test.log" | .