]> git.gsnw.org Git - fping.git/commitdiff
Add test for -f option
authorDavid Schweikert <david@schweikert.ch>
Mon, 28 Apr 2014 17:28:29 +0000 (19:28 +0200)
committerDavid Schweikert <david@schweikert.ch>
Mon, 28 Apr 2014 17:28:29 +0000 (19:28 +0200)
ci/test-6-options-f-h.pl [new file with mode: 0755]

diff --git a/ci/test-6-options-f-h.pl b/ci/test-6-options-f-h.pl
new file mode 100755 (executable)
index 0000000..7756ae4
--- /dev/null
@@ -0,0 +1,40 @@
+#!/usr/bin/perl -w
+
+use Test::Command tests => 9;
+use Test::More;
+use Time::HiRes qw(gettimeofday tv_interval);
+use File::Temp;
+
+#  -f file    read list of targets from a file ( - means stdin) (only if no -g specified)
+#  -g         generate target list (only if no -f specified)
+#               (specify the start and end IP in the target list, or supply a IP netmask)
+#               (ex. ../src/fping -g 192.168.1.0 192.168.1.255 or ../src/fping -g 192.168.1.0/24)
+#  -H n       Set the IP TTL value (Time To Live hops)
+
+my $tmpfile = File::Temp->new();
+print $tmpfile "127.0.0.1\n127.0.0.2\n";
+close($tmpfile);
+
+# fping without option (-> equivalent to 'fping -f -')
+{
+my $cmd = Test::Command->new(cmd => "cat ".$tmpfile->filename." | fping");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping -f -
+{
+my $cmd = Test::Command->new(cmd => "cat ".$tmpfile->filename." | fping -f -");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping -f file
+{
+my $cmd = Test::Command->new(cmd => "fping -f ".$tmpfile->filename);
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("127.0.0.1 is alive\n127.0.0.2 is alive\n");
+$cmd->stderr_is_eq("");
+}