From: David Schweikert Date: Wed, 5 Mar 2014 07:16:35 +0000 (+0100) Subject: some more tests X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8bd200905dc0fcd5bcfb9b2d3321250934b62830;p=fping.git some more tests --- diff --git a/ci/test-1.pl b/ci/test-1-basics.pl similarity index 60% rename from ci/test-1.pl rename to ci/test-1-basics.pl index 0b88863..9500970 100755 --- a/ci/test-1.pl +++ b/ci/test-1-basics.pl @@ -1,25 +1,21 @@ #!/usr/bin/perl -w use Test::Command tests => 9; -my $fping_bin = '/opt/fping/sbin/fping'; -my $fping6_bin = '/opt/fping/sbin/fping6'; -#my $fping_bin = '/home/dws/checkouts/fping/src/fping'; -#my $fping6_bin = '/home/dws/checkouts/fping/src/fping6'; # ping 127.0.0.1 -my $cmd1 = Test::Command->new(cmd => "$fping_bin 127.0.0.1"); +my $cmd1 = Test::Command->new(cmd => "fping 127.0.0.1"); $cmd1->exit_is_num(0); $cmd1->stdout_is_eq("127.0.0.1 is alive\n"); $cmd1->stderr_is_eq(""); # ping ::1 -my $cmd2 = Test::Command->new(cmd => "$fping6_bin ::1"); +my $cmd2 = Test::Command->new(cmd => "fping6 ::1"); $cmd2->exit_is_num(0); $cmd2->stdout_is_eq("::1 is alive\n"); $cmd2->stderr_is_eq(""); # ping 3 times 127.0.0.1 -my $cmd3 = Test::Command->new(cmd => "$fping_bin -p 100 -C3 127.0.0.1"); +my $cmd3 = Test::Command->new(cmd => "fping -p 100 -C3 127.0.0.1"); $cmd3->exit_is_num(0); $cmd3->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\) 127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\) diff --git a/ci/test-2-help.pl b/ci/test-2-help.pl new file mode 100755 index 0000000..802988d --- /dev/null +++ b/ci/test-2-help.pl @@ -0,0 +1,58 @@ +#!/usr/bin/perl -w + +use Test::Command tests => 9; + +# fping -h +my $cmd1 = Test::Command->new(cmd => "fping -h"); +$cmd1->exit_is_num(0); +$cmd1->stdout_is_eq(<stderr_is_eq(""); + +# fping -v +my $cmd2 = Test::Command->new(cmd => "fping -v"); +$cmd2->exit_is_num(0); +$cmd2->stdout_like(qr{fping: Version \S+ +fping: comments to david\@schweikert\.ch\n}); +$cmd2->stderr_is_eq(""); + +# fping with unknown option +my $cmd3 = Test::Command->new(cmd => "fping -Z"); +$cmd3->exit_is_num(1); +$cmd3->stdout_is_eq(""); +$cmd3->stderr_is_eq("fping: invalid option -- 'Z' +see 'fping -h' for usage information\n"); diff --git a/src/fping.c b/src/fping.c index af7608f..8ead087 100644 --- a/src/fping.c +++ b/src/fping.c @@ -570,7 +570,8 @@ int main( int argc, char **argv ) } break; default: - usage(1); + fprintf(stderr, "see 'fping -h' for usage information\n"); + exit(1); break; }/* SWITCH */ @@ -579,7 +580,7 @@ int main( int argc, char **argv ) /* validate various option settings */ if (ttl > 255) { - fprintf(stderr, "ping: ttl %u out of range\n", ttl); + fprintf(stderr, "ttl %u out of range\n", ttl); usage(1); }