improve tests for macos x and for when offline

pull/82/head
David Schweikert 10 years ago
parent f6f16b9202
commit 0114c307ee

@ -0,0 +1,13 @@
#!/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

@ -1,6 +1,13 @@
#!/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;

@ -7,7 +7,7 @@ use Test::Command tests => 6;
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
@ -15,5 +15,5 @@ $cmd->stderr_is_eq("nosuchname.example.com: Name or service not known\n");
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});
}

@ -1,6 +1,15 @@
#!/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+)?};
@ -15,3 +24,43 @@ www\.france-telecom\.fr\s*: xmt/rcv/%loss = [123]/3/\d+%, min/avg/max = $re_num/
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("");
}

@ -1,6 +1,6 @@
#!/usr/bin/perl -w
use Test::Command tests => 23;
use Test::Command tests => 14;
use Test::More;
use Time::HiRes qw(gettimeofday tv_interval);
@ -25,30 +25,6 @@ $cmd->stdout_is_eq("127.0.0.1 is alive\n");
$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");
@ -63,7 +39,7 @@ my $t0 = [gettimeofday];
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);

@ -1,6 +1,6 @@
#!/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
@ -22,10 +22,4 @@ $cmd->stdout_like(qr{127\.0\.0\.1 : \[0\], 84 bytes, 0\.\d+ ms \(0.\d+ avg, 0% l
});
}
# 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

@ -1,6 +1,6 @@
#!/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
@ -9,13 +9,7 @@ use Test::Command tests => 12;
# -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
{

Loading…
Cancel
Save