From: David Schweikert Date: Tue, 14 Feb 2017 10:45:09 +0000 (+0100) Subject: improve coverage X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=24ce982e5b3132c8d46fd2bccc6380ae75e91b07;p=fping.git improve coverage --- diff --git a/ci/build-2-install.sh b/ci/build-2-install.sh index 247eaef..bb94f32 100755 --- a/ci/build-2-install.sh +++ b/ci/build-2-install.sh @@ -10,7 +10,7 @@ fi autoreconf -i ./configure --enable-ipv4 --enable-ipv6 --prefix=/opt/fping -make CFLAGS="-g -fprofile-arcs -ftest-coverage" +make CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage" ## setcap currently doesn't work anymore on travis-ci #sudo setcap cap_net_raw+ep src/fping ## setcap debugging: diff --git a/ci/test-08-options-n-q.pl b/ci/test-08-options-n-q.pl index c490c19..d14173f 100755 --- a/ci/test-08-options-n-q.pl +++ b/ci/test-08-options-n-q.pl @@ -1,6 +1,6 @@ #!/usr/bin/perl -w -use Test::Command tests => 12; +use Test::Command tests => 18; # -n show targets by name (-d is equivalent) # -O n set the type of service (tos) flag on the ICMP packets @@ -11,6 +11,22 @@ use Test::Command tests => 12; # fping -n -> test-14-internet-hosts +# fping -d -n +{ +my $cmd = Test::Command->new(cmd => "fping -d -n 127.0.0.1"); +$cmd->exit_is_num(1); +$cmd->stdout_is_eq(""); +$cmd->stderr_is_eq("fping: use either one of -d or -n\n"); +} + +# fping -n -d +{ +my $cmd = Test::Command->new(cmd => "fping -n -d 127.0.0.1"); +$cmd->exit_is_num(1); +$cmd->stdout_is_eq(""); +$cmd->stderr_is_eq("fping: use either one of -d or -n\n"); +} + # fping -o { my $cmd = Test::Command->new(cmd => "fping -t100 -p 100 -o -c 5 8.8.8.7"); diff --git a/ci/test-09-option-r-t.pl b/ci/test-09-option-r-t.pl index eae162d..2ea7a68 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 => 18; +use Test::Command tests => 21; use Test::More; # -R random bytes @@ -95,4 +95,12 @@ SKIP: { $cmd->stderr_is_eq(""); } +# fping -S +{ +my $cmd = Test::Command->new(cmd => "fping -S bla"); +$cmd->exit_is_num(1); +$cmd->stdout_is_eq(""); +$cmd->stderr_is_eq("fping: can't parse source address: bla\n"); +} + # fping -t tested in test-4-options-a-b.pl diff --git a/src/fping.c b/src/fping.c index 945eb09..ee2da5f 100644 --- a/src/fping.c +++ b/src/fping.c @@ -613,8 +613,8 @@ int main(int argc, char** argv) break; } #endif - usage(1); - break; + fprintf(stderr, "%s: can't parse source address: %s\n", prog, optparse_state.optarg); + exit(1); case 'I': #ifdef SO_BINDTODEVICE