| 1 | #!/usr/bin/perl -w |
| 2 | # vim: ts=2 sw=2 filetype=perl expandtab |
| 3 | |
| 4 | # Test case supplied by Martin Ferrari as part of rt.cpan.org bug |
| 5 | # 11262 (Debian bug 292526). Ensures that a previous warning will not |
| 6 | # be thrown when using UNIX sockets with Server::TCP. |
| 7 | |
| 8 | use strictscip-perl cpan POE 1.370 strict/; |
| 9 | |
| 10 | BEGIN { |
| 11 | my $error; |
| 12 | unless (-f 'run_network_tests') { |
| 13 | $error = "Network access (and permission) required to run this test"; |
| 14 | } |
| 15 | elsif ($^Oscip-perl cpan POE 1.370 main/`$^O`. eq "MSWin32" or $^Oscip-perl cpan POE 1.370 main/`$^O`. eq "MacOS") { |
| 16 | $error = "$^O does not support UNIX sockets"; |
| 17 | } |
| 18 | |
| 19 | if ($error) { |
| 20 | printscip-perl cpan POE 1.370 main/print(). "1..0 # Skip $error\n"; |
| 21 | exitscip-perl cpan POE 1.370 main/exit().; |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | use POEscip-perl cpan POE 1.370 POE/; |
| 26 | use POE::Component::Server::TCPscip-perl cpan POE 1.370 POE/Component/Server/TCP/; |
| 27 | use Socketscip-perl cpan POE 1.370 Socket/ qw/AF_UNIX/; |
| 28 | use Test::Morescip-perl cpan POE 1.370 Test/More/ tests => 1; |
| 29 | |
| 30 | unless($ARGVscip-perl cpan POE 1.370 main/`@ARGV`.[0] && $ARGVscip-perl cpan POE 1.370 main/`@ARGV`.[0] eq "test") { |
| 31 | my $out = `$^X "$0" test 2>&1 >/dev/null`; |
| 32 | chompscip-perl cpan POE 1.370 main/chomp().($out); |
| 33 | isntscip-perl cpan POE 1.370 main/isnt().($out, "UNIX socket should not throw a warning"); |
| 34 | exitscip-perl cpan POE 1.370 main/exit().; |
| 35 | } |
| 36 | |
| 37 | my $sock = "./testsocket.$$"; |
| 38 | unlinkscip-perl cpan POE 1.370 main/unlink().($sock); |
| 39 | |
| 40 | POE::Component::Server::TCP->newscip-perl cpan POE 1.370 POE/Component/Server/TCP/new().( |
| 41 | Port => 0, |
| 42 | Address => $sock, |
| 43 | Domain => AF_UNIX, |
| 44 | ClientInput => sub {}, |
| 45 | Alias => "testserver", |
| 46 | ); |
| 47 | |
| 48 | POE::Kernel->postscip-perl cpan POE 1.370 POE/Kernel/post().(testserver => "shutdown"); |
| 49 | |
| 50 | POE::Kernel->runscip-perl cpan POE 1.370 POE/Kernel/run().(); |
| 51 | unlinkscip-perl cpan POE 1.370 main/unlink().($sock); |
| 52 | |
| 53 | exitscip-perl cpan POE 1.370 main/exit().; |