2011-04-26 19:15:55 +02:00
|
|
|
#!perl
|
|
|
|
# vim:ts=4:sw=4:expandtab
|
|
|
|
#
|
2012-09-10 14:09:01 +02:00
|
|
|
# Please read the following documents before working on tests:
|
|
|
|
# • http://build.i3wm.org/docs/testsuite.html
|
|
|
|
# (or docs/testsuite)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/lib-i3test.html
|
|
|
|
# (alternatively: perldoc ./testcases/lib/i3test.pm)
|
|
|
|
#
|
|
|
|
# • http://build.i3wm.org/docs/ipc.html
|
|
|
|
# (or docs/ipc)
|
|
|
|
#
|
|
|
|
# • http://onyxneon.com/books/modern_perl/modern_perl_a4.pdf
|
|
|
|
# (unless you are already familiar with Perl)
|
|
|
|
#
|
2011-04-26 19:15:55 +02:00
|
|
|
# Tests if the various ipc_socket_path options are correctly handled
|
|
|
|
#
|
2011-11-25 17:39:19 +01:00
|
|
|
use i3test i3_autostart => 0;
|
2011-04-26 19:15:55 +02:00
|
|
|
use File::Temp qw(tempfile tempdir);
|
2012-06-29 21:21:07 +02:00
|
|
|
use File::Basename;
|
2011-04-26 19:15:55 +02:00
|
|
|
use POSIX qw(getuid);
|
|
|
|
use v5.10;
|
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# default case: socket will be created in /tmp/i3-<username>/ipc-socket.<pid>
|
|
|
|
#####################################################################
|
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
my $config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
EOT
|
2011-04-26 19:15:55 +02:00
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
# ensure XDG_RUNTIME_DIR is not set
|
|
|
|
delete $ENV{XDG_RUNTIME_DIR};
|
2011-12-18 18:53:21 +01:00
|
|
|
|
2012-01-30 16:51:48 +01:00
|
|
|
my $pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
|
2012-06-29 21:21:07 +02:00
|
|
|
my $socketpath = get_socket_path(0);
|
2011-04-26 19:15:55 +02:00
|
|
|
my $folder = "/tmp/i3-" . getpwuid(getuid());
|
2012-06-29 21:21:07 +02:00
|
|
|
like(dirname($socketpath), qr/^$folder/, 'temp directory matches expected pattern');
|
|
|
|
$folder = dirname($socketpath);
|
2011-12-18 18:53:21 +01:00
|
|
|
|
2011-04-26 19:15:55 +02:00
|
|
|
ok(-d $folder, "folder $folder exists");
|
2012-06-29 21:21:07 +02:00
|
|
|
$socketpath = "$folder/ipc-socket." . $pid;
|
2011-04-26 19:15:55 +02:00
|
|
|
ok(-S $socketpath, "file $socketpath exists and is a socket");
|
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
exit_gracefully($pid);
|
2011-04-26 19:15:55 +02:00
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# XDG_RUNTIME_DIR case: socket gets created in $XDG_RUNTIME_DIR/i3/ipc-socket.<pid>
|
|
|
|
#####################################################################
|
|
|
|
|
|
|
|
my $rtdir = tempdir(CLEANUP => 1);
|
|
|
|
|
|
|
|
ok(! -e "$rtdir/i3", "$rtdir/i3 does not exist yet");
|
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
$ENV{XDG_RUNTIME_DIR} = $rtdir;
|
|
|
|
|
2012-01-30 16:51:48 +01:00
|
|
|
$pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
|
2011-04-26 19:15:55 +02:00
|
|
|
|
|
|
|
ok(-d "$rtdir/i3", "$rtdir/i3 exists and is a directory");
|
2011-10-05 00:34:23 +02:00
|
|
|
$socketpath = "$rtdir/i3/ipc-socket." . $pid;
|
2011-04-26 19:15:55 +02:00
|
|
|
ok(-S $socketpath, "file $socketpath exists and is a socket");
|
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
exit_gracefully($pid);
|
2011-04-26 19:15:55 +02:00
|
|
|
|
|
|
|
#####################################################################
|
|
|
|
# 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");
|
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
$config = <<EOT;
|
|
|
|
# i3 config file (v4)
|
|
|
|
font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
|
|
|
|
ipc-socket $socketpath
|
|
|
|
EOT
|
2011-04-26 19:15:55 +02:00
|
|
|
|
2012-01-30 16:51:48 +01:00
|
|
|
$pid = launch_with_config($config, dont_add_socket_path => 1, dont_create_temp_dir => 1);
|
2011-04-26 19:15:55 +02:00
|
|
|
|
|
|
|
ok(-S $socketpath, "file $socketpath exists and is a socket");
|
|
|
|
|
2011-10-05 00:34:23 +02:00
|
|
|
exit_gracefully($pid);
|
2011-04-26 19:15:55 +02:00
|
|
|
|
|
|
|
done_testing;
|