From: David Schweikert Date: Fri, 7 Mar 2014 14:57:47 +0000 (+0100) Subject: more tests X-Git-Url: https://git.gsnw.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cd21d0bb91886aa93e10ee7f04667b5260f9d5ed;p=fping.git more tests --- diff --git a/ChangeLog b/ChangeLog index 3e0b22f..ca4ff1b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,9 +1,9 @@ UNRELEASED David Schweikert * Fix random output on socket error (reported by Aleksandrs Saveljevs, #56) - * Initial test suite and continous intergration (with travis-ci.org / coveralls.io) * Support ppc64le architecture by including alpha libtool version (reported by Amit Kumar Gupta and Aravinda B Thunug) - * Fix compliation problem on FreeBSD (#57) + * Fix compilation problem on FreeBSD (#57) + * Initial test suite and continous intergration (with travis-ci.org / coveralls.io) * Don't output usage information on error 2013-11-08 David Schweikert diff --git a/autoclean.sh b/autoclean.sh index 5757c9d..1977d24 100755 --- a/autoclean.sh +++ b/autoclean.sh @@ -19,3 +19,6 @@ rm -f stamp-h1 rm -f doc/Makefile.in rm -f src/Makefile.in rm -f doc/fping.8 +rm -f src/*.gcda +rm -f src/*.gcno +rm -f src/*.gcov diff --git a/ci/test-4-options-a-b.pl b/ci/test-4-options-a-b.pl new file mode 100755 index 0000000..993458b --- /dev/null +++ b/ci/test-4-options-a-b.pl @@ -0,0 +1,39 @@ +#!/usr/bin/perl -w + +use Test::Command tests => 14; +use Test::More; +use Time::HiRes qw(gettimeofday tv_interval); + +# -a show targets that are alive +# -A show targets by address +# -b n amount of ping data to send, in bytes (default 56) +# -B f set exponential backoff factor to f + +# fping -a +my $cmd1 = Test::Command->new(cmd => "fping -a 127.0.0.1 127.0.0.2"); +$cmd1->exit_is_num(0); +$cmd1->stdout_is_eq("127.0.0.1\n127.0.0.2\n"); +$cmd1->stderr_is_eq(""); + +# fping -A +my $cmd2 = Test::Command->new(cmd => "fping -A 127.0.0.1"); +$cmd2->exit_is_num(0); +$cmd2->stdout_is_eq("127.0.0.1 is alive\n"); +$cmd2->stderr_is_eq(""); + +# fping -b +my $cmd3 = Test::Command->new(cmd => "fping -b 1000 127.0.0.1"); +$cmd3->exit_is_num(0); +$cmd3->stdout_is_eq("127.0.0.1 is alive\n"); +$cmd3->stderr_is_eq(""); + +# fping -B +my $t0 = [gettimeofday]; +my $cmd4 = Test::Command->new(cmd => "fping -t 100 -r 3 -B 2 8.8.8.7"); +$cmd4->exit_is_num(0); +$cmd4->stdout_is_eq("8.8.8.7 is unreachable\n"); +$cmd4->stderr_is_eq(""); +my $elapsed = tv_interval($t0); +# 0.1 + 0.2 + 0.4 + 0.8 = 1.5 +cmp_ok($elapsed, '>=', 1.5); +cmp_ok($elapsed, '<', 1.7);