--- /dev/null
+#!/bin/bash
+
+# only do this on Mac OS X
+if [ `uname -s` != "Darwin" ]; then
+ exit 0;
+fi
+
+if [[ ! `ifconfig lo0` =~ 127\.0\.0\.2 ]]; then
+ sudo ifconfig lo0 127.0.0.2/8 alias
+ sudo ifconfig lo0 127.0.0.3/8 alias
+ sudo ifconfig lo0 127.0.0.4/8 alias
+ sudo ifconfig lo0 127.0.0.5/8 alias
+fi
#!/usr/bin/perl -w
-use Test::Command tests => 6;
+use Test::Command;
+use Test::More;
+
+if( $^O eq 'darwin' ) {
+ plan skip_all => 'Test irrelevant on MacOS';
+ exit 0;
+}
+plan tests => 6;
# run without privileges
my $fping_bin = `which fping`; chomp $fping_bin;
my $cmd = Test::Command->new(cmd => "fping nosuchname.example.com");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
-$cmd->stderr_is_eq("nosuchname.example.com: Name or service not known\n");
+$cmd->stderr_like(qr{^nosuchname\.example\.com: (Name or service not known|nodename nor servname provided, or not known)\n});
}
# fping6
my $cmd = Test::Command->new(cmd => "fping6 nosuchname.example.com");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("");
-$cmd->stderr_is_eq("nosuchname.example.com: Name or service not known\n");
+$cmd->stderr_like(qr{^nosuchname\.example\.com: (Name or service not known|nodename nor servname provided, or not known)\n});
}
#!/usr/bin/perl -w
-use Test::Command tests => 3;
+use Test::Command;
+use Test::More;
+
+# evaluate if we have internet
+if(!gethostbyname("www.google.com")) {
+ plan skip_all => 'Can\'t resolve www.google.com -> no internet?';
+ exit 0;
+}
+
+plan tests => 18;
my $re_num = qr{\d+(?:\.\d+)?};
www\.google\.com\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = $re_num/$re_num/$re_num
});
}
+
+# fping -A -n
+{
+my $cmd = Test::Command->new(cmd => "fping -A -n 8.8.8.8");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("google-public-dns-a.google.com (8.8.8.8) is alive\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping -A -n
+{
+my $cmd = Test::Command->new(cmd => "fping -A -n google-public-dns-a.google.com");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("google-public-dns-a.google.com (8.8.8.8) is alive\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping6 -A -n
+{
+my $cmd = Test::Command->new(cmd => "fping6 -n -A 2001:4860:4860::8888");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("google-public-dns-a.google.com (2001:4860:4860::8888) is alive\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping -m
+{
+my $cmd = Test::Command->new(cmd => "fping -m google-public-dns-a.google.com");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
+$cmd->stderr_is_eq("");
+}
+
+# fping -n
+{
+my $cmd = Test::Command->new(cmd => "fping -n 8.8.8.8");
+$cmd->exit_is_num(0);
+$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
+$cmd->stderr_is_eq("");
+}
#!/usr/bin/perl -w
-use Test::Command tests => 23;
+use Test::Command tests => 14;
use Test::More;
use Time::HiRes qw(gettimeofday tv_interval);
$cmd->stderr_is_eq("");
}
-# fping -A -n
-{
-my $cmd = Test::Command->new(cmd => "fping -A -n 8.8.8.8");
-$cmd->exit_is_num(0);
-$cmd->stdout_is_eq("google-public-dns-a.google.com (8.8.8.8) is alive\n");
-$cmd->stderr_is_eq("");
-}
-
-# fping -A -n
-{
-my $cmd = Test::Command->new(cmd => "fping -A -n google-public-dns-a.google.com");
-$cmd->exit_is_num(0);
-$cmd->stdout_is_eq("google-public-dns-a.google.com (8.8.8.8) is alive\n");
-$cmd->stderr_is_eq("");
-}
-
-# fping6 -A -n
-{
-my $cmd = Test::Command->new(cmd => "fping6 -n -A 2001:4860:4860::8888");
-$cmd->exit_is_num(0);
-$cmd->stdout_is_eq("google-public-dns-a.google.com (2001:4860:4860::8888) is alive\n");
-$cmd->stderr_is_eq("");
-}
-
# fping -b
{
my $cmd = Test::Command->new(cmd => "fping -b 1000 127.0.0.1");
my $cmd = Test::Command->new(cmd => "fping -t 100 -r 3 -B 2 8.8.8.7");
$cmd->exit_is_num(1);
$cmd->stdout_is_eq("8.8.8.7 is unreachable\n");
-$cmd->stderr_is_eq("");
+$cmd->stderr_like(qr{^(|(8.8.8.7: error while sending ping: No route to host\n)+)$});
my $elapsed = tv_interval($t0);
# 0.1 + 0.2 + 0.4 + 0.8 = 1.5
cmp_ok($elapsed, '>=', 1.5);
#!/usr/bin/perl -w
-use Test::Command tests => 7;
+use Test::Command tests => 4;
# -i n interval between sending ping packets (in millisec) (default 25)
# -l loop sending pings forever
});
}
-# fping -m
-{
-my $cmd = Test::Command->new(cmd => "fping -m google-public-dns-a.google.com");
-$cmd->exit_is_num(0);
-$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
-$cmd->stderr_is_eq("");
-}
+# fping -m -> test-14-internet-hosts
#!/usr/bin/perl -w
-use Test::Command tests => 12;
+use Test::Command tests => 9;
# -n show targets by name (-d is equivalent)
# -O n set the type of service (tos) flag on the ICMP packets
# -q quiet (don't show per-target/per-ping results)
# -Q n same as -q, but show summary every n seconds
-# fping -n
-{
-my $cmd = Test::Command->new(cmd => "fping -n 8.8.8.8");
-$cmd->exit_is_num(0);
-$cmd->stdout_is_eq("google-public-dns-a.google.com is alive\n");
-$cmd->stderr_is_eq("");
-}
+# fping -n -> test-14-internet-hosts
# fping -O
{