sc 1.55 KB
Newer Older
Kevin Tew's avatar
Kevin Tew committed
1 2
#!/usr/bin/perl
use lib 'lib';
3
use SemiModern::Perl;
4
use TBConfig;
5
use TestBed::TestSuite;
6
use TestBed::XMLRPC::Client::Pretty;
7
use TestBed::TestSuite::Experiment::Macros;
Kevin Tew's avatar
Kevin Tew committed
8
use Data::Dumper;
9
use Tools;
Kevin Tew's avatar
Kevin Tew committed
10
use TestBed::Wrap::tevc;
Kevin Tew's avatar
Kevin Tew committed
11 12 13 14 15 16 17 18 19 20

my $ns = <<'NSEND';
source tb_compat.tcl

set ns [new Simulator]

set node1 [$ns node]
set node2 [$ns node]

set lan1 [$ns make-lan "$node1 $node2" 100Mb 0ms]
Kevin Tew's avatar
Kevin Tew committed
21
set link1 [$ns duplex-link $node1 $node2 100Mb 50ms DropTail]
Kevin Tew's avatar
Kevin Tew committed
22 23 24
$ns run
NSEND

Kevin Tew's avatar
Kevin Tew committed
25 26
sub usage {
say <<"END"
27
ShortCut
28 29 30 31 32 33 34
./sc CMD EID ARGS

  CMD = start
        swapin
        swapout
        end
        ping
35 36 37
        tevc
        linktest
        single_node_tests
38 39
        ni    // nodeinfo
        li    // linkinfo
Kevin Tew's avatar
Kevin Tew committed
40
END
Kevin Tew's avatar
Kevin Tew committed
41
}
Kevin Tew's avatar
Kevin Tew committed
42

43 44 45 46 47 48 49 50
sub end_all_experiments {
  plistexps;
  say "";
  if (yn_prompt("Are you sure you want to terminate all experiments?")) {
    e(@{$_->[0]})->end for( experiments_hash_to_list(list_full));
  }
}

51
if (@ARGV) {
52
  $_ = shift;
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69
  if (/endall/) { end_all_experiments; }
  elsif (/end/) { e($_)->end for(@ARGV); }
  else {
    my $e = e(shift);
    if (/--help/) { usage; } 
    elsif (/end/) { $e->end(); }
    elsif (/ping/ ) { $e->ping_test; }
    elsif (/swapin/) { $e->swapin_wait; }
    elsif (/swapout/) { $e->swapout_wait; }
    elsif (/start/) { $e->startexp_ns_wait($ns); }
    elsif (/tevc/) { $e->tevc(@ARGV); }
    elsif (/linktest/) { $e->linktest; }
    elsif (/single_node_tests/) { $e->single_node_tests; }
    elsif (/ni/) { say Dumper($e->nodeinfo) ;}
    elsif (/li/) { say Dumper($e->linkinfo) ;}
    else { 
    }
70
  }
71 72
}
else {
Kevin Tew's avatar
Kevin Tew committed
73 74
  usage;
  plistexps;
Kevin Tew's avatar
Kevin Tew committed
75 76 77
}

# vim: ft=perl: