test/init.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #
       
     2 #    Copyright 2007 Intel Corporation
       
     3 # 
       
     4 #    Licensed under the Apache License, Version 2.0 (the "License");
       
     5 #    you may not use this file except in compliance with the License.
       
     6 #    You may obtain a copy of the License at
       
     7 # 
       
     8 #        http://www.apache.org/licenses/LICENSE-2.0
       
     9 # 
       
    10 #    Unless required by applicable law or agreed to in writing, software
       
    11 #    distributed under the License is distributed on an "AS IS" BASIS,
       
    12 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    13 #    See the License for the specific language governing permissions and
       
    14 #    limitations under the License.
       
    15 #
       
    16 
       
    17 test::name init
       
    18 net::default_num_nodes 2
       
    19 
       
    20 set topology    linear
       
    21 set router      static
       
    22 set link_type   alwayson
       
    23 set clayer      tcp
       
    24 set segmentlen  0
       
    25 set prevhop_hdr 0
       
    26 
       
    27 foreach {var val} $opt(opts) {
       
    28     if {0} {
       
    29     } elseif {$var == "-topology" || $var == "topology"} {
       
    30 	set topology $val
       
    31     } elseif {$var == "-router" || $var == "router"} {
       
    32 	set router $val
       
    33     } elseif {$var == "-linktype" || $var == "linktype"} {
       
    34 	set link_type $val
       
    35     } elseif {$var == "-cl" || $var == "cl"} {
       
    36 	set clayer $val
       
    37     } elseif {$var == "-segmentlen" || $var == "segmentlen"} {
       
    38         set segmentlen $val	
       
    39     } elseif {$var == "-prevhop_hdr" || $var == "prevhop_hdr"} {
       
    40         set prevhop_hdr 1
       
    41     } else {
       
    42 	testlog error "ERROR: unrecognized test option '$var'"
       
    43 	exit 1
       
    44     }
       
    45 }
       
    46 
       
    47 testlog "Initializing with $router router"
       
    48 dtn::config -router_type $router
       
    49 
       
    50 testlog "Configuring $clayer interfaces / links"
       
    51 dtn::config_interface $clayer
       
    52 
       
    53 set linkopts ""
       
    54 if {$segmentlen != 0} {
       
    55     append linkopts "segment_length=$segmentlen "
       
    56 }
       
    57 
       
    58 if {$prevhop_hdr} {
       
    59     append linkopts "prevhop_hdr=1 "
       
    60 }
       
    61 
       
    62 set withroutes false
       
    63 if {$router == "static"} {
       
    64     set withroutes true
       
    65 }
       
    66 
       
    67 dtn::config_${topology}_topology $link_type $clayer $withroutes $linkopts
       
    68 
       
    69 test::script {
       
    70     testlog "Running dtnds"
       
    71     dtn::run_dtnd *
       
    72 
       
    73     testlog "Waiting for dtnds to start up"
       
    74     dtn::wait_for_dtnd *
       
    75 
       
    76     testlog "Setting up registrations"
       
    77     foreach node [net::nodelist] {
       
    78         dtn::tell_dtnd $node tcl_registration dtn://$node/test
       
    79     }
       
    80 
       
    81     testlog "Test initialization complete"
       
    82 }
       
    83 
       
    84 test::exit_script {
       
    85     testlog "Stopping all dtnds"
       
    86     dtn::stop_dtnd *
       
    87 }