From b5046cfa786bbf6f35005ef2f297ebb8bef02fec Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Fri, 20 Jan 2017 22:59:55 +0100 Subject: [PATCH] Fix -M expecting an argument, when it shouldn't --- ChangeLog | 1 + ci/test-07-options-i-m.pl | 11 ++++++++++- ci/test-14-ping-internet-hosts.pl | 10 +++++++++- src/fping.c | 2 +- 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7f9267a..a813938 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,7 @@ Unreleased * (feature) Simplify restrictions: only -i >= 1 and -p >= 10 are enforced now * (bugfix) Fix compatibility issue with AIX (#69, @blentzgh) * (bugfix) Fix -q not suppressing some ICMP error messages (#83) + * (bugfix) Fix -M expecting an argument, when it shouldn't 2017-01-11 David Schweikert * Version 3.15 diff --git a/ci/test-07-options-i-m.pl b/ci/test-07-options-i-m.pl index e4529d9..9a22d13 100755 --- a/ci/test-07-options-i-m.pl +++ b/ci/test-07-options-i-m.pl @@ -1,10 +1,11 @@ #!/usr/bin/perl -w -use Test::Command tests => 4; +use Test::Command tests => 7; # -i n interval between sending ping packets (in millisec) (default 25) # -l loop sending pings forever # -m ping multiple interfaces on target host +# -M don't fragment # fping -i n { @@ -22,4 +23,12 @@ $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% l }); } +# fping -M +{ +my $cmd = Test::Command->new(cmd => "fping -M 127.0.0.1"); +$cmd->exit_is_num(0); +$cmd->stdout_is_eq("127.0.0.1 is alive\n"); +$cmd->stderr_is_eq(""); +} + # fping -m -> test-14-internet-hosts diff --git a/ci/test-14-ping-internet-hosts.pl b/ci/test-14-ping-internet-hosts.pl index 3c7aadb..5e36aa0 100755 --- a/ci/test-14-ping-internet-hosts.pl +++ b/ci/test-14-ping-internet-hosts.pl @@ -9,7 +9,7 @@ if(!gethostbyname("www.google.com")) { exit 0; } -plan tests => 18; +plan tests => 21; my $re_num = qr{\d+(?:\.\d+)?}; @@ -67,3 +67,11 @@ $cmd->exit_is_num(0); $cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n"); $cmd->stderr_is_eq(""); } + +# fping -M +{ +my $cmd = Test::Command->new(cmd => "fping -r 0 -b 10000 -M 8.8.8.8"); +$cmd->exit_is_num(1); +$cmd->stdout_is_eq("8.8.8.8 is unreachable\n"); +$cmd->stderr_is_eq("8.8.8.8: error while sending ping: Message too long\n"); +} diff --git a/src/fping.c b/src/fping.c index 50991dd..6cde9d0 100644 --- a/src/fping.c +++ b/src/fping.c @@ -385,7 +385,7 @@ int main( int argc, char **argv ) /* get command line options */ - while( ( c = getopt( argc, argv, "gedhlmnNqusaAvDRz:t:H:i:p:f:r:c:b:C:Q:B:S:I:T:O:M:o" ) ) != EOF ) + while( ( c = getopt( argc, argv, "ADMNRadeghlmnoqsuvzB:C:H:I:O:Q:S:T:b:c:f:i:p:r:t:" ) ) != EOF ) { switch( c ) {