forked from auto-pts/auto-pts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoptsclient-bluez.py
executable file
·99 lines (69 loc) · 2.59 KB
/
autoptsclient-bluez.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env python
#
# auto-pts - The Bluetooth PTS Automation Framework
#
# Copyright (c) 2017, Intel Corporation.
#
# This program is free software; you can redistribute it and/or modify it
# under the terms and conditions of the GNU General Public License,
# version 2, as published by the Free Software Foundation.
#
# This program is distributed in the hope it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
"""Bluez auto PTS client"""
import os
import sys
from distutils.spawn import find_executable
import autoptsclient_common as autoptsclient
import ptsprojects.bluez as autoprojects
import ptsprojects.stack as stack
from pybtp import btp
from ptsprojects.bluez.iutctl import get_iut
def parse_args():
"""Parses command line arguments and options"""
arg_parser = autoptsclient.CliParser(description="PTS automation client")
arg_parser.add_argument("btpclient_path",
help="Path to Bluez tool btpclient")
# IUT specific arguments below
args = arg_parser.parse_args()
return args
def main():
"""Main."""
if os.geteuid() == 0: # root privileges are not needed
sys.exit("Please do not run this program as root.")
args = parse_args()
callback_thread = autoptsclient.init_core()
ptses = autoptsclient.init_pts(args, callback_thread)
btp.init(get_iut)
autoprojects.iutctl.AUTO_PTS_LOCAL = autoptsclient.AUTO_PTS_LOCAL
autoprojects.iutctl.init(args.btpclient_path)
stack.init_stack()
stack_inst = stack.get_stack()
stack_inst.synch_init(callback_thread.set_pending_response,
callback_thread.clear_pending_responses)
test_cases = autoprojects.gap.test_cases(ptses[0])
test_cases += autoprojects.sm.test_cases(ptses[0])
autoptsclient.run_test_cases(ptses, test_cases, args)
autoprojects.iutctl.cleanup()
print "\nBye!"
sys.stdout.flush()
for pts in ptses:
pts.unregister_xmlrpc_ptscallback()
# not the cleanest but the easiest way to exit the server thread
os._exit(0)
if __name__ == "__main__":
# os._exit: not the cleanest but the easiest way to exit the server thread
try:
main()
except KeyboardInterrupt: # Ctrl-C
os._exit(14)
# SystemExit is thrown in arg_parser.parse_args and in sys.exit
except SystemExit:
raise # let the default handlers do the work
except Exception:
import traceback
traceback.print_exc()
os._exit(16)