Commit aa8f83ff authored by Jonathon Duerig's avatar Jonathon Duerig

Make sure that linktest doesn't try to run rc.topomap when running in standalone mode.

parent 4796b751
......@@ -110,12 +110,14 @@ use constant TEST_LATENCY => 1; # direct link connectivity & latency
use constant TEST_RT_STATIC => 2; # prior plus static routing
use constant TEST_LOSS => 3; # prior plus loss
use constant TEST_BW => 4; # prior plus bandwidth
use constant TEST_UNLINK => 5; # prior plus unconnected interfaces
# test names
use constant NAME_RT_STATIC => "Routing";
use constant NAME_LATENCY => "Latency";
use constant NAME_LOSS => "Loss";
use constant NAME_BW => "Bandwidth";
use constant NAME_UNLINK => "Unlink";
# error suffix for logs
use constant SUFFIX_ERROR => ".error";
......@@ -314,6 +316,7 @@ if ($compat < 1.2) {
# path to applications and files
our $PATH_NICKNAME = "$VARDIR/boot/nickname";
our $PATH_CONTROL_IF = "$VARDIR/boot/controlif";
our $PATH_KEYFILE = "$VARDIR/boot/eventkey";
our $PATH_RUDE = "$BINDIR/emulab-rude";
our $PATH_CRUDE = "$BINDIR/emulab-crude";
......@@ -648,6 +651,22 @@ if(&dotest(TEST_BW)){
&report_status(NAME_BW);
}
if(&dotest(TEST_UNLINK)) {
my $stamp = TimeStamp();
my $msg = "Testing Unconnected Interfaces ... $stamp";
&post_event(EVENT_REPORT,$msg);
&sim_event(EVENT_LOG,$msg);
# Ick, this barrier makes sure the above message gets into the log
# first, so as not to confuse Mike
if ($printsched) {
&schedlog("barrier $barriers_hit: pre-unlink test");
}
&barrier();
&debug("\n$msg\n\n");
&unlink_test;
&report_status(NAME_UNLINK);
}
&cleanup;
if ($printsched) {
......@@ -666,6 +685,113 @@ $msg = "Linktest Done";
exit(EXIT_OK);
##############################################################################
# Unlink Test Functions
##############################################################################
our $control_if = "";
our %interfaces = ();
sub setup_interfaces {
$control_if = `cat $PATH_CONTROL_IF`;
chomp($control_if);
foreach my $link (@{ $hostmap{$hostname}->links }) {
$interfaces{lc($link->mac)} = 1;
my $foo = $link->mac;
}
}
sub get_iflist {
my $raw = `/sbin/ifconfig -a`;
my @result = split("\n\n", $raw);
return \@result;
}
sub gather_stats {
my @result = ();
my @iflist = @{ &get_iflist() };
foreach my $ifline (@iflist) {
if ($ifline =~ /^(\w+)\W.*RX packets:([0-9]+) /) {
if ($1 ne $control_if) {
push(@result, $2);
}
}
}
return \@result;
}
sub check_stats {
my @first = @{ $_[0] };
my @second = @{ $_[1] };
my $result = 0;
if (scalar(@first) == scalar(@second)) {
$result = 1;
for (my $i = 0; $i < scalar(@first); ++$i) {
if ($first[$i] != $second[$i]) {
$result = 0;
last;
}
}
}
return $result;
}
sub arpping {
my @iflist = @{ &get_iflist() };
foreach my $ifline (@iflist) {
if ($ifline =~ /^(\w+)\W.*HWaddr ([0-9a-fA-F:]+)/) {
my $ifname = $1;
my $mac = lc(join('', split(':', $2)));
if (! exists($interfaces{$mac}) && $ifname ne $control_if) {
my $command
= "sudo /sbin/ifconfig $ifname up; ".
"sudo /sbin/arping -c 1 -w 1 -I $ifname 10.0.0.1; ".
"sudo /sbin/ifconfig $ifname down";
# print($command."\n");
system($command);
}
}
}
}
sub modify_interfaces {
my ($speed, $duplex) = @_;
my @iflist = @{ &get_iflist() };
foreach my $ifline (@iflist) {
if ($ifline =~ /^(\w+)\W.*HWaddr ([0-9a-fA-F:]+)/) {
my $ifname = $1;
my $mac = lc(join('', split(':', $2)));
if (! exists($interfaces{$mac}) && $ifname ne $control_if) {
my $command = "sudo /sbin/ethtool -s $ifname speed $speed ".
"duplex $duplex autoneg off";
# print($command."\n");
system($command);
}
}
}
}
sub unlink_test {
my @speeds = ('10', '100', '1000');
my @duplexes = ('half', 'full');
&setup_interfaces();
my $start = &gather_stats();
&barrier();
&arpping();
foreach my $speed (@speeds) {
foreach my $duplex (@duplexes) {
&modify_interfaces($speed, $duplex);
&arpping();
}
}
&barrier();
my $end = &gather_stats();
if (! &check_stats($start, $end)) {
&error(NAME_UNLINK, undef,
"Some interfaces received packets");
}
}
##############################################################################
# Loss Test Functions
......
sudo perl -w -T /proj/tbres/duerig/src/event/linktest/linktest.pl STARTAT=1 STOPAT=$1 DOARP=0 LOGDIR=$4 BINDIR=$2 VARDIR=$3 STANDALONE=1
sudo perl -w -T $2/linktest.pl STARTAT=1 STOPAT=$1 DOARP=0 LOGDIR=$4 BINDIR=$2 VARDIR=$3 STANDALONE=1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment