more tests

pull/67/head
David Schweikert 11 years ago
parent 930af0fc54
commit af0446b046

@ -4,6 +4,7 @@ UNRELEASED David Schweikert <david@schweikert.ch>
* Support ppc64le architecture by including alpha libtool version
(reported by Amit Kumar Gupta and Aravinda B Thunug)
* Fix compliation problem on FreeBSD (#57)
* Don't output usage information on error
2013-11-08 David Schweikert <david@schweikert.ch>
* Version 3.8

@ -0,0 +1,81 @@
#!/usr/bin/perl -w
use Test::Command tests => 33;
# fping -i 9
my $cmd1 = Test::Command->new(cmd => "fping -i 9 -g 127.0.0.1/29");
$cmd1->exit_is_num(1);
$cmd1->stdout_is_eq("");
$cmd1->stderr_is_eq(<<END);
fping: these options are too risky for mere mortals.
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
END
# fping -p 15
my $cmd2 = Test::Command->new(cmd => "fping -c3 -p 15 127.0.0.1");
$cmd2->exit_is_num(1);
$cmd2->stdout_is_eq("");
$cmd2->stderr_is_eq(<<END);
fping: these options are too risky for mere mortals.
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
END
# fping -r 30
my $cmd3 = Test::Command->new(cmd => "fping -r 30 127.0.0.1");
$cmd3->exit_is_num(1);
$cmd3->stdout_is_eq("");
$cmd3->stderr_is_eq(<<END);
fping: these options are too risky for mere mortals.
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
END
# fping -t 40
my $cmd4 = Test::Command->new(cmd => "fping -t 40 127.0.0.1");
$cmd4->exit_is_num(1);
$cmd4->stdout_is_eq("");
$cmd4->stderr_is_eq(<<END);
fping: these options are too risky for mere mortals.
fping: You need i >= 10, p >= 20, r < 20, and t >= 50
END
# fping -H 300
my $cmd5 = Test::Command->new(cmd => "fping -H 300 127.0.0.1");
$cmd5->exit_is_num(1);
$cmd5->stdout_is_eq("");
$cmd5->stderr_is_eq("ttl 300 out of range\n");
# fping -a -u
my $cmd6 = Test::Command->new(cmd => "fping -a -u 127.0.0.1");
$cmd6->exit_is_num(1);
$cmd6->stdout_is_eq("");
$cmd6->stderr_is_eq("fping: specify only one of a, u\n");
# fping -c -l
my $cmd7 = Test::Command->new(cmd => "fping -c3 -l 127.0.0.1");
$cmd7->exit_is_num(1);
$cmd7->stdout_is_eq("");
$cmd7->stderr_is_eq("fping: specify only one of c, l\n");
# fping -b 65509
my $cmd8 = Test::Command->new(cmd => "fping -b 65509 127.0.0.1");
$cmd8->exit_is_num(1);
$cmd8->stdout_is_eq("");
$cmd8->stderr_is_eq("fping: data size 65509 not valid, must be between 0 and 65508\n");
# fping -B 0.9
my $cmd9 = Test::Command->new(cmd => "fping -B 0.9 127.0.0.1");
$cmd9->exit_is_num(1);
$cmd9->stdout_is_eq("");
$cmd9->stderr_is_eq("fping: backoff factor 0.9 not valid, must be between 1.0 and 5.0\n");
# fping -B 0.9
my $cmd10 = Test::Command->new(cmd => "fping -B 5.1 127.0.0.1");
$cmd10->exit_is_num(1);
$cmd10->stdout_is_eq("");
$cmd10->stderr_is_eq("fping: backoff factor 5.1 not valid, must be between 1.0 and 5.0\n");
# fping -C 11000
my $cmd11 = Test::Command->new(cmd => "fping -C 11000 127.0.0.1");
$cmd11->exit_is_num(1);
$cmd11->stdout_is_eq("");
$cmd11->stderr_is_eq("fping: count 11000 not valid, must be less than 10000\n");

@ -581,20 +581,20 @@ int main( int argc, char **argv )
if (ttl > 255) {
fprintf(stderr, "ttl %u out of range\n", ttl);
usage(1);
exit(1);
}
if( unreachable_flag && alive_flag )
{
fprintf( stderr, "%s: specify only one of a, u\n", argv[0] );
usage(1);
exit(1);
}/* IF */
if( count_flag && loop_flag )
{
fprintf( stderr, "%s: specify only one of c, l\n", argv[0] );
usage(1);
exit(1);
}/* IF */
@ -607,15 +607,14 @@ int main( int argc, char **argv )
fprintf( stderr, "%s: these options are too risky for mere mortals.\n", prog );
fprintf( stderr, "%s: You need i >= %u, p >= %u, r < %u, and t >= %u\n",
prog, MIN_INTERVAL, MIN_PERHOST_INTERVAL, MAX_RETRY, MIN_TIMEOUT );
usage(1);
exit(1);
}/* IF */
if( ( ping_data_size > MAX_PING_DATA ) || ( ping_data_size < MIN_PING_DATA ) )
{
fprintf( stderr, "%s: data size %u not valid, must be between %u and %u\n",
prog, ping_data_size, (unsigned int) MIN_PING_DATA, (unsigned int) MAX_PING_DATA );
usage(1);
exit(1);
}/* IF */
@ -623,7 +622,7 @@ int main( int argc, char **argv )
{
fprintf( stderr, "%s: backoff factor %.1f not valid, must be between %.1f and %.1f\n",
prog, backoff, MIN_BACKOFF_FACTOR, MAX_BACKOFF_FACTOR );
usage(1);
exit(1);
}/* IF */
@ -631,7 +630,7 @@ int main( int argc, char **argv )
{
fprintf( stderr, "%s: count %u not valid, must be less than %u\n",
prog, count, MAX_COUNT );
usage(1);
exit(1);
}/* IF */

Loading…
Cancel
Save