#!perl # vim:ts=4:sw=4:expandtab # # Tests if the various ipc_socket_path options are correctly handled # use i3test i3_autostart => 0; use File::Temp qw(tempfile tempdir); use POSIX qw(getuid); use v5.10; ##################################################################### # default case: socket will be created in /tmp/i3-/ipc-socket. ##################################################################### my $config = <; my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1); my @files_after = ; @files_after = grep { !($_ ~~ @files_before) } @files_after; is(@files_after, 1, 'one new temp directory'); my $folder = "/tmp/i3-" . getpwuid(getuid()); like($files_after[0], qr/^$folder/, 'temp directory matches expected pattern'); $folder = $files_after[0]; ok(-d $folder, "folder $folder exists"); my $socketpath = "$folder/ipc-socket." . $pid; ok(-S $socketpath, "file $socketpath exists and is a socket"); exit_gracefully($pid); ##################################################################### # XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket. ##################################################################### my $rtdir = tempdir(CLEANUP => 1); ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet"); $ENV{XDG_RUNTIME_DIR} = $rtdir; $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1); ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory"); $socketpath = "$rtdir/i3/ipc-socket." . $pid; ok(-S $socketpath, "file $socketpath exists and is a socket"); exit_gracefully($pid); ##################################################################### # configuration file case: socket gets placed whereever we specify ##################################################################### my $tmpdir = tempdir(CLEANUP => 1); $socketpath = $tmpdir . "/config.sock"; ok(! -e $socketpath, "$socketpath does not exist yet"); $config = < 1, dont_create_temp_dir => 1); ok(-S $socketpath, "file $socketpath exists and is a socket"); exit_gracefully($pid); done_testing;