diff --git a/perl/MANIFEST b/perl/MANIFEST index 591b0b3..1568745 100644 --- a/perl/MANIFEST +++ b/perl/MANIFEST @@ -14,4 +14,5 @@ MANIFEST.SKIP README t/01-load.t t/02-unix_domain_socket.t +t/03-network_socket.t typemap diff --git a/perl/t/02-unix_domain_socket.t b/perl/t/02-unix_domain_socket.t index 69d093b..f94fe20 100644 --- a/perl/t/02-unix_domain_socket.t +++ b/perl/t/02-unix_domain_socket.t @@ -28,15 +28,7 @@ if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) { } elsif (! $can_fork) { plan skip_all => 'no fork'; } elsif ($^O eq 'MSWin32') { - if ($ENV{CONTINUOUS_INTEGRATION}) { - # https://github.com/Perl/perl5/issues/17429 - plan skip_all => 'Skipping on Windows CI'; - } else { - # https://github.com/Perl/perl5/issues/17575 - if (! eval { socket(my $sock, PF_UNIX, SOCK_STREAM, 0) }) { - plan skip_all => "AF_UNIX unavailable or disabled on this platform" - } - } + plan skip_all => "FCGI with UNIX domain sockets not implemented on $^O"; } my (undef, $unix_socket_file) = tempfile(); diff --git a/perl/t/03-network_socket.t b/perl/t/03-network_socket.t new file mode 100644 index 0000000..caa4402 --- /dev/null +++ b/perl/t/03-network_socket.t @@ -0,0 +1,59 @@ +#!/usr/bin/env perl + +use strict; +use warnings; + +use FCGI; +use FCGI::Client; +use IO::Socket::IP; +use Test::More 'tests' => 4; + +my $port = 8888; + +# Client +if (my $pid = fork()) { + my $right_ret = <<'END'; +Content-Type: text/plain + +END + + my ($stdout, $stderr) = client_request($port); + is($stdout, $right_ret."0\n", 'Test first round on stdout.'); + is($stderr, undef, 'Test first round on stderr.'); + + ($stdout, $stderr) = client_request($port); + is($stdout, $right_ret."1\n", 'Test second round on stdout.'); + is($stderr, undef, 'Test second round on stderr.'); + +# Server +} elsif (defined $pid) { + my $fcgi_socket = FCGI::OpenSocket(':'.$port, 5); + my $request = FCGI::Request(\*STDIN, \*STDOUT, \*STDERR, \%ENV, $fcgi_socket); + + # Only two cycles. + my $count = 0; + while ($count < 2 && $request->Accept() >= 0) { + print "Content-Type: text/plain\n\n"; + print $count++."\n"; + } + exit; + +} else { + die $!; +} + +sub client_request { + my $port = shift; + + my $sock = IO::Socket::IP->new( + PeerAddr => '127.0.0.1', + PeerPort => $port, + ) or die $!; + + my $client = FCGI::Client::Connection->new(sock => $sock); + my ($stdout, $stderr) = $client->request({ + REQUEST_METHOD => 'GET', + }, ''); + + return ($stdout, $stderr); +}