]> git.sur5r.net Git - i3/i3/blob - testcases/t/159-socketpaths.t
Merge branch 'fix-resize-focus'
[i3/i3] / testcases / t / 159-socketpaths.t
1 #!perl
2 # vim:ts=4:sw=4:expandtab
3 # !NO_I3_INSTANCE! will prevent complete-run.pl from starting i3
4 #
5 # Tests if the various ipc_socket_path options are correctly handled
6 #
7 use i3test;
8 use File::Temp qw(tempfile tempdir);
9 use POSIX qw(getuid);
10 use v5.10;
11
12 #####################################################################
13 # default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
14 #####################################################################
15
16 my $config = <<EOT;
17 # i3 config file (v4)
18 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
19 EOT
20
21 # ensure XDG_RUNTIME_DIR is not set
22 delete $ENV{XDG_RUNTIME_DIR};
23 my $pid = launch_with_config($config, 1);
24
25 my $folder = "/tmp/i3-" . getpwuid(getuid());
26 ok(-d $folder, "folder $folder exists");
27 my $socketpath = "$folder/ipc-socket." . $pid;
28 ok(-S $socketpath, "file $socketpath exists and is a socket");
29
30 exit_gracefully($pid);
31
32 #####################################################################
33 # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
34 #####################################################################
35
36 my $rtdir = tempdir(CLEANUP => 1);
37
38 ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
39
40 $ENV{XDG_RUNTIME_DIR} = $rtdir;
41
42 $pid = launch_with_config($config, 1);
43
44 ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
45 $socketpath = "$rtdir/i3/ipc-socket." . $pid;
46 ok(-S $socketpath, "file $socketpath exists and is a socket");
47
48 exit_gracefully($pid);
49
50 #####################################################################
51 # configuration file case: socket gets placed whereever we specify
52 #####################################################################
53
54 my $tmpdir = tempdir(CLEANUP => 1);
55 $socketpath = $tmpdir . "/config.sock";
56 ok(! -e $socketpath, "$socketpath does not exist yet");
57
58 $config = <<EOT;
59 # i3 config file (v4)
60 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
61 ipc-socket $socketpath
62 EOT
63
64 $pid = launch_with_config($config, 1);
65
66 ok(-S $socketpath, "file $socketpath exists and is a socket");
67
68 exit_gracefully($pid);
69
70 done_testing;