From c9f276b3cd74ba7f2760720f29d6b38f7e91ab89 Mon Sep 17 00:00:00 2001 From: David Schweikert Date: Fri, 2 May 2014 23:39:39 +0200 Subject: [PATCH] more tests --- ci/test-11-nopriv.pl | 0 ci/test-12-option-type.pl | 10 ++++++++++ src/fping.c | 6 +++++- 3 files changed, 15 insertions(+), 1 deletion(-) mode change 100644 => 100755 ci/test-11-nopriv.pl create mode 100755 ci/test-12-option-type.pl 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");