Adding separate exit codes for success or failure, and printing the number of reachable hosts

pull/138/head
deepak0004 6 years ago
parent 9812557c71
commit af9b3bfbfe

@ -27,14 +27,14 @@ $cmd->stderr_is_eq("");
{
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("");
}

@ -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)

Loading…
Cancel
Save