Net/Prober/tcp.pm

filter: Statementstmt 88.8% 32 / 36 Branchbran 50.0% 4 / 8 Conditioncond 37.5% 3 / 8 MC/DCmcdc 20.0% 1 / 5 Subroutinesub 100% 6 / 6 Podpod 0.0% 0 / 1 totaltotal 71.8% 46 / 64 CC 8 SCAR 19.9
CC
8
Cov
75%
probe
11.3
BEGIN
1.0
BEGIN
1.0
CRAP 7.3
« Test/Net/Prober/HTTPServer.pm ↑ Summary Net/Prober/ssh.pm »
1 package Net::Prober::tcp;
2 1 $Net::Prober::tcp::VERSION = '0.16';
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'Net::Prober::Probe::TCP';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 ▶use Carp ();
Subroutine BEGIN: called CC=1 SCAR=0.0
8 1 ▶use Net::Prober ();
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub probe {
11 2 ▶ my ($self, $args) = @_;
Subroutine probe: called CC=8 SCAR=24.2
Pod undocumented
12  
13 2 my ($host, $port, $timeout, $proto) =
14 $self->parse_args($args, qw(host port timeout proto));
15  
16 2 $port = Net::Prober::port_name_to_num($port);
17  
18 2 ▶ if (! defined $port or $port == 0) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $port or $port == 0) 1 1 2
Condition66%2/3
not defined $port or $port == 0
l!l&&r!l&&!r
101
MC/DC50%1/2
not defined $port or $port == 0
not defined $port $port == 0
Truth table66%2/3
not(A) or B
A= not defined $portB= $port == 0
ABresult
1X1
011
000
19 1 Carp::croak("Can't probe: undefined port");
20 }
21  
22 1 ▶ $timeout ||= 3.5;
Condition50%1/2
$timeout ||= "3.5"
l!l
10
MC/DC0%0/1
$timeout ||= "3.5"
$timeout
Truth table50%1/2
A
A= $timeout
Aresult
11
00
23  
24 1 my $t0 = $self->time_now();
25  
26 1 my $sock = $self->open_socket($args);
27 1 my $good = 0;
28 1 my $reason;
29  
30 1 ▶ if (! $sock) {
Branch: 1 branch
BranchTrueFalseTotal
if (not $sock) { } 1 0 1
31 1 $reason = "Socket open failed";
32 }
33 else {
34 0 ▶ $good = $sock->connected() && $sock->close();
Condition0%0/3
$sock->connected && $sock->close
!ll&&!rl&&r
000
MC/DC0%0/2
$sock->connected && $sock->close
$sock->connected $sock->close
Truth table0%0/3
A && B
A= $sock->connectedB= $sock->close
ABresult
0X0
100
111
35 0 ▶ if (! $good) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($good) 0 0 0
36 0 $reason = "Socket connect or close failed";
37 }
38 }
39  
40 1 my $elapsed = $self->time_elapsed();
41  
42 1 ▶ if ($good) {
Branch: 1 branch
BranchTrueFalseTotal
if ($good) 0 1 1
43 0 return $self->probe_ok(
44 time => $elapsed,
45 host => $host,
46 port => $port,
47 );
48 }
49  
50 1 return $self->probe_failed(
51 time => $elapsed,
52 host => $host,
53 port => $port,
54 reason => $reason,
55 );
56  
57 }
58  
59 1 1;
60  
61 __END__
« Test/Net/Prober/HTTPServer.pm ↑ Summary Net/Prober/ssh.pm »