test/bluez-inq.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_inq
       
    18 net::default_num_nodes 2
       
    19 
       
    20 dtn::config 
       
    21 
       
    22 set inq "oasys/test/bluez-inq-test"
       
    23 if [file exists $inq] {
       
    24 manifest::file $inq inq
       
    25 } else {
       
    26     puts "Failed to stat $inq"
       
    27     exit -1
       
    28 }
       
    29 
       
    30 test::script {
       
    31     
       
    32     # XXX/wilson fix this, don't assume hci0!!
       
    33     testlog "Testing whether each node is set discoverable by Bluetooth Inquiry"
       
    34     bluez::discoverable *
       
    35 
       
    36     foreach id [net::nodelist] {
       
    37         if {$bluez::iscan($id)==0} {
       
    38             testlog "Node $id is not set discoverable, quitting"
       
    39             exit
       
    40         } else {
       
    41             testlog "ISCAN is set on node $id"
       
    42             set other [expr 1 - $id]
       
    43             testlog "Attempting inquiry from node $other"
       
    44             set bdaddr [bluez::inquire $other]
       
    45             testlog "Discovered: [join $bdaddr]"
       
    46         }
       
    47     }
       
    48 
       
    49     testlog "Executing oasys::BluetoothInquiry unit test on node 0"
       
    50     dtn::run_app_and_wait 0 inq
       
    51 
       
    52     testlog "Executing oasys::BluetoothInquiry unit test on node 1"
       
    53     dtn::run_app_and_wait 1 inq
       
    54 
       
    55     testlog "Test success!"
       
    56 }
       
    57 
       
    58 test::exit_script {
       
    59     testlog "Cleaning up"
       
    60 }