diff options
author | Waldemar Rymarkiewicz <waldemar.rymarkiewicz@tieto.com> | 2011-03-24 14:33:01 +0100 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@nokia.com> | 2011-03-25 11:13:08 +0200 |
commit | 883ef406d60e3be6d4ae9ef8e29e17ecf49b6be2 (patch) | |
tree | 6562487fe9af6d9e34d6bed8429807e5d3b57cde /test/test-sap-server | |
parent | d3f69537a46b1050d2415ca4afcdedba967096e8 (diff) | |
download | bluez-883ef406d60e3be6d4ae9ef8e29e17ecf49b6be2.tar.gz |
Sim Access Profile test scripts
Add simple SAP client python implementation and a test script.
To run test-sap-server you need Python 2.6 or newer (tested with 2.6 only)
and PyBluez package installed.
Diffstat (limited to 'test/test-sap-server')
-rwxr-xr-x | test/test-sap-server | 138 |
1 files changed, 138 insertions, 0 deletions
diff --git a/test/test-sap-server b/test/test-sap-server new file mode 100755 index 000000000..bea6ca948 --- /dev/null +++ b/test/test-sap-server @@ -0,0 +1,138 @@ +#!/usr/bin/python + +from sap import * +import time + +def connect_disconnect_by_client(sap): + + print "[Test] Connect - Disconnect by client \n" + + try: + if not sap.isConnected(): + sap.connect() + + if sap.proc_connect(): + if sap.proc_disconnectByClient(): + print "OK" + return 0 + + print "NOT OK" + return 1 + + except BluetoothError , e: + print "Error " + str(e) + + +def connect_disconnect_by_server_gracefully(sap, timeout=0): + + print "[Test] Connect - Disconnect by server with timer \n" + + try: + if not sap.isConnected(): + sap.connect() + + if sap.proc_connect(): + if sap.proc_disconnectByServer(timeout): + print "OK" + return 0 + + print "NOT OK" + return 1 + + except BluetoothError , e: + print "Error " + str(e) + + +def connect_txAPDU_disconnect_by_client(sap): + + print "[Test] Connect - TX APDU - Disconnect by client \n" + + try: + if not sap.isConnected(): + sap.connect() + + if sap.proc_connect(): + if not sap.proc_transferAPDU(): + print "NOT OK 1" + return 1 + + if not sap.proc_transferAPDU(): + print "NOT OK 2" + return 1 + + if not sap.proc_transferAPDU(): + print "NOT OK 3" + return 1 + + if not sap.proc_transferAPDU(): + print "NOT OK 4" + return 1 + + if sap.proc_disconnectByClient(): + print "OK" + return 0 + + print "NOT OK" + return 1 + + except BluetoothError , e: + print "Error " + str(e) + +def connect_rfcomm_only_and_wait_for_close_by_server(sap): + + print "[Test] Connect rfcomm only - Disconnect by server timeout \n" + + if not sap.isConnected(): + sap.connect() + + time.sleep(40) + print "OK" + +def power_sim_off_on(sap): + + print "[Test] Powe sim off \n" + + try: + if not sap.isConnected(): + sap.connect() + + if sap.proc_connect(): + if not sap.proc_resetSim(): + print "NOT OK" + return 1 + + if not sap.proc_powerSimOff(): + print "NOT OK" + return 1 + + if not sap.proc_powerSimOn(): + print "NOT OK" + return 1 + + if sap.proc_disconnectByClient(): + print "OK" + return 0 + + print "NOT OK" + return 1 + + except BluetoothError , e: + print "Error " + str(e) + + +if __name__ == "__main__": + + host = "00:00:00:00:00:0" # server bd_addr + port = 8 # sap server port + + try: + s = SAPClient(host, port) + except BluetoothError , e: + print "Error " + str(e) + + connect_disconnect_by_client(s) + connect_disconnect_by_server_gracefully(s) + connect_disconnect_by_server_gracefully(s, 40) # wait 40 sec for srv to close rfcomm sock + connect_rfcomm_only_and_wait_for_close_by_server(s) + connect_txAPDU_disconnect_by_client(s) + power_sim_off_on(s) |