2 # vim:ts=4:sw=4:expandtab
4 # Tests if the various ipc_socket_path options are correctly handled
6 use i3test i3_autostart => 0;
7 use File::Temp qw(tempfile tempdir);
11 #####################################################################
12 # default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
13 #####################################################################
17 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
20 # ensure XDG_RUNTIME_DIR is not set
21 delete $ENV{XDG_RUNTIME_DIR};
22 my $pid = launch_with_config($config, dont_add_socket_path => 1);
24 my $folder = "/tmp/i3-" . getpwuid(getuid());
25 ok(-d $folder, "folder $folder exists");
26 my $socketpath = "$folder/ipc-socket." . $pid;
27 ok(-S $socketpath, "file $socketpath exists and is a socket");
29 exit_gracefully($pid);
31 #####################################################################
32 # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
33 #####################################################################
35 my $rtdir = tempdir(CLEANUP => 1);
37 ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
39 $ENV{XDG_RUNTIME_DIR} = $rtdir;
41 $pid = launch_with_config($config, dont_add_socket_path => 1);
43 ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
44 $socketpath = "$rtdir/i3/ipc-socket." . $pid;
45 ok(-S $socketpath, "file $socketpath exists and is a socket");
47 exit_gracefully($pid);
49 #####################################################################
50 # configuration file case: socket gets placed whereever we specify
51 #####################################################################
53 my $tmpdir = tempdir(CLEANUP => 1);
54 $socketpath = $tmpdir . "/config.sock";
55 ok(! -e $socketpath, "$socketpath does not exist yet");
59 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
60 ipc-socket $socketpath
63 $pid = launch_with_config($config, dont_add_socket_path => 1);
65 ok(-S $socketpath, "file $socketpath exists and is a socket");
67 exit_gracefully($pid);