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);
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 my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
25 my $socketpath = get_socket_path(0);
26 my $folder = "/tmp/i3-" . getpwuid(getuid());
27 like(dirname($socketpath), qr/^$folder/, 'temp directory matches expected pattern');
28 $folder = dirname($socketpath);
30 ok(-d $folder, "folder $folder exists");
31 $socketpath = "$folder/ipc-socket." . $pid;
32 ok(-S $socketpath, "file $socketpath exists and is a socket");
34 exit_gracefully($pid);
36 #####################################################################
37 # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
38 #####################################################################
40 my $rtdir = tempdir(CLEANUP => 1);
42 ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
44 $ENV{XDG_RUNTIME_DIR} = $rtdir;
46 $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
48 ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
49 $socketpath = "$rtdir/i3/ipc-socket." . $pid;
50 ok(-S $socketpath, "file $socketpath exists and is a socket");
52 exit_gracefully($pid);
54 #####################################################################
55 # configuration file case: socket gets placed whereever we specify
56 #####################################################################
58 my $tmpdir = tempdir(CLEANUP => 1);
59 $socketpath = $tmpdir . "/config.sock";
60 ok(! -e $socketpath, "$socketpath does not exist yet");
64 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
65 ipc-socket $socketpath
68 $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
70 ok(-S $socketpath, "file $socketpath exists and is a socket");
72 exit_gracefully($pid);