Release 3.10
commit
e042466b9a
@ -0,0 +1,24 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 6;
|
||||||
|
|
||||||
|
# -u show targets that are unreachable
|
||||||
|
# -v show version
|
||||||
|
|
||||||
|
# fping -u
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -r0 -u 8.8.0.0 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(1);
|
||||||
|
$cmd->stdout_is_eq("8.8.0.0\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -v
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -v");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_like(qr{ping: Version 3\.\d+
|
||||||
|
fping: comments to david\@schweikert\.ch
|
||||||
|
});
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 6;
|
||||||
|
|
||||||
|
# run without privileges
|
||||||
|
my $fping_bin = `which fping`; chomp $fping_bin;
|
||||||
|
my $fping6_bin = `which fping6`; chomp $fping6_bin;
|
||||||
|
system("cp $fping_bin /tmp/fping.copy; chmod +x /tmp/fping.copy");
|
||||||
|
system("cp $fping6_bin /tmp/fping6.copy; chmod +x /tmp/fping6.copy");
|
||||||
|
|
||||||
|
# fping
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "/tmp/fping.copy 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(4);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_like(qr{\(null\): can't create socket \(must run as root\?\) : .*\n});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping6
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "/tmp/fping6.copy ::1");
|
||||||
|
$cmd->exit_is_num(4);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_like(qr{\(null\): can't create raw socket \(must run as root\?\) : .*\n});
|
||||||
|
}
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 36;
|
||||||
|
|
||||||
|
for my $arg (qw(i b B c C H i O p Q r t)) {
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -$arg xxx");
|
||||||
|
$cmd->exit_is_num(1);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_like(qr{Usage:});
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 6;
|
||||||
|
|
||||||
|
# fping
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping nosuchname.example.com");
|
||||||
|
$cmd->exit_is_num(1);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_is_eq("nosuchname.example.com address not found\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping6
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping6 nosuchname.example.com");
|
||||||
|
$cmd->exit_is_num(1);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_is_eq("nosuchname.example.com: Name or service not known\n");
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 3;
|
||||||
|
|
||||||
|
# fping
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -q -i 10 -p 20 -c 3 -t200 8.8.8.8 4.2.2.5 www.france-telecom.fr www.google.com");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_like(qr{8\.8\.8\.8\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
|
||||||
|
4\.2\.2\.5\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
|
||||||
|
www\.france-telecom\.fr\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
|
||||||
|
www\.google\.com\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = \d+\.\d+/\d+\.\d+/\d+\.\d+
|
||||||
|
});
|
||||||
|
}
|
@ -0,0 +1,60 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 12;
|
||||||
|
|
||||||
|
# -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
|
||||||
|
|
||||||
|
# fping -c n
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -c 2 -p 100 localhost 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
|
||||||
|
127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
|
||||||
|
localhost : \[1\], 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\)
|
||||||
|
});
|
||||||
|
|
||||||
|
$cmd->stderr_like(qr{localhost : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
|
||||||
|
127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -C n
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -C 2 -p 100 localhost 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
|
||||||
|
127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
|
||||||
|
localhost : \[1\], 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\)
|
||||||
|
});
|
||||||
|
|
||||||
|
$cmd->stderr_like(qr{localhost : 0\.\d+ 0\.\d+
|
||||||
|
127\.0\.0\.1 : 0\.\d+ 0\.\d+
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -D
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -D -c 2 -p 100 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_like(qr{\[\d{10}\.\d+\] 127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
|
||||||
|
\[\d{10}\.\d+\] 127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
|
||||||
|
});
|
||||||
|
|
||||||
|
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -e
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -e 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_like(qr{127\.0\.0\.1 is alive \(0\.\d+ ms\)
|
||||||
|
});
|
||||||
|
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 18;
|
||||||
|
use File::Temp;
|
||||||
|
|
||||||
|
# -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. ../src/fping -g 192.168.1.0 192.168.1.255 or ../src/fping -g 192.168.1.0/24)
|
||||||
|
# -H n Set the IP TTL value (Time To Live hops)
|
||||||
|
|
||||||
|
my $tmpfile = File::Temp->new();
|
||||||
|
print $tmpfile "127.0.0.1\n127.0.0.2\n";
|
||||||
|
close($tmpfile);
|
||||||
|
|
||||||
|
# fping without option (-> equivalent to 'fping -f -')
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "cat ".$tmpfile->filename." | fping");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -f -
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "cat ".$tmpfile->filename." | fping -f -");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -f file
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -f ".$tmpfile->filename);
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -g (range)
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -g 127.0.0.1 127.0.0.5");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n127.0.0.3 is alive\n127.0.0.4 is alive\n127.0.0.5 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -g (cidr)
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -g 127.0.0.1/30");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -H
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -H 1 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 7;
|
||||||
|
|
||||||
|
# -i n interval between sending ping packets (in millisec) (default 25)
|
||||||
|
# -l loop sending pings forever
|
||||||
|
# -m ping multiple interfaces on target host
|
||||||
|
|
||||||
|
# fping -i n
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -i 100 127.0.0.1 127.0.0.2");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -l
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
|
||||||
|
$cmd->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\)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -m
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -m google-public-dns-a.google.com");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 12;
|
||||||
|
|
||||||
|
# -n show targets by name (-d is equivalent)
|
||||||
|
# -O n set the type of service (tos) flag on the ICMP packets
|
||||||
|
# -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
|
||||||
|
|
||||||
|
# fping -n
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -n 8.8.8.8");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -O
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -O 2 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -q
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -q -p 100 -c 3 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -Q
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 400 -c 4 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("");
|
||||||
|
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
|
||||||
|
127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
|
||||||
|
127\.0\.0\.1 : xmt/rcv/%loss = 4/4/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
use Test::Command tests => 12;
|
||||||
|
|
||||||
|
# -r n number of retries (default 3)
|
||||||
|
# -s print final stats
|
||||||
|
# -S addr set source address
|
||||||
|
# -t n individual target initial timeout (in millisec) (default 500)
|
||||||
|
# -T n ignored (for compatibility with fping 2.4)
|
||||||
|
|
||||||
|
# fping -r tested in test-4-options-a-b.pl
|
||||||
|
|
||||||
|
# fping -s
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -s 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
|
||||||
|
$cmd->stderr_like(qr{\s*
|
||||||
|
\s*1 targets
|
||||||
|
\s*1 alive
|
||||||
|
\s*0 unreachable
|
||||||
|
\s*0 unknown addresses
|
||||||
|
\s*
|
||||||
|
\s*0 timeouts \(waiting for response\)
|
||||||
|
\s*1 ICMP Echos sent
|
||||||
|
\s*1 ICMP Echo Replies received
|
||||||
|
\s*0 other ICMP received
|
||||||
|
|
||||||
|
\s*0.\d+ ms \(min round trip time\)
|
||||||
|
\s*0.\d+ ms \(avg round trip time\)
|
||||||
|
\s*0.\d+ ms \(max round trip time\)
|
||||||
|
\s*0.\d+ sec \(elapsed real time\)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -s (no host reachable)
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -r0 -t100 -s 8.8.0.0");
|
||||||
|
$cmd->exit_is_num(1);
|
||||||
|
$cmd->stdout_is_eq("8.8.0.0 is unreachable\n");
|
||||||
|
$cmd->stderr_like(qr{\s*
|
||||||
|
\s*1 targets
|
||||||
|
\s*0 alive
|
||||||
|
\s*1 unreachable
|
||||||
|
\s*0 unknown addresses
|
||||||
|
\s*
|
||||||
|
\s*1 timeouts \(waiting for response\)
|
||||||
|
\s*1 ICMP Echos sent
|
||||||
|
\s*0 ICMP Echo Replies received
|
||||||
|
\s*0 other ICMP received
|
||||||
|
|
||||||
|
\s*0.\d+ ms \(min round trip time\)
|
||||||
|
\s*0.\d+ ms \(avg round trip time\)
|
||||||
|
\s*0.\d+ ms \(max round trip time\)
|
||||||
|
\s*0.\d+ sec \(elapsed real time\)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -S
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping -S 127.0.0.1 127.0.0.1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("127.0.0.1 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping6 -S
|
||||||
|
{
|
||||||
|
my $cmd = Test::Command->new(cmd => "fping6 -S ::1 ::1");
|
||||||
|
$cmd->exit_is_num(0);
|
||||||
|
$cmd->stdout_is_eq("::1 is alive\n");
|
||||||
|
$cmd->stderr_is_eq("");
|
||||||
|
}
|
||||||
|
|
||||||
|
# fping -t tested in test-4-options-a-b.pl
|
@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/perl -w
|
||||||
|
|
||||||
|
# regression testing for github issue #58
|
||||||
|
|
||||||
|
use Test::Command tests => 3;
|
||||||
|
|
||||||
|
my $cmd1 = Test::Command->new(cmd => "fping -a -g 2001:db8:120:4161::4/64");
|
||||||
|
$cmd1->exit_is_num(1);
|
||||||
|
$cmd1->stdout_is_eq("");
|
||||||
|
$cmd1->stderr_is_eq("Error: -g works only with IPv4 addresses\n");
|
Loading…
Reference in New Issue