| 1 | package Check::Socket; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use base qw(Exporter); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 5 | ▶ | use Readonly; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | use Socket; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 5 | our $ERROR_MESSAGE; | |||||||||||||||||||||||||||
| 12 | 5 | Readonly::Array our @EXPORT_OK => qw(check_socket $ERROR_MESSAGE); | |||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||
| 14 | 5 | our $VERSION = 0.04; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | 6 | ▶ | sub check_socket { | ||||||||||||||||||||||||||
|
Subroutine
check_socket: called CC=15 SCAR=36.6
Pod
documented
| |||||||||||||||||||||||||||||
| 17 | 6 | my ($config_hr, $os, $env_hr) = @_; | |||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 6 | ▶ | $config_hr ||= \%Config; | ||||||||||||||||||||||||||
|
Condition100%2/2
$config_hr ||= \%Check::Socket::Config
MC/DC100%1/1
$config_hr ||= \%Check::Socket::Config
$config_hr
Truth table100%2/2
A
A= $config_hr
| |||||||||||||||||||||||||||||
| 20 | 6 | ▶ | $os ||= $^O; | ||||||||||||||||||||||||||
|
Condition66%2/3
$os ||= $^O
MC/DC0%0/2
$os ||= $^O
$os
$^O
Truth table66%2/3
A ||= B
A= $osB= $^O
| |||||||||||||||||||||||||||||
| 21 | 6 | ▶ | $env_hr ||= \%ENV; | ||||||||||||||||||||||||||
|
Condition100%2/2
$env_hr ||= \%ENV
MC/DC100%1/1
$env_hr ||= \%ENV
$env_hr
Truth table100%2/2
A
A= $env_hr
| |||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 6 | ▶ | if ($env_hr->{PERL_CORE} and $config_hr->{'extensions'} !~ /\bSocket\b/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$env_hr->{"PERL_CORE"} and not $config_hr->{"extensions"} =~ /\bSocket\b/
MC/DC0%0/2
$env_hr->{"PERL_CORE"} and not $config_hr->{"extensions"} =~ /\bSocket\b/
$env_hr->{"PERL_CORE"}
not $config_hr->{"extensions"} =~ /\bSocket\b/
Truth table33%1/3
A and not(B)
A= $env_hr->{"PERL_CORE"}B= not $config_hr->{"extensions"} =~ /\bSocket\b/
| |||||||||||||||||||||||||||||
| 24 | 0 | $ERROR_MESSAGE = 'Socket extension unavailable.'; | |||||||||||||||||||||||||||
| 25 | 0 | return 0; | |||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 6 | ▶ | if ($env_hr->{PERL_CORE} and $config_hr->{'extensions'} !~ /\bIO\b/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$env_hr->{"PERL_CORE"} and not $config_hr->{"extensions"} =~ /\bIO\b/
MC/DC0%0/2
$env_hr->{"PERL_CORE"} and not $config_hr->{"extensions"} =~ /\bIO\b/
$env_hr->{"PERL_CORE"}
not $config_hr->{"extensions"} =~ /\bIO\b/
Truth table33%1/3
A and not(B)
A= $env_hr->{"PERL_CORE"}B= not $config_hr->{"extensions"} =~ /\bIO\b/
| |||||||||||||||||||||||||||||
| 29 | 0 | $ERROR_MESSAGE = 'IO extension unavailable.'; | |||||||||||||||||||||||||||
| 30 | 0 | return 0; | |||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 6 | ▶ | if ($os eq 'os2') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | 0 | ▶ | eval { IO::Socket::pack_sockaddr_un('/foo/bar') || 1 }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ($@ =~ /not implemented/) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | $ERROR_MESSAGE = "$os: Compiled without TCP/IP stack v4."; | |||||||||||||||||||||||||||
| 37 | 0 | return 0; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 6 | ▶ | if ($os =~ m/^(?:qnx|nto|vos)$/ ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 3 | $ERROR_MESSAGE = "$os: UNIX domain sockets not implemented."; | |||||||||||||||||||||||||||
| 43 | 3 | return 0; | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | 3 | ▶ | if ($os eq 'MSWin32') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 47 | 1 | ▶ | if ($env_hr->{CONTINUOUS_INTEGRATION}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 48 | # https://github.com/Perl/perl5/issues/17429 | ||||||||||||||||||||||||||||
| 49 | 1 | $ERROR_MESSAGE = "$os: Skip sockets on CI."; | |||||||||||||||||||||||||||
| 50 | 1 | return 0; | |||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | # https://github.com/Perl/perl5/issues/17575 | ||||||||||||||||||||||||||||
| 54 | 0 | ▶ | if (! eval { socket(my $sock, PF_UNIX, SOCK_STREAM, 0) }) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 55 | 0 | $ERROR_MESSAGE = "$os: AF_UNIX unavailable or disabled."; | |||||||||||||||||||||||||||
| 56 | 0 | return 0; | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 2 | return 1; | |||||||||||||||||||||||||||
| 61 | } | ||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||
| 63 | 5 | 1; | |||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | __END__ | ||||||||||||||||||||||||||||