line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Test::Ping; |
2
|
|
|
|
|
|
|
|
3
|
15
|
|
|
15
|
|
376645
|
use strict; |
|
15
|
|
|
|
|
36
|
|
|
15
|
|
|
|
|
569
|
|
4
|
15
|
|
|
15
|
|
84
|
use warnings; |
|
15
|
|
|
|
|
33
|
|
|
15
|
|
|
|
|
440
|
|
5
|
|
|
|
|
|
|
|
6
|
15
|
|
|
15
|
|
10176
|
use Test::Ping::Ties::BIND; |
|
15
|
|
|
|
|
55
|
|
|
15
|
|
|
|
|
647
|
|
7
|
15
|
|
|
15
|
|
9292
|
use Test::Ping::Ties::PORT; |
|
15
|
|
|
|
|
40
|
|
|
15
|
|
|
|
|
376
|
|
8
|
15
|
|
|
15
|
|
8513
|
use Test::Ping::Ties::PROTO; |
|
15
|
|
|
|
|
35
|
|
|
15
|
|
|
|
|
364
|
|
9
|
15
|
|
|
15
|
|
12725
|
use Test::Ping::Ties::HIRES; |
|
15
|
|
|
|
|
36
|
|
|
15
|
|
|
|
|
423
|
|
10
|
15
|
|
|
15
|
|
9517
|
use Test::Ping::Ties::TIMEOUT; |
|
15
|
|
|
|
|
47
|
|
|
15
|
|
|
|
|
403
|
|
11
|
15
|
|
|
15
|
|
8560
|
use Test::Ping::Ties::SOURCE_VERIFY; |
|
15
|
|
|
|
|
37
|
|
|
15
|
|
|
|
|
391
|
|
12
|
15
|
|
|
15
|
|
8863
|
use Test::Ping::Ties::SERVICE_CHECK; |
|
15
|
|
|
|
|
39
|
|
|
15
|
|
|
|
|
2471
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
my $CLASS = __PACKAGE__; |
15
|
|
|
|
|
|
|
my $OBJPATH = __PACKAGE__->builder->{'_net-ping_object'}; |
16
|
|
|
|
|
|
|
my $method_ignore = '__NONE'; |
17
|
|
|
|
|
|
|
our $VERSION = '0.17'; |
18
|
|
|
|
|
|
|
our @EXPORT = qw( |
19
|
|
|
|
|
|
|
ping_ok |
20
|
|
|
|
|
|
|
ping_not_ok |
21
|
|
|
|
|
|
|
create_ping_object_ok |
22
|
|
|
|
|
|
|
create_ping_object_not_ok |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
# Net::Ping variables |
26
|
|
|
|
|
|
|
our $PORT; |
27
|
|
|
|
|
|
|
our $BIND; |
28
|
|
|
|
|
|
|
our $PROTO; |
29
|
|
|
|
|
|
|
our $HIRES; |
30
|
|
|
|
|
|
|
our $TIMEOUT; |
31
|
|
|
|
|
|
|
our $SOURCE_VERIFY; |
32
|
|
|
|
|
|
|
our $SERVICE_CHECK; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
BEGIN { |
35
|
15
|
|
|
15
|
|
96
|
use base 'Test::Builder::Module'; |
|
15
|
|
|
|
|
34
|
|
|
15
|
|
|
|
|
1828
|
|
36
|
15
|
|
|
15
|
|
86
|
use Net::Ping; |
|
15
|
|
|
|
|
30
|
|
|
15
|
|
|
|
|
2187
|
|
37
|
|
|
|
|
|
|
|
38
|
15
|
|
|
15
|
|
106
|
__PACKAGE__->builder->{'_net-ping_object'} = Net::Ping->new($PROTO); |
39
|
|
|
|
|
|
|
|
40
|
15
|
|
|
|
|
25426
|
tie $PORT, 'Test::Ping::Ties::PORT'; |
41
|
15
|
|
|
|
|
104
|
tie $BIND, 'Test::Ping::Ties::BIND'; |
42
|
15
|
|
|
|
|
104
|
tie $PROTO, 'Test::Ping::Ties::PROTO'; |
43
|
15
|
|
|
|
|
86
|
tie $HIRES, 'Test::Ping::Ties::HIRES'; |
44
|
15
|
|
|
|
|
89
|
tie $TIMEOUT, 'Test::Ping::Ties::TIMEOUT'; |
45
|
15
|
|
|
|
|
87
|
tie $SOURCE_VERIFY, 'Test::Ping::Ties::SOURCE_VERIFY'; |
46
|
15
|
|
|
|
|
132
|
tie $SERVICE_CHECK, 'Test::Ping::Ties::SERVICE_CHECK'; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub ping_ok { |
50
|
36
|
|
|
36
|
1
|
5869
|
my ( $host, $name ) = @_; |
51
|
36
|
|
|
|
|
212
|
my $tb = $CLASS->builder; |
52
|
36
|
|
|
|
|
402
|
my $pinger = $OBJPATH; |
53
|
|
|
|
|
|
|
|
54
|
36
|
|
|
|
|
285
|
my ( $ret, $duration ) = $pinger->ping( $host, $TIMEOUT ); |
55
|
36
|
|
|
|
|
10654536
|
$tb->ok( $ret, $name ); |
56
|
|
|
|
|
|
|
|
57
|
36
|
|
|
|
|
25979
|
return ( $ret, $duration ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub ping_not_ok { |
61
|
3
|
|
|
3
|
1
|
16
|
my ( $host, $name ) = @_; |
62
|
3
|
|
|
|
|
27
|
my $tb = $CLASS->builder; |
63
|
3
|
|
|
|
|
37
|
my $pinger = $OBJPATH; |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
17
|
my $alive = $pinger->ping( $host, $TIMEOUT ); |
66
|
3
|
|
|
|
|
14013396
|
$tb->ok( !$alive, $name ); |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
3219
|
return 1; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub create_ping_object_ok { |
72
|
16
|
|
|
16
|
1
|
50261
|
my @args = @_; |
73
|
16
|
|
50
|
|
|
84
|
my $name = pop @args || q{}; |
74
|
16
|
|
|
|
|
136
|
my $tb = $CLASS->builder; |
75
|
16
|
|
|
|
|
308
|
$OBJPATH = Net::Ping->new(@args); |
76
|
|
|
|
|
|
|
|
77
|
16
|
50
|
|
|
|
8083
|
if ($OBJPATH) { |
78
|
16
|
|
|
|
|
387
|
$tb->is_eq( ref $OBJPATH, 'Net::Ping', $name ); |
79
|
|
|
|
|
|
|
} else { |
80
|
0
|
|
|
|
|
0
|
$tb->ok( 0, $name ); |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub create_ping_object_not_ok { |
85
|
0
|
|
|
0
|
1
|
0
|
my @args = @_; |
86
|
0
|
|
0
|
|
|
0
|
my $name = pop @args || q{}; |
87
|
0
|
|
|
|
|
0
|
my $tb = $CLASS->builder; |
88
|
0
|
|
|
|
|
0
|
$OBJPATH = Net::Ping->new(@args); |
89
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
0
|
$tb->ok( !$OBJPATH, $name ); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
sub _has_var_ok { |
94
|
6
|
|
|
6
|
|
38
|
my ( $var_name, $var_value, $name ) = @_; |
95
|
6
|
|
|
|
|
33
|
my $tb = $CLASS->builder; |
96
|
6
|
|
|
|
|
77
|
$tb->is_eq( $OBJPATH->{$var_name}, $var_value, $name ); ## no critic |
97
|
6
|
|
|
|
|
3835
|
return 1; |
98
|
|
|
|
|
|
|
} |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub _ping_object { |
101
|
115
|
|
50
|
115
|
|
19853065
|
my $obj = $_[1] || $_[0] || q{}; |
102
|
|
|
|
|
|
|
|
103
|
115
|
50
|
|
|
|
408
|
if ( ref $obj eq 'Net::Ping' ) { |
104
|
0
|
|
|
|
|
0
|
$OBJPATH = $obj; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
115
|
|
|
|
|
650
|
return $OBJPATH; |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
15
|
|
|
15
|
|
19219
|
END { $OBJPATH->close(); } |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
1; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
__END__ |