From: David Schweikert Date: Mon, 22 Dec 2025 15:15:55 +0000 (+0100) Subject: Tests performance and robustness fixes. X-Git-Tag: v5.5~15 X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6816b5aa4af67a3fb643b84241c09e88c172a9f9;p=fping.git Tests performance and robustness fixes. --- diff --git a/ci/prepare-linux.sh b/ci/prepare-linux.sh index efe8b3b..4af6d84 100755 --- a/ci/prepare-linux.sh +++ b/ci/prepare-linux.sh @@ -2,6 +2,8 @@ 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 diff --git a/ci/test-05-options-c-e.pl b/ci/test-05-options-c-e.pl index d1cc767..3f27be8 100755 --- a/ci/test-05-options-c-e.pl +++ b/ci/test-05-options-c-e.pl @@ -92,12 +92,12 @@ SKIP: { 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+ @@ -225,7 +225,7 @@ SKIP: { 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(""); @@ -236,7 +236,7 @@ SKIP: { 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\) @@ -252,7 +252,7 @@ SKIP: { 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\) @@ -267,7 +267,7 @@ ff02::1 : - { 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(""); } diff --git a/ci/test-07-options-i-m.pl b/ci/test-07-options-i-m.pl index d69e04d..7cca6ab 100755 --- a/ci/test-07-options-i-m.pl +++ b/ci/test-07-options-i-m.pl @@ -56,7 +56,7 @@ $cmd->stderr_like(qr{binding to specific interface \(SO_BINDTODEVICE\):.*\n}); # 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\) }); @@ -64,7 +64,7 @@ $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0 # 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+\) }); @@ -83,7 +83,7 @@ $cmd->stderr_is_eq(""); # 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\) @@ -100,7 +100,7 @@ SKIP: { 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+ @@ -111,7 +111,7 @@ $cmd->stderr_like(qr{\[\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\) }); diff --git a/ci/test-08-options-n-q.pl b/ci/test-08-options-n-q.pl index f145e5d..6fb9535 100755 --- a/ci/test-08-options-n-q.pl +++ b/ci/test-08-options-n-q.pl @@ -97,7 +97,10 @@ $cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 3/3/0%, min/avg/max = \d\.\d } # 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(""); @@ -107,22 +110,26 @@ $cmd->stderr_like(qr{\[\d+:\d+:\d+\] }); } -# 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+\] @@ -134,8 +141,11 @@ $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+\] @@ -147,8 +157,11 @@ $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+\] @@ -160,28 +173,35 @@ $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 }); } +