2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • http://build.i3wm.org/docs/testsuite.html
8 # • http://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • http://build.i3wm.org/docs/ipc.html
14 # • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
15 # (unless you are already familiar with Perl)
17 # Tests if the various ipc_socket_path options are correctly handled
19 use i3test i3_autostart => 0;
20 use File::Temp qw(tempfile tempdir);
25 #####################################################################
26 # default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
27 #####################################################################
31 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
34 # ensure XDG_RUNTIME_DIR is not set
35 delete $ENV{XDG_RUNTIME_DIR};
37 my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
38 my $socketpath = get_socket_path(0);
39 my $folder = "/tmp/i3-" . getpwuid(getuid());
40 like(dirname($socketpath), qr/^$folder/, 'temp directory matches expected pattern');
41 $folder = dirname($socketpath);
43 ok(-d $folder, "folder $folder exists");
44 $socketpath = "$folder/ipc-socket." . $pid;
45 ok(-S $socketpath, "file $socketpath exists and is a socket");
47 exit_gracefully($pid);
49 #####################################################################
50 # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
51 #####################################################################
53 my $rtdir = tempdir(CLEANUP => 1);
55 ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
57 $ENV{XDG_RUNTIME_DIR} = $rtdir;
59 $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
61 ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
62 $socketpath = "$rtdir/i3/ipc-socket." . $pid;
63 ok(-S $socketpath, "file $socketpath exists and is a socket");
65 exit_gracefully($pid);
67 #####################################################################
68 # configuration file case: socket gets placed whereever we specify
69 #####################################################################
71 my $tmpdir = tempdir(CLEANUP => 1);
72 $socketpath = $tmpdir . "/config.sock";
73 ok(! -e $socketpath, "$socketpath does not exist yet");
77 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
78 ipc-socket $socketpath
81 $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
83 ok(-S $socketpath, "file $socketpath exists and is a socket");
85 exit_gracefully($pid);