2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
5 # Tests if the various ipc_socket_path options are correctly handled
10 use File::Temp qw(tempfile tempdir);
14 # assuming we are run by complete-run.pl
15 my $i3_path = abs_path("../i3");
17 #####################################################################
18 # default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
19 #####################################################################
21 my ($fh, $tmpfile) = tempfile();
22 say $fh "# i3 config file (v4)";
23 say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
27 my $i3cmd = "unset XDG_RUNTIME_DIR; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
28 my $process = Proc::Background->new($i3cmd);
31 diag("pid = " . $process->pid);
33 my $folder = "/tmp/i3-" . getpwuid(getuid());
34 ok(-d $folder, "folder $folder exists");
35 my $socketpath = "$folder/ipc-socket." . $process->pid;
36 ok(-S $socketpath, "file $socketpath exists and is a socket");
38 exit_gracefully($process->pid, $socketpath);
42 #####################################################################
43 # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
44 #####################################################################
46 my $rtdir = tempdir(CLEANUP => 1);
48 ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
50 $i3cmd = "export XDG_RUNTIME_DIR=$rtdir; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
51 $process = Proc::Background->new($i3cmd);
54 ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
55 $socketpath = "$rtdir/i3/ipc-socket." . $process->pid;
56 ok(-S $socketpath, "file $socketpath exists and is a socket");
58 exit_gracefully($process->pid, $socketpath);
62 #####################################################################
63 # configuration file case: socket gets placed whereever we specify
64 #####################################################################
66 my $tmpdir = tempdir(CLEANUP => 1);
67 $socketpath = $tmpdir . "/config.sock";
68 ok(! -e $socketpath, "$socketpath does not exist yet");
70 ($fh, $tmpfile) = tempfile();
71 say $fh "# i3 config file (v4)";
72 say $fh "font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1";
73 say $fh "ipc-socket $socketpath";
76 $i3cmd = "export XDG_RUNTIME_DIR=$rtdir; exec " . abs_path("../i3") . " -V -d all --disable-signalhandler -c $tmpfile >/dev/null 2>/dev/null";
77 $process = Proc::Background->new($i3cmd);
80 ok(-S $socketpath, "file $socketpath exists and is a socket");
82 exit_gracefully($process->pid, $socketpath);