sudo setcap cap_net_raw,cap_net_admin+ep src/fping
-if [[ ! $PATH =~ fping/src ]]; then
- PATH=/home/dws/checkouts/fping/src:$PATH
+if [ -d "$PWD/src" ]; then
+ if [[ ":$PATH:" != *":$PWD/src:"* ]]; then
+ PATH="$PWD/src:$PATH"
+ fi
fi
ff02::1 : xmt/rcv/%loss = 1/1/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+\n});
}
-# fping --icmp-timestamp -c n 127.0.0.1
+# fping --icmp-timestamp -c 2 127.0.0.1
SKIP: {
if($^O eq 'darwin') {
skip 'On macOS, this test is unreliable', 3;
}
-my $cmd = Test::Command->new(cmd => "fping -4 --icmp-timestamp -c 2 127.0.0.1");
+my $cmd = Test::Command->new(cmd => "fping -4 -p 100 --icmp-timestamp -c 2 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
127\.0\.0\.1 : \[1\], 20 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\), timestamps: Originate=\d+ Receive=\d+ Transmit=\d+ Localreceive=\d+
if($ENV{SKIP_IPV6}) {
skip 'Skip IPv6 tests', 3;
}
- my $cmd = Test::Command->new(cmd => "fping --check-source ff02::1");
+ my $cmd = Test::Command->new(cmd => "fping -r1 -t100 --check-source ff02::1");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("ff02::1 is unreachable\n");
$cmd->stderr_is_eq("");
if($ENV{SKIP_IPV6}) {
skip 'Skip IPv6 tests', 3;
}
- my $cmd = Test::Command->new(cmd => "fping -c1 --check-source 127.0.0.1 ff02::1");
+ my $cmd = Test::Command->new(cmd => "fping -c1 -t100 --check-source 127.0.0.1 ff02::1");
$cmd->exit_is_num(1);
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
ff02::1 : \[0\], timed out \(NaN avg, 100% loss\)
if($ENV{SKIP_IPV6}) {
skip 'Skip IPv6 tests', 3;
}
- my $cmd = Test::Command->new(cmd => "fping -C1 --check-source 127.0.0.1 ff02::1");
+ my $cmd = Test::Command->new(cmd => "fping -C1 -t100 --check-source 127.0.0.1 ff02::1");
$cmd->exit_is_num(1);
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
ff02::1 : \[0\], timed out \(NaN avg, 100% loss\)
{
my $cmd = Test::Command->new(cmd => "fping -d 127.0.0.1");
$cmd->exit_is_num(0);
-$cmd->stdout_is_eq("localhost is alive\n");
+$cmd->stdout_like(qr/^localhost(\.localdomain)? 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');
+my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill fping)& fping -p 100 -l 127.0.0.1');
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
});
# fping -l --print-tos --print-ttl
{
-my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 --print-ttl --print-tos -l 127.0.0.1');
+my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill fping)& fping -p 100 --print-ttl --print-tos -l 127.0.0.1');
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) \(TOS \d+\) \(TTL \d+\)
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) \(TOS \d+\) \(TTL \d+\)
});
# fping -l with SIGQUIT
{
-my $cmd = Test::Command->new(cmd => '(sleep 2; pkill -QUIT fping; sleep 2; pkill fping)& fping -p 900 -l 127.0.0.1');
+my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill -QUIT fping; sleep 0.5; pkill fping)& fping -p 100 -l 127.0.0.1');
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[2\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
if($^O eq 'darwin') {
skip 'On macOS, this test is unreliable', 2;
}
-my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 850 -l -Q 1 127.0.0.1');
+my $cmd = Test::Command->new(cmd => '(sleep 1.5; pkill fping)& fping -p 100 -l -Q 0.5 127.0.0.1');
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d\d:\d\d:\d\d\]
127\.0\.0\.1 : xmt/rcv/%loss = \d/\d/\d%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
# fping -l -t
{
-my $cmd = Test::Command->new(cmd => '(sleep 2; pkill fping)& fping -p 900 -t 1500 -l 127.0.0.1');
+my $cmd = Test::Command->new(cmd => '(sleep 0.5; pkill fping)& fping -p 100 -t 1500 -l 127.0.0.1');
$cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\)
});
}
# fping -Q
-{
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
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("");
});
}
-# fping -Q (longer test to show two time stamps and reset statistics)
-{
-my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 550 -c 5 127.0.0.1");
+# fping -Q (fractional time)
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -Q0.5 -p 200 -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 = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
-\[\d+:\d+:\d+\]
-127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
-127\.0\.0\.1 : xmt/rcv/%loss = 5/5/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
+127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
+127\.0\.0\.1 : xmt/rcv/%loss = 4/4/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+
});
}
-# fping -Q n ignores non-number characters after the number, except for keywords
-{
-my $cmd = Test::Command->new(cmd => "fping -Q 1whatever -p 550 -c 5 127.0.0.1");
+# fping -Q (longer test to show two time stamps and reset statistics)
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -Q 1 -p 550 -c 5 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
}
# fping -Q n ignores unknown keywords
-{
-my $cmd = Test::Command->new(cmd => "fping -Q 1,not_a_keyword -p 550 -c 5 127.0.0.1");
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -Q 0.5,not_a_keyword -p 300 -c 5 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
}
# fping -Q n,cumulative
-{
-my $cmd = Test::Command->new(cmd => "fping -Q 1,cumulative -p 550 -c 5 127.0.0.1");
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -Q 0.5,cumulative -p 300 -c 5 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
}
# fping -Q -o
-{
-my $cmd = Test::Command->new(cmd => "fping -c4 -Q1 -p550 -o 8.8.8.7");
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -c4 -Q0.5 -p300 -o 8.8.8.7");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
-8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 55\d
+8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 30\d
\[\d+:\d+:\d+\]
-8\.8\.8\.7 : xmt/rcv/%loss = 2/0/100%, outage\(ms\) = 110\d
-8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 220\d
+8\.8\.8\.7 : xmt/rcv/%loss = 2/0/100%, outage\(ms\) = 60\d
+8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 120\d
});
}
# fping -Q n,cumulative -o
-{
-my $cmd = Test::Command->new(cmd => "fping -c4 -Q1,cumulative -p550 -o 8.8.8.7");
+SKIP: {
+if($^O eq 'darwin') {
+ skip 'On macOS, -Q tests are unreliable', 3;
+}
+my $cmd = Test::Command->new(cmd => "fping -c4 -Q0.5,cumulative -p300 -o 8.8.8.7");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
$cmd->stderr_like(qr{\[\d+:\d+:\d+\]
-8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 55\d
+8\.8\.8\.7 : xmt/rcv/%loss = 1/0/100%, outage\(ms\) = 30\d
\[\d+:\d+:\d+\]
-8\.8\.8\.7 : xmt/rcv/%loss = 3/0/100%, outage\(ms\) = 165\d
-8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 220\d
+8\.8\.8\.7 : xmt/rcv/%loss = 3/0/100%, outage\(ms\) = 90\d
+8\.8\.8\.7 : xmt/rcv/%loss = 4/0/100%, outage\(ms\) = 120\d
});
}
+