From 51daca0ce2041c9cc2bf985de284f7e6cd5863d8 Mon Sep 17 00:00:00 2001 From: Erik Auerswald Date: Sun, 23 Jun 2024 17:04:48 +0200 Subject: [PATCH 1/2] ci: test empty string argument instead of number Giving an empty string instead of a number as option argument was not reliably caught, see GH issue #324 and GH PR #323. --- ci/test-12-option-type.pl | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ci/test-12-option-type.pl b/ci/test-12-option-type.pl index c3ca51f6..6514425a 100755 --- a/ci/test-12-option-type.pl +++ b/ci/test-12-option-type.pl @@ -1,22 +1,27 @@ #!/usr/bin/perl -w -use Test::Command tests => 42; +use Test::Command tests => 84; use Test::More; +# some options require a numeric argument for my $arg (qw(b B c C H i O p Q r t x X)) { - my $cmd = Test::Command->new(cmd => "fping -$arg xxx"); - $cmd->exit_is_num(1); - $cmd->stdout_is_eq(""); - $cmd->stderr_like(qr{Usage:}); + for my $test_input (qw(xxx '')) { + my $cmd = Test::Command->new(cmd => "fping -$arg $test_input"); + $cmd->exit_is_num(1); + $cmd->stdout_is_eq(""); + $cmd->stderr_like(qr{Usage:}); + } } # fping -k, only supported on Linux, requires a number SKIP: { if($^O ne 'linux') { - skip '-k option is only supported on Linux', 3; + skip '-k option is only supported on Linux', 6; + } + for my $test_input (qw(xxx '')) { + my $cmd = Test::Command->new(cmd => "fping -k $test_input 127.0.0.1"); + $cmd->exit_is_num(1); + $cmd->stdout_is_eq(""); + $cmd->stderr_like(qr{Usage:}); } - my $cmd = Test::Command->new(cmd => 'fping -k xxx 127.0.0.1'); - $cmd->exit_is_num(1); - $cmd->stdout_is_eq(""); - $cmd->stderr_like(qr{Usage:}); } From c22916354ffd0e7d9953f73db93b9861df3ed083 Mon Sep 17 00:00:00 2001 From: Erik Auerswald Date: Sun, 23 Jun 2024 17:19:13 +0200 Subject: [PATCH 2/2] ci: test timestamp plausibility Some changes of fping resulted in some systems reporting implausible timestamps, see, e.g., GH issue #203. This commit adds a simplistic plausability check for timestamps in Unix time format: they need to be greater or equal to 1000000000 (2001-09-09 03:46:40+02:00). --- ci/test-05-options-c-e.pl | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/ci/test-05-options-c-e.pl b/ci/test-05-options-c-e.pl index 9b290baf..9884d116 100755 --- a/ci/test-05-options-c-e.pl +++ b/ci/test-05-options-c-e.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::Command tests => 48; +use Test::Command tests => 51; # -c n count of pings to send to each target (default 1) # -C n same as -c, report results in verbose format @@ -138,6 +138,17 @@ }); } +# fping -D (timestamp not before 2001-09-09) +{ +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{\[[1-9]\d{9,}\.\d+\] 127\.0\.0\.1 : \[0\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) +\[[1-9]\d{9,}\.\d+\] 127\.0\.0\.1 : \[1\], 64 bytes, \d\.\d+ ms \(\d\.\d+ avg, 0% loss\) +}); +$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = \d\.\d+/\d\.\d+/\d\.\d+ +}); +} + # fping -D --timestamp-format=ctime { my $cmd = Test::Command->new(cmd => "fping -D --timestamp-format=ctime -c 2 -p 100 127.0.0.1");