17
17
Author: Przemyslaw Wirkus <[email protected] >
18
18
"""
19
19
20
+ from __future__ import print_function
20
21
from multiprocessing import freeze_support
21
22
from mbed_os_tools .test import init_host_test_cli_params
22
23
from mbed_os_tools .test .host_tests_runner .host_test_default import DefaultTestSelector
24
+ from mbed_os_tools .test .host_tests_toolbox .host_functional import handle_send_break_cmd
23
25
24
26
25
27
def main ():
@@ -28,18 +30,33 @@ def main():
28
30
2. Call default test execution function run() to start test instrumentation
29
31
"""
30
32
freeze_support ()
31
- result = 1
32
- test_selector = DefaultTestSelector (init_host_test_cli_params ())
33
- try :
34
- result = test_selector .execute ()
35
- except (KeyboardInterrupt , SystemExit ):
36
- test_selector .finish ()
37
- raise
33
+ result = 0
34
+ cli_params = init_host_test_cli_params ()
35
+
36
+ if cli_params .version : # --version
37
+ import pkg_resources # part of setuptools
38
+ version = pkg_resources .require ("mbed-host-tests" )[0 ].version
39
+ print (version )
40
+ elif cli_params .send_break_cmd : # -b with -p PORT (and optional -r RESET_TYPE)
41
+ handle_send_break_cmd (
42
+ port = cli_params .port ,
43
+ disk = cli_params .disk ,
44
+ reset_type = cli_params .forced_reset_type ,
45
+ baudrate = cli_params .baud_rate ,
46
+ verbose = cli_params .verbose
47
+ )
38
48
else :
39
- test_selector .finish ()
40
-
41
- # Ensure we don't return a negative value
42
- if result < 0 or result > 255 :
43
- result = 1
49
+ test_selector = DefaultTestSelector (cli_params )
50
+ try :
51
+ result = test_selector .execute ()
52
+ # Ensure we don't return a negative value
53
+ if result < 0 or result > 255 :
54
+ result = 1
55
+ except (KeyboardInterrupt , SystemExit ):
56
+ test_selector .finish ()
57
+ result = 1
58
+ raise
59
+ else :
60
+ test_selector .finish ()
44
61
45
62
return result
0 commit comments