forked from auto-pts/auto-pts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
autoptsclient-aospbluez.py
executable file
·90 lines (65 loc) · 2.55 KB
/
autoptsclient-aospbluez.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
#!/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.
#
"""AOSP BlueZ auto PTS client"""
import os
import sys
import argparse
import autoptsclient_common as autoptsclient
import ptsprojects.aospbluez as autoprojects
def parse_args():
"""Parses command line arguments and options"""
arg_parser = argparse.ArgumentParser(
description="PTS automation client")
arg_parser.add_argument("server_address",
help="IP address of the PTS automation server")
arg_parser.add_argument("workspace",
help=("Path to PTS workspace file to use for "
"testing. It should have pqw6 extension. "
"The file should be located on the "
"Windows machine, where the PTS "
"automation server is running"))
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()
proxy = autoptsclient.init_core(args.server_address, args.workspace)
test_cases = autoprojects.rfcomm.test_cases(proxy)
# test_cases = autoprojects.l2cap.test_cases(proxy)
# test_cases = autoprojects.gap.test_cases(proxy)
autoprojects.iutctl.init()
autoptsclient.run_test_cases(proxy, test_cases)
autoprojects.iutctl.cleanup()
print "\nBye!"
sys.stdout.flush()
proxy.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 BaseException:
import traceback
traceback.print_exc()
os._exit(16)