test/ipc-version-test.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #
       
     2 #    Copyright 2006 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 ipc-version-test
       
    18 net::num_nodes 1
       
    19 
       
    20 manifest::file apps/dtntest/dtntest dtntest
       
    21 
       
    22 dtn::config
       
    23 dtn::config_topology_common false
       
    24 
       
    25 set version 54321
       
    26 foreach {var val} $opt(opts) {
       
    27     if {$var == "-version" || $var == "version"} {
       
    28         set version $val
       
    29     }
       
    30 }
       
    31 
       
    32 test::script {
       
    33     testlog "Running dtnd and dtntest"
       
    34     dtn::run_dtnd 0
       
    35     dtn::run_dtntest 0
       
    36 
       
    37     testlog "Waiting for dtnd and dtntest to start up"
       
    38     dtn::wait_for_dtnd 0
       
    39     dtn::wait_for_dtntest 0
       
    40 
       
    41     testlog "Doing a dtn_open with default version (should work)"
       
    42     set id [dtn::tell_dtntest 0 dtn_open]
       
    43     testlog "dtn_open succeeded"
       
    44     dtn::tell_dtntest 0 dtn_close $id
       
    45     testlog "dtn_close succeeded"
       
    46 
       
    47     testlog "Setting up flamebox-ignore"
       
    48     dtn::tell_dtnd 0 log /test always \
       
    49 	"flamebox-ignore ign1 handshake .*s version \[0-9\]* != DTN_IPC_VERSION"
       
    50     
       
    51     testlog "Doing a dtn_open with version=$version (should fail)"
       
    52     if { [catch \
       
    53 	  {set id [dtn::tell_dtntest 0 dtn_open version=$version]} \
       
    54 	  errorstr] } {
       
    55 	testlog "  and it did!"
       
    56     } else {
       
    57 	dtn::tell_dtntest 0 dtn_close $id
       
    58 	error "dtn_open did not fail as expected despite IPC version mismatch"
       
    59     }
       
    60     
       
    61     testlog "Test success!"
       
    62 }
       
    63 
       
    64 test::exit_script {
       
    65     testlog "clearing flamebox ignores"
       
    66     tell_dtnd 0 log /test always "flamebox-ignore-cancel ign1"
       
    67     
       
    68     testlog "Stopping dtnd and dtntest"
       
    69     dtn::stop_dtnd 0
       
    70     dtn::stop_dtntest 0
       
    71 }