2 # vim:ts=4:sw=4:expandtab
4 # Please read the following documents before working on tests:
5 # • https://build.i3wm.org/docs/testsuite.html
8 # • https://build.i3wm.org/docs/lib-i3test.html
9 # (alternatively: perldoc ./testcases/lib/i3test.pm)
11 # • https://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 # Test that i3 will not hang if a connected client stops reading from its
18 # subscription socket and that the client is killed after a delay.
20 # Bug still in: 4.15-180-g715cea61
21 use i3test i3_config => <<EOT;
23 font -misc-fixed-medium-r-normal--13-120-75-75-C-70-iso10646-1
24 # Set the timeout to 500ms to reduce the duration of this test.
28 # Manually connect to i3 so that we can choose to not read events
30 my $sock = IO::Socket::UNIX->new(Peer => get_socket_path());
32 my $payload = '["workspace"]';
33 my $message = $magic . pack("LL", length($payload), 2) . $payload;
36 # Constantly switch between 2 workspaces to generate events.
43 local $SIG{ALRM} = sub { die "Timeout\n" };
44 # 500 is an arbitrarily large number to make sure that the socket becomes
46 for (my $i = 0; $i < 500; $i++) {
48 cmd 'workspace back_and_forth';
52 ok(!$@, 'i3 didn\'t hang');
54 # Wait for connection timeout
58 my $s = IO::Select->new($sock);
60 while ($s->can_read(0.05)) {
61 if (read($sock, my $buffer, 100) == 0) {
66 ok($reached_eof, 'socket connection closed');