From 5b7e6962d72353dddff5b8f24d97aa6d2df69b21 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20Josef=20=C5=A0pa=C4=8Dek?= Date: Thu, 8 Dec 2022 10:29:54 +0100 Subject: [PATCH] Use common Check::Fork|Socket to check ability of fork and socket in system --- perl/Makefile.PL | 3 ++- perl/t/02-unix_domain_socket.t | 36 +++++----------------------------- 2 files changed, 7 insertions(+), 32 deletions(-) diff --git a/perl/Makefile.PL b/perl/Makefile.PL index a389f0c..08dd6b6 100644 --- a/perl/Makefile.PL +++ b/perl/Makefile.PL @@ -138,7 +138,8 @@ WriteMakefile( PM => {'FCGI.pm' => '$(INST_ARCHLIBDIR)/FCGI.pm'}, PREREQ_PM => {'XSLoader' => '0'}, TEST_REQUIRES => { - 'Config' => 0, + 'Check::Fork' => 0.02, + 'Check::Socket' => 0.03, 'FCGI::Client' => 0.09, 'File::Temp' => 0, 'IO::Socket' => 0, diff --git a/perl/t/02-unix_domain_socket.t b/perl/t/02-unix_domain_socket.t index 69d093b..3354da0 100644 --- a/perl/t/02-unix_domain_socket.t +++ b/perl/t/02-unix_domain_socket.t @@ -1,43 +1,17 @@ use strict; use warnings; -use Config; +use Check::Fork qw(check_fork); +use Check::Socket qw(check_socket); use FCGI; use FCGI::Client; use File::Temp qw(tempfile); use IO::Socket; use Test::More 0.88; -my $can_fork = $Config{d_fork} - || ( - ($^O eq 'MSWin32' || $^O eq 'NetWare') - and $Config{useithreads} - and $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ - ); -if ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bSocket\b/) { - plan skip_all => 'Socket extension unavailable'; -} elsif ($ENV{PERL_CORE} and $Config{'extensions'} !~ /\bIO\b/) { - plan skip_all => 'IO extension unavailable'; -} elsif ($^O eq 'os2') { - eval { IO::Socket::pack_sockaddr_un('/foo/bar') || 1 }; - if ($@ !~ /not implemented/) { - plan skip_all => 'compiled without TCP/IP stack v4'; - } -} elsif ($^O =~ m/^(?:qnx|nto|vos)$/ ) { - plan skip_all => "UNIX domain sockets not implemented on $^O"; -} 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" - } - } -} +check_fork() || plan skip_all => $Check::Fork::ERROR_MESSAGE; +check_socket() || plan skip_all => $Check::Socket::ERROR_MESSAGE; +$^O eq 'MSWin32' && plan skip_all => 'FCGI with UNIX domain sockets not implemented on $^O'; my (undef, $unix_socket_file) = tempfile(); my $fcgi_socket = FCGI::OpenSocket($unix_socket_file, 5);