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
8 use File::Temp qw(tempfile tempdir);
12 #####################################################################
13 # default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
14 #####################################################################
18 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
21 # ensure XDG_RUNTIME_DIR is not set
22 delete $ENV{XDG_RUNTIME_DIR};
24 # See which files exist in /tmp before to not mistakenly check an already
25 # existing tmpdir of another i3 instance.
26 my @files_before = </tmp/i3-*>;
27 my $pid = launch_with_config($config, 1);
28 my @files_after = </tmp/i3-*>;
29 @files_after = grep { !($_ ~~ @files_before) } @files_after;
31 is(@files_after, 1, 'one new temp directory');
33 my $folder = "/tmp/i3-" . getpwuid(getuid());
34 like($files_after[0], qr/^$folder/, 'temp directory matches expected pattern');
35 $folder = $files_after[0];
37 ok(-d $folder, "folder $folder exists");
38 my $socketpath = "$folder/ipc-socket." . $pid;
39 ok(-S $socketpath, "file $socketpath exists and is a socket");
41 exit_gracefully($pid);
43 #####################################################################
44 # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
45 #####################################################################
47 my $rtdir = tempdir(CLEANUP => 1);
49 ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
51 $ENV{XDG_RUNTIME_DIR} = $rtdir;
53 $pid = launch_with_config($config, 1);
55 ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
56 $socketpath = "$rtdir/i3/ipc-socket." . $pid;
57 ok(-S $socketpath, "file $socketpath exists and is a socket");
59 exit_gracefully($pid);
61 #####################################################################
62 # configuration file case: socket gets placed whereever we specify
63 #####################################################################
65 my $tmpdir = tempdir(CLEANUP => 1);
66 $socketpath = $tmpdir . "/config.sock";
67 ok(! -e $socketpath, "$socketpath does not exist yet");
71 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
72 ipc-socket $socketpath
75 $pid = launch_with_config($config, 1);
77 ok(-S $socketpath, "file $socketpath exists and is a socket");
79 exit_gracefully($pid);