From 5d70c4d61b2e8c292337fefd975b9d603c6fdc8e Mon Sep 17 00:00:00 2001 From: Erik Auerswald Date: Sun, 19 May 2024 17:42:31 +0200 Subject: [PATCH 1/2] test help output during normal option parsing The existing test for "fping -h" triggers the special code path for only one option, either -h or --help, that is handled before normal option parsing. --- ci/test-02-help.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ci/test-02-help.pl b/ci/test-02-help.pl index 19c6741b..5a146fb8 100755 --- a/ci/test-02-help.pl +++ b/ci/test-02-help.pl @@ -1,11 +1,11 @@ #!/usr/bin/perl -w -use Test::Command tests => 9; +use Test::Command tests => 12; my $I_HELP = " -I, --iface=IFACE bind to a particular interface\n"; $I_HELP = '' if $^O eq 'darwin'; -# fping -h +# fping -h (special pre-parse code path) my $cmd1 = Test::Command->new(cmd => "fping -h"); $cmd1->exit_is_num(0); $cmd1->stdout_like(qr{Usage: fping \[options\] \[targets\.\.\.\] @@ -16,6 +16,17 @@ }s); $cmd1->stderr_is_eq(""); +# fping -4 -h (normal option parsing code path) +my $cmd4 = Test::Command->new(cmd => "fping -4 -h"); +$cmd4->exit_is_num(0); +$cmd4->stdout_like(qr{Usage: fping \[options\] \[targets\.\.\.\] + +Probing options: +.* + -v, --version show version +}s); +$cmd4->stderr_is_eq(""); + # fping -v my $cmd2 = Test::Command->new(cmd => "fping -v"); $cmd2->exit_is_num(0); From e4837542433a6ec05a74a24dcfccebc5e971a5a3 Mon Sep 17 00:00:00 2001 From: Erik Auerswald Date: Sun, 19 May 2024 17:54:37 +0200 Subject: [PATCH 2/2] test error when binding to wrong local address Test "fping -S" with both IPv4 and IPv6 addresses not configured on local interfaces using addresses reserved for documentation. Check the fping error message, but accept any system generated additional information. This additional information differs between operation systems. --- ci/test-09-option-r-t.pl | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/ci/test-09-option-r-t.pl b/ci/test-09-option-r-t.pl index b256f667..5cede8d7 100755 --- a/ci/test-09-option-r-t.pl +++ b/ci/test-09-option-r-t.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::Command tests => 21; +use Test::Command tests => 27; use Test::More; # -R random bytes @@ -84,6 +84,14 @@ $cmd->stderr_is_eq(""); } +# fping -S (wrong source address) +{ +my $cmd = Test::Command->new(cmd => "fping -S 192.0.2.47 127.0.0.1"); +$cmd->exit_is_num(4); +$cmd->stdout_is_eq(""); +$cmd->stderr_like(qr{fping: cannot bind source address : .+\n}); +} + # fping -S SKIP: { if($ENV{SKIP_IPV6}) { @@ -95,6 +103,17 @@ $cmd->stderr_is_eq(""); } +# fping -S (wrong IPv6 source address) +SKIP: { + if($ENV{SKIP_IPV6}) { + skip 'Skip IPv6 tests', 3; + } + my $cmd = Test::Command->new(cmd => "fping -S 2001:db8::1 ::1"); + $cmd->exit_is_num(4); + $cmd->stdout_is_eq(""); + $cmd->stderr_like(qr{fping: cannot bind source address : .+\n}); +} + # fping -S { my $cmd = Test::Command->new(cmd => "fping -S bla");