1717Author: Przemyslaw Wirkus <[email protected] > 1818"""
1919
20+ from __future__ import print_function
2021from multiprocessing import freeze_support
2122from mbed_os_tools .test import init_host_test_cli_params
2223from 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
2325
2426
2527def main ():
@@ -28,18 +30,33 @@ def main():
2830 2. Call default test execution function run() to start test instrumentation
2931 """
3032 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+ )
3848 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 ()
4461
4562 return result
0 commit comments