| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use Test::Command tests => 21; |
| 4 |
use Test::More; |
| 5 |
|
| 6 |
# -R random bytes |
| 7 |
# -r n number of retries (default 3) |
| 8 |
# -s print final stats |
| 9 |
# -S addr set source address |
| 10 |
# -t n individual target initial timeout (in millisec) (default 500) |
| 11 |
# -T n ignored (for compatibility with fping 2.4) |
| 12 |
|
| 13 |
# fping -R |
| 14 |
{ |
| 15 |
my $cmd = Test::Command->new(cmd => "fping -q -R -c3 -p100 127.0.0.1"); |
| 16 |
$cmd->exit_is_num(0); |
| 17 |
$cmd->stdout_is_eq(""); |
| 18 |
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%.*}); |
| 19 |
} |
| 20 |
|
| 21 |
SKIP: { |
| 22 |
if($ENV{SKIP_IPV6}) { |
| 23 |
skip 'Skip IPv6 tests', 3; |
| 24 |
} |
| 25 |
my $cmd = Test::Command->new(cmd => "fping -q -R -c3 -p100 ::1"); |
| 26 |
$cmd->exit_is_num(0); |
| 27 |
$cmd->stdout_is_eq(""); |
| 28 |
$cmd->stderr_like(qr{::1 : xmt/rcv/%loss = 3/3/0%.*}); |
| 29 |
} |
| 30 |
|
| 31 |
# fping -r tested in test-4-options-a-b.pl |
| 32 |
|
| 33 |
# fping -s |
| 34 |
{ |
| 35 |
my $cmd = Test::Command->new(cmd => "fping -s 127.0.0.1"); |
| 36 |
$cmd->exit_is_num(0); |
| 37 |
$cmd->stdout_is_eq("127.0.0.1 is alive\n"); |
| 38 |
$cmd->stderr_like(qr{\s* |
| 39 |
\s*1 targets |
| 40 |
\s*1 alive |
| 41 |
\s*0 unreachable |
| 42 |
\s*0 unknown addresses |
| 43 |
\s* |
| 44 |
\s*0 timeouts \(waiting for response\) |
| 45 |
\s*1 ICMP Echos sent |
| 46 |
\s*1 ICMP Echo Replies received |
| 47 |
\s*0 other ICMP received |
| 48 |
|
| 49 |
\s*\d\.\d+ ms \(min round trip time\) |
| 50 |
\s*\d\.\d+ ms \(avg round trip time\) |
| 51 |
\s*\d\.\d+ ms \(max round trip time\) |
| 52 |
\s*\d\.\d+ sec \(elapsed real time\) |
| 53 |
}); |
| 54 |
} |
| 55 |
|
| 56 |
# fping -s (no host reachable) |
| 57 |
{ |
| 58 |
my $cmd = Test::Command->new(cmd => "fping -r0 -t100 -s 8.8.0.0"); |
| 59 |
$cmd->exit_is_num(1); |
| 60 |
$cmd->stdout_is_eq("8.8.0.0 is unreachable\n"); |
| 61 |
$cmd->stderr_like(qr{\s* |
| 62 |
\s*1 targets |
| 63 |
\s*0 alive |
| 64 |
\s*1 unreachable |
| 65 |
\s*0 unknown addresses |
| 66 |
\s* |
| 67 |
\s*1 timeouts \(waiting for response\) |
| 68 |
\s*1 ICMP Echos sent |
| 69 |
\s*0 ICMP Echo Replies received |
| 70 |
\s*0 other ICMP received |
| 71 |
|
| 72 |
\s*\d\.\d+ ms \(min round trip time\) |
| 73 |
\s*\d\.\d+ ms \(avg round trip time\) |
| 74 |
\s*\d\.\d+ ms \(max round trip time\) |
| 75 |
\s*\d\.\d+ sec \(elapsed real time\) |
| 76 |
}); |
| 77 |
} |
| 78 |
|
| 79 |
# fping -S |
| 80 |
{ |
| 81 |
my $cmd = Test::Command->new(cmd => "fping -S 127.0.0.1 127.0.0.1"); |
| 82 |
$cmd->exit_is_num(0); |
| 83 |
$cmd->stdout_is_eq("127.0.0.1 is alive\n"); |
| 84 |
$cmd->stderr_is_eq(""); |
| 85 |
} |
| 86 |
|
| 87 |
# fping -S |
| 88 |
SKIP: { |
| 89 |
if($ENV{SKIP_IPV6}) { |
| 90 |
skip 'Skip IPv6 tests', 3; |
| 91 |
} |
| 92 |
my $cmd = Test::Command->new(cmd => "fping -S ::1 ::1"); |
| 93 |
$cmd->exit_is_num(0); |
| 94 |
$cmd->stdout_is_eq("::1 is alive\n"); |
| 95 |
$cmd->stderr_is_eq(""); |
| 96 |
} |
| 97 |
|
| 98 |
# fping -S |
| 99 |
{ |
| 100 |
my $cmd = Test::Command->new(cmd => "fping -S bla"); |
| 101 |
$cmd->exit_is_num(1); |
| 102 |
$cmd->stdout_is_eq(""); |
| 103 |
$cmd->stderr_is_eq("fping: can't parse source address: bla\n"); |
| 104 |
} |
| 105 |
|
| 106 |
# (note: fping -t also tested in test-4-options-a-b.pl) |