From: David Schweikert Date: Fri, 2 May 2014 21:39:39 +0000 (+0200) Subject: more tests X-Git-Tag: 3.10~1^2~12 X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c9f276b3cd74ba7f2760720f29d6b38f7e91ab89;p=fping.git more tests --- diff --git a/ci/test-11-nopriv.pl b/ci/test-11-nopriv.pl old mode 100644 new mode 100755 diff --git a/ci/test-12-option-type.pl b/ci/test-12-option-type.pl new file mode 100755 index 0000000..d6e3211 --- /dev/null +++ b/ci/test-12-option-type.pl @@ -0,0 +1,10 @@ +#!/usr/bin/perl -w + +use Test::Command tests => 33; + +for my $arg (qw(i B c C H i O p Q r t)) { + my $cmd = Test::Command->new(cmd => "fping -$arg xxx"); + $cmd->exit_is_num(1); + $cmd->stdout_is_eq(""); + $cmd->stderr_like(qr{Usage:}); +} diff --git a/src/fping.c b/src/fping.c index 6237090..b62983c 100644 --- a/src/fping.c +++ b/src/fping.c @@ -392,7 +392,8 @@ int main( int argc, char **argv ) break; case 'r': - retry = ( unsigned int )atoi( optarg ); + if(!(retry = ( unsigned int )atoi( optarg ))) + usage(1); break; case 'i': @@ -550,6 +551,9 @@ int main( int argc, char **argv ) perror("setting type of service octet IP_TOS"); } } + else { + usage(1); + } break; default: fprintf(stderr, "see 'fping -h' for usage information\n");