| 1 |
#!/usr/bin/perl -w |
| 2 |
|
| 3 |
use Test::Command tests => 12; |
| 4 |
|
| 5 |
# -c n count of pings to send to each target (default 1) |
| 6 |
# -C n same as -c, report results in verbose format |
| 7 |
# -D print timestamp before each output line |
| 8 |
# -e show elapsed time on return packets |
| 9 |
|
| 10 |
# fping -c n |
| 11 |
{ |
| 12 |
my $cmd = Test::Command->new(cmd => "fping -4 -c 2 -p 100 localhost 127.0.0.1"); |
| 13 |
$cmd->exit_is_num(0); |
| 14 |
$cmd->stdout_like(qr{localhost : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 15 |
127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 16 |
localhost : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 17 |
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 18 |
}); |
| 19 |
|
| 20 |
$cmd->stderr_like(qr{localhost : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+ |
| 21 |
127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+ |
| 22 |
}); |
| 23 |
} |
| 24 |
|
| 25 |
# fping -C n |
| 26 |
{ |
| 27 |
my $cmd = Test::Command->new(cmd => "fping -4 -C 2 -p 100 localhost 127.0.0.1"); |
| 28 |
$cmd->exit_is_num(0); |
| 29 |
$cmd->stdout_like(qr{localhost : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 30 |
127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 31 |
localhost : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 32 |
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 33 |
}); |
| 34 |
|
| 35 |
$cmd->stderr_like(qr{localhost : \d\.\d+ \d\.\d+ |
| 36 |
127\.0\.0\.1 : \d\.\d+ \d\.\d+ |
| 37 |
}); |
| 38 |
} |
| 39 |
|
| 40 |
# fping -D |
| 41 |
{ |
| 42 |
my $cmd = Test::Command->new(cmd => "fping -D -c 2 -p 100 127.0.0.1"); |
| 43 |
$cmd->exit_is_num(0); |
| 44 |
$cmd->stdout_like(qr{\[\d+\.\d+\] 127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 45 |
\[\d+\.\d+\] 127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) |
| 46 |
}); |
| 47 |
|
| 48 |
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+ |
| 49 |
}); |
| 50 |
} |
| 51 |
|
| 52 |
# fping -e |
| 53 |
{ |
| 54 |
my $cmd = Test::Command->new(cmd => "fping -e 127.0.0.1"); |
| 55 |
$cmd->exit_is_num(0); |
| 56 |
$cmd->stdout_like(qr{127\.0\.0\.1 is alive \(\d\.\d+ ms\) |
| 57 |
}); |
| 58 |
|
| 59 |
$cmd->stderr_is_eq(""); |
| 60 |
} |