Skip to content

Commit

Permalink
Adding separate exit codes for success or failure, and printing the n…
Browse files Browse the repository at this point in the history
…umber of reachable hosts
  • Loading branch information
deepak0004 committed Oct 27, 2018
1 parent 9812557 commit af9b3bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions ci/test-10-option-u-x.pl
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,14 @@
{
my $cmd = Test::Command->new(cmd => "fping -x 1 8.8.0.0 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq(">=1 hosts are reachable\n");
$cmd->stdout_is_eq("Number of reachable hosts: 1\n");
$cmd->stderr_is_eq("");
}

# fping -x
{
my $cmd = Test::Command->new(cmd => "fping -x 2 8.8.0.0 127.0.0.1");
$cmd->exit_is_num(0);
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("<2 hosts are reachable\n");
$cmd->stderr_is_eq("");
}
5 changes: 3 additions & 2 deletions src/fping.c
Original file line number Diff line number Diff line change
Expand Up @@ -1334,11 +1334,12 @@ void finish()

if (reachable_flag) {
if ((num_hosts-num_unreachable >= reachable)) {
printf(">=%d hosts are reachable\n", reachable);
printf("Number of reachable hosts: %d\n", num_hosts-num_unreachable);
exit(0);
} else {
printf("<%d hosts are reachable\n", reachable);
exit(1);
}
exit(0);
}

if (num_noaddress)
Expand Down

0 comments on commit af9b3bf

Please sign in to comment.