]> git.gsnw.org Git - fping.git/commitdiff
More tests
authorDavid Schweikert <david@schweikert.ch>
Fri, 4 Apr 2014 20:22:48 +0000 (22:22 +0200)
committerDavid Schweikert <david@schweikert.ch>
Fri, 4 Apr 2014 20:22:48 +0000 (22:22 +0200)
ci/test-5-options-c-e.pl [new file with mode: 0755]

diff --git a/ci/test-5-options-c-e.pl b/ci/test-5-options-c-e.pl
new file mode 100755 (executable)
index 0000000..c2c0a56
--- /dev/null
@@ -0,0 +1,62 @@
+#!/usr/bin/perl -w
+
+use Test::Command tests => 12;
+use Test::More;
+use Time::HiRes qw(gettimeofday tv_interval);
+
+#  -c n       count of pings to send to each target (default 1)
+#  -C n       same as -c, report results in verbose format
+#  -D         print timestamp before each output line
+#  -e         show elapsed time on return packets
+
+# fping -c n
+{
+my $cmd = Test::Command->new(cmd => "fping -c 2 -p 100 localhost 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
+localhost : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+});
+
+$cmd->stderr_like(qr{localhost : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
+127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
+});
+}
+
+# fping -C n
+{
+my $cmd = Test::Command->new(cmd => "fping -C 2 -p 100 localhost 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{localhost : \[0\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
+localhost : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+});
+
+$cmd->stderr_like(qr{localhost : 0\.\d+ 0\.\d+
+127\.0\.0\.1 : 0\.\d+ 0\.\d+
+});
+}
+
+# fping -D
+{
+my $cmd = Test::Command->new(cmd => "fping -D -c 2 -p 100 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{\[\d{10}\.\d+\] 127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% loss\)
+\[\d{10}\.\d+\] 127\.0\.0\.1 : \[1\], 84 bytes, 0\.\d+ ms \(0\.\d+ avg, 0% loss\)
+});
+
+$cmd->stderr_like(qr{127\.0\.0\.1 : xmt/rcv/%loss = 2/2/0%, min/avg/max = 0\.\d+/0\.\d+/0\.\d+
+});
+}
+
+# fping -e
+{
+my $cmd = Test::Command->new(cmd => "fping -e 127.0.0.1");
+$cmd->exit_is_num(0);
+$cmd->stdout_like(qr{127\.0\.0\.1 is alive \(0\.\d+ ms\)
+});
+
+$cmd->stderr_is_eq("");
+}