test/bluez-sdp.tcl
changeset 0 2b3e5ec03512
equal deleted inserted replaced
-1:000000000000 0:2b3e5ec03512
       
     1 #
       
     2 #    Copyright 2007 Baylor University
       
     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 bluez_sdp
       
    18 net::default_num_nodes 2
       
    19 # sdp-reg-test's default is 30
       
    20 set reg_sleep_seconds 30
       
    21 
       
    22 dtn::config 
       
    23 
       
    24 # query must have arg "remote=$bdaddr"
       
    25 set query "oasys/test/sdp-query-test"
       
    26 if [file exists $query] {
       
    27 manifest::file $query query
       
    28 } else {
       
    29     puts "Failed to stat $query"
       
    30     exit -1
       
    31 }
       
    32 # reg needs no args
       
    33 set reg "oasys/test/sdp-reg-test"
       
    34 if [file exists $reg] {
       
    35 manifest::file $reg reg
       
    36 } else {
       
    37     puts "Failed to stat $reg"
       
    38     exit -1
       
    39 }
       
    40 
       
    41 test::script {
       
    42     
       
    43     testlog "Reading Bluetooth adapter addresses from each node"
       
    44     bluez::getbdaddr *
       
    45 
       
    46     testlog "Execute SDP registration test on node 0"
       
    47     set regpid [dtn::run_app 0 reg sleep=$reg_sleep_seconds]
       
    48 
       
    49     testlog "Query SDP from node 1 (using BlueZ sdptool)"
       
    50     set i 0
       
    51     foreach svc [bluez::sdpquery 1 0] {
       
    52         testlog "Found registration for \"$svc\""
       
    53         incr i
       
    54     }
       
    55     testlog "Found $i registrations using sdptool"
       
    56 
       
    57     testlog "Execute SDP query test on node 1"
       
    58     dtn::run_app_and_wait 1 query "remote=$bluez::btaddr(0)"
       
    59 
       
    60     testlog "Waiting for SDP registration to expire"
       
    61     # wait_for_pid_exit's default timeout is 30 
       
    62     run::wait_for_pid_exit 0 $regpid
       
    63 
       
    64     testlog "Test success!"
       
    65 }
       
    66 
       
    67 test::exit_script {
       
    68     testlog "Cleaning up"
       
    69 }