File: ferrari-server-unix.t

package info (click to toggle)
libpoe-perl 2%3A1.3670-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,996 kB
  • ctags: 1,416
  • sloc: perl: 22,865; makefile: 9
file content (53 lines) | stat: -rw-r--r-- 1,130 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/perl -w
# vim: ts=2 sw=2 filetype=perl expandtab

# Test case supplied by Martin Ferrari as part of rt.cpan.org bug
# 11262 (Debian bug 292526).  Ensures that a previous warning will not
# be thrown when using UNIX sockets with Server::TCP.

use strict;

BEGIN {
  my $error;
  unless (-f 'run_network_tests') {
    $error = "Network access (and permission) required to run this test";
  }
  elsif ($^O eq "MSWin32" or $^O eq "MacOS") {
    $error = "$^O does not support UNIX sockets";
  }

  if ($error) {
    print "1..0 # Skip $error\n";
    exit;
  }
}

use POE;
use POE::Component::Server::TCP;
use Socket qw/AF_UNIX/;
use Test::More tests => 1;

unless($ARGV[0] && $ARGV[0] eq "test") {
  my $out = `$^X "$0" test 2>&1 >/dev/null`;
  chomp($out);
  isnt($out, "UNIX socket should not throw a warning");
  exit;
}

my $sock = "./testsocket.$$";
unlink($sock);

POE::Component::Server::TCP->new(
  Port        => 0,
  Address     => $sock,
  Domain      => AF_UNIX,
  ClientInput => sub {},
  Alias       => "testserver",
);

POE::Kernel->post(testserver => "shutdown");

POE::Kernel->run();
unlink($sock);

exit;