test/api-leak-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 api-leak-test
       
    18 net::num_nodes 1
       
    19 
       
    20 manifest::file apps/dtntest/dtntest dtntest
       
    21 manifest::file Rules.make test-payload.dat
       
    22 
       
    23 dtn::config
       
    24 dtn::config_topology_common false
       
    25 
       
    26 set count 10000
       
    27 foreach {var val} $opt(opts) {
       
    28     if {$var == "-count" || $var == "count"} {
       
    29         set count $val
       
    30     }
       
    31 }
       
    32 
       
    33 test::script {
       
    34     testlog "Running dtnd and dtntest"
       
    35     dtn::run_dtnd 0
       
    36     dtn::run_dtntest 0
       
    37 
       
    38     testlog "Waiting for dtnd and dtntest to start up"
       
    39     dtn::wait_for_dtnd 0
       
    40     dtn::wait_for_dtntest 0
       
    41 
       
    42     testlog "Creating / removing $count dtn handles"
       
    43     for {set i 0} {$i < $count} {incr i} {
       
    44 	set id [dtn::tell_dtntest 0 dtn_open]
       
    45 	dtn::tell_dtntest 0 dtn_close $id
       
    46     }
       
    47 
       
    48     testlog "Creating one more handle"
       
    49     set h [dtn::tell_dtntest 0 dtn_open]
       
    50 
       
    51     testlog "Creating / removing $count registrations and bindings"
       
    52     for {set i 0} {$i < $count} {incr i} {
       
    53 	set regid [dtn::tell_dtntest 0 dtn_register $h \
       
    54 		endpoint=dtn://test expiration=100 init_passive=true]
       
    55 	dtn::tell_dtntest 0 dtn_bind $h $regid
       
    56 	dtn::tell_dtntest 0 dtn_unbind $h $regid
       
    57 	dtn::tell_dtntest 0 dtn_unregister $h $regid
       
    58     }
       
    59 
       
    60     testlog "Creating / removing a registration with an eval script"
       
    61     set regid [dtn::tell_dtntest 0 dtn_register $h \
       
    62 	    endpoint=dtn://dest expiration=100 script="/tmp/foobar"]
       
    63     dtn::tell_dtntest 0 dtn_unregister $h $regid
       
    64     dtn::tell_dtntest 0 dtn_unbind $h $regid
       
    65     dtn::tell_dtntest 0 dtn_unregister $h $regid
       
    66     
       
    67     testlog "Creating one more registration for source and dest"
       
    68     set regid0 [dtn::tell_dtntest 0 dtn_register $h \
       
    69 	    endpoint=dtn://source expiration=100]
       
    70     set regid1 [dtn::tell_dtntest 0 dtn_register $h \
       
    71 	    endpoint=dtn://dest expiration=100]
       
    72     
       
    73     testlog "Sending / receiving $count bundles from memory"
       
    74     for {set i 0} {$i < $count} {incr i} {
       
    75 	dtn::tell_dtntest 0 dtn_send $h source=dtn://source dest=dtn://dest \
       
    76 		expiration=10 payload_data=this_is_some_test_payload_data
       
    77 	dtn::tell_dtntest 0 dtn_recv $h payload_mem=true timeout=10000
       
    78     }
       
    79     
       
    80     testlog "Sending / receiving $count bundles from files"
       
    81     for {set i 0} {$i < $count} {incr i} {
       
    82 	dtn::tell_dtntest 0 dtn_send $h source=dtn://source dest=dtn://dest \
       
    83 		expiration=10 payload_file=test-payload.dat
       
    84 	dtn::tell_dtntest 0 dtn_recv $h payload_file=true timeout=10000
       
    85     }
       
    86     
       
    87     testlog "Checking that all bundles were delivered"
       
    88     dtn::wait_for_bundle_stat 0 0 pending
       
    89     dtn::wait_for_bundle_stat 0 [expr $count * 2] delivered
       
    90     
       
    91     testlog "Test success!"
       
    92 }
       
    93 
       
    94 test::exit_script {
       
    95     testlog "Stopping dtnd and dtntest"
       
    96     dtn::tell_dtntest 0 dtn_close $h
       
    97     dtn::stop_dtntest 0
       
    98     dtn::stop_dtnd 0
       
    99 }