]> git.gsnw.org Git - fping.git/commitdiff
Test for fping: add option to exit immediately once N hosts have been found
authorGerman Service Network <support@gsnw.de>
Sun, 31 Jul 2022 06:53:57 +0000 (08:53 +0200)
committerDavid Schweikert <david@schweikert.ch>
Sun, 27 Aug 2023 09:03:49 +0000 (11:03 +0200)
ci/test-10-option-u-x.pl

index f4bb66c3923e929f65924dca58890b13b772ea8c..72fc03e5e0d274e96e5741d9f3e1be04eb2d18e8 100755 (executable)
@@ -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
 {
@@ -36,3 +38,19 @@ $cmd->exit_is_num(1);
 $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("");
+}