Skip to content

Commit

Permalink
Test for fping: add option to exit immediately once N hosts have been…
Browse files Browse the repository at this point in the history
… found
  • Loading branch information
gsnw-sebast authored and schweikert committed Aug 27, 2023
1 parent d45438c commit f94adaf
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion ci/test-10-option-u-x.pl
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#!/usr/bin/perl -w

use Test::Command tests => 12;
use Test::Command tests => 18;

# -u show targets that are unreachable
# -v show version
# -x shows if >=N hosts are reachable or not
# -X exits true immediately when N hosts are found

# fping -u
{
Expand Down Expand Up @@ -36,3 +38,19 @@
$cmd->stdout_is_eq("Not enough hosts reachable (required: 2, reachable: 1)\n");
$cmd->stderr_is_eq("");
}

# fping -X
{
my $cmd = Test::Command->new(cmd => "fping -X 1 --generate 127.0.0.0/29");
$cmd->exit_is_num(0);
$cmd->stdout_is_eq("Enough hosts reachable (required: 1, reachable: 1)\n");
$cmd->stderr_is_eq("");
}

# fping -X
{
my $cmd = Test::Command->new(cmd => "fping -X 2 --generate 8.8.0.0/29");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("Not enough hosts reachable (required: 2, reachable: 0)\n");
$cmd->stderr_is_eq("");
}

0 comments on commit f94adaf

Please sign in to comment.