test-utils/run-dtn.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #!/usr/bin/tclsh
       
     2 
       
     3 #
       
     4 #    Copyright 2005-2006 Intel Corporation
       
     5 # 
       
     6 #    Licensed under the Apache License, Version 2.0 (the "License");
       
     7 #    you may not use this file except in compliance with the License.
       
     8 #    You may obtain a copy of the License at
       
     9 # 
       
    10 #        http://www.apache.org/licenses/LICENSE-2.0
       
    11 # 
       
    12 #    Unless required by applicable law or agreed to in writing, software
       
    13 #    distributed under the License is distributed on an "AS IS" BASIS,
       
    14 #    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
       
    15 #    See the License for the specific language governing permissions and
       
    16 #    limitations under the License.
       
    17 #
       
    18 
       
    19 
       
    20 
       
    21 #
       
    22 # Before the import, snarf out the base test dir option so we can
       
    23 # properly set up the import path
       
    24 #
       
    25 set base_test_dir [pwd]
       
    26 if {[llength $argv] >= 2} {
       
    27     for {set i 0} {$i < [llength $argv]} {incr i} {
       
    28 	if {[lindex $argv $i] == "--base-test-dir"} {
       
    29 	    set base_test_dir [file normalize [pwd]/[lindex $argv [expr $i + 1]]]
       
    30 	}
       
    31     }
       
    32 }
       
    33 
       
    34 source "$base_test_dir/../test-utils/import.tcl"
       
    35 
       
    36 set import::path [list \
       
    37 	$base_test_dir/../test-utils \
       
    38 	$base_test_dir/../oasys/tclcmd \
       
    39 	$base_test_dir/oasys/tclcmd \
       
    40 	$base_test_dir/test-utils \
       
    41 	$base_test_dir/test/nets \
       
    42 	]
       
    43 
       
    44 import "test-lib.tcl" 
       
    45 import "dtn-test-lib.tcl"
       
    46 
       
    47 if {[llength $argv] < 1} {
       
    48     puts "run-dtn.tcl <init_options> <test script> <options>..."
       
    49     puts ""
       
    50     puts "Required:"
       
    51     puts "    <test script> Test script to run"
       
    52     puts ""
       
    53     run::usage
       
    54 
       
    55     if {[info commands real_exit] != ""} {
       
    56 	real_exit
       
    57     } else {
       
    58 	exit
       
    59     }
       
    60 }
       
    61 
       
    62 # no buffering for stdout
       
    63 fconfigure stdout -buffering none
       
    64 
       
    65 # default args
       
    66 set defaults [list -net localhost --gdb-match dtnd*]
       
    67 set argv [concat $defaults $argv]
       
    68 run::init $argv
       
    69 
       
    70 test::error_script { dtn::dump_stats; dtn::dump_routes }
       
    71 test::run_script
       
    72 if {!$opt(daemon)} {
       
    73     command_loop "dtntest% "
       
    74 }
       
    75 test::run_exit_script
       
    76 run::wait_for_programs
       
    77 run::collect_logs
       
    78 run::cleanup
       
    79 test::run_cleanup_script