#!/usr/bin/perl -w
use Test::Command tests => 9;
-my $fping_bin = '/opt/fping/sbin/fping';
-my $fping6_bin = '/opt/fping/sbin/fping6';
-#my $fping_bin = '/home/dws/checkouts/fping/src/fping';
-#my $fping6_bin = '/home/dws/checkouts/fping/src/fping6';
# ping 127.0.0.1
-my $cmd1 = Test::Command->new(cmd => "$fping_bin 127.0.0.1");
+my $cmd1 = Test::Command->new(cmd => "fping 127.0.0.1");
$cmd1->exit_is_num(0);
$cmd1->stdout_is_eq("127.0.0.1 is alive\n");
$cmd1->stderr_is_eq("");
# ping ::1
-my $cmd2 = Test::Command->new(cmd => "$fping6_bin ::1");
+my $cmd2 = Test::Command->new(cmd => "fping6 ::1");
$cmd2->exit_is_num(0);
$cmd2->stdout_is_eq("::1 is alive\n");
$cmd2->stderr_is_eq("");
# ping 3 times 127.0.0.1
-my $cmd3 = Test::Command->new(cmd => "$fping_bin -p 100 -C3 127.0.0.1");
+my $cmd3 = Test::Command->new(cmd => "fping -p 100 -C3 127.0.0.1");
$cmd3->exit_is_num(0);
$cmd3->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
--- /dev/null
+#!/usr/bin/perl -w
+
+use Test::Command tests => 9;
+
+# fping -h
+my $cmd1 = Test::Command->new(cmd => "fping -h");
+$cmd1->exit_is_num(0);
+$cmd1->stdout_is_eq(<<END);
+
+Usage: fping [options] [targets...]
+ -a show targets that are alive
+ -A show targets by address
+ -b n amount of ping data to send, in bytes (default 56)
+ -B f set exponential backoff factor to f
+ -c n count of pings to send to each target (default 1)
+ -C n same as -c, report results in verbose format
+ -D print timestamp before each output line
+ -e show elapsed time on return packets
+ -f file read list of targets from a file ( - means stdin) (only if no -g specified)
+ -g generate target list (only if no -f specified)
+ (specify the start and end IP in the target list, or supply a IP netmask)
+ (ex. fping -g 192.168.1.0 192.168.1.255 or fping -g 192.168.1.0/24)
+ -H n Set the IP TTL value (Time To Live hops)
+ -i n interval between sending ping packets (in millisec) (default 25)
+ -l loop sending pings forever
+ -m ping multiple interfaces on target host
+ -n show targets by name (-d is equivalent)
+ -p n interval between ping packets to one target (in millisec)
+ (in looping and counting modes, default 1000)
+ -q quiet (don't show per-target/per-ping results)
+ -Q n same as -q, but show summary every n seconds
+ -r n number of retries (default 3)
+ -s print final stats
+ -I if bind to a particular interface
+ -S addr set source address
+ -t n individual target initial timeout (in millisec) (default 500)
+ -T n ignored (for compatibility with fping 2.4)
+ -u show targets that are unreachable
+ -O n set the type of service (tos) flag on the ICMP packets
+ -v show version
+ targets list of targets to check (if no -f specified)
+
+END
+$cmd1->stderr_is_eq("");
+
+# fping -v
+my $cmd2 = Test::Command->new(cmd => "fping -v");
+$cmd2->exit_is_num(0);
+$cmd2->stdout_like(qr{fping: Version \S+
+fping: comments to david\@schweikert\.ch\n});
+$cmd2->stderr_is_eq("");
+
+# fping with unknown option
+my $cmd3 = Test::Command->new(cmd => "fping -Z");
+$cmd3->exit_is_num(1);
+$cmd3->stdout_is_eq("");
+$cmd3->stderr_is_eq("fping: invalid option -- 'Z'
+see 'fping -h' for usage information\n");