]> git.gsnw.org Git - fping.git/commitdiff
Tests performance and robustness fixes.
authorDavid Schweikert <david@schweikert.ch>
Mon, 22 Dec 2025 15:15:55 +0000 (16:15 +0100)
committerDavid Schweikert <david@schweikert.ch>
Wed, 24 Dec 2025 13:25:58 +0000 (14:25 +0100)
ci/prepare-linux.sh
ci/test-05-options-c-e.pl
ci/test-07-options-i-m.pl
ci/test-08-options-n-q.pl

index efe8b3b86af251ce8ca7138dbc5a1bc2c3f0e332..4af6d84972c7df7b2b9bc4d462e9e83115c50edf 100755 (executable)
@@ -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
index d1cc767f7f6e79126668a93cc1ba59cee7fafffb..3f27be8a783d459de6ffa58b2ffcbe60dbd9661d 100755 (executable)
@@ -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("");
 }
 
index d69e04da4b73bd0ca589307aada87dc7598e2ece..7cca6ab3f4f3b9dd12d0a06c987b6fce76dd6932 100755 (executable)
@@ -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\)
 });
index f145e5dd20631e56a75a96a850d2ea4f98504b09..6fb95356f7adb0b4c77b4253fc8eda2a52b1e2ff 100755 (executable)
@@ -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
 });
 }
 
+