Skip to content

Commit 1c9c5f0

Browse files
committed
Move htrun implementation to mbed_os_tools
1 parent 7985f2b commit 1c9c5f0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+136
-4420
lines changed

legacy/mbed-host-tests/mbed_host_tests/__init__.py

Lines changed: 9 additions & 232 deletions
Original file line numberDiff line numberDiff line change
@@ -25,235 +25,12 @@
2525
2626
"""
2727

28-
29-
import os
30-
import imp
31-
import inspect
32-
from os import listdir
33-
from os.path import isfile, join, abspath, basename
34-
import sys
35-
from optparse import OptionParser
36-
from optparse import SUPPRESS_HELP
37-
from mbed_host_tests import host_tests_plugins
38-
from mbed_host_tests.host_tests_registry import HostRegistry
39-
from mbed_host_tests.host_tests import BaseHostTest, event_callback
40-
41-
42-
# Set the default baud rate
43-
DEFAULT_BAUD_RATE = 9600
44-
45-
###############################################################################
46-
# Functional interface for test supervisor registry
47-
###############################################################################
48-
49-
50-
def get_plugin_caps(methods=None):
51-
if not methods:
52-
methods = ['CopyMethod', 'ResetMethod']
53-
result = {}
54-
for method in methods:
55-
result[method] = host_tests_plugins.get_plugin_caps(method)
56-
return result
57-
58-
59-
def init_host_test_cli_params():
60-
"""! Function creates CLI parser object and returns populated options object.
61-
@return Function returns 'options' object returned from OptionParser class
62-
@details Options object later can be used to populate host test selector script.
63-
"""
64-
parser = OptionParser()
65-
66-
parser.add_option("-m", "--micro",
67-
dest="micro",
68-
help="Target microcontroller name",
69-
metavar="MICRO")
70-
71-
parser.add_option("-p", "--port",
72-
dest="port",
73-
help="Serial port of the target",
74-
metavar="PORT")
75-
76-
parser.add_option("-d", "--disk",
77-
dest="disk",
78-
help="Target disk (mount point) path",
79-
metavar="DISK_PATH")
80-
81-
parser.add_option("-t", "--target-id",
82-
dest="target_id",
83-
help="Unique Target Id or mbed platform",
84-
metavar="TARGET_ID")
85-
86-
parser.add_option("", "--sync",
87-
dest="sync_behavior",
88-
default=2,
89-
type=int,
90-
help="Define how many times __sync packet will be sent to device: 0: none; -1: forever; 1,2,3... - number of times (Default 2 time)",
91-
metavar="SYNC_BEHAVIOR")
92-
93-
parser.add_option("", "--sync-timeout",
94-
dest="sync_timeout",
95-
default=5,
96-
type=int,
97-
help="Define delay in seconds between __sync packet (Default is 5 seconds)",
98-
metavar="SYNC_TIMEOUT")
99-
100-
parser.add_option("-f", "--image-path",
101-
dest="image_path",
102-
help="Path with target's binary image",
103-
metavar="IMAGE_PATH")
104-
105-
copy_methods_str = "Plugin support: " + ', '.join(host_tests_plugins.get_plugin_caps('CopyMethod'))
106-
107-
parser.add_option("-c", "--copy",
108-
dest="copy_method",
109-
help="Copy (flash the target) method selector. " + copy_methods_str,
110-
metavar="COPY_METHOD")
111-
112-
parser.add_option("", "--retry-copy",
113-
dest="retry_copy",
114-
default=3,
115-
type=int,
116-
help="Number of attempts to flash the target",
117-
metavar="RETRY_COPY")
118-
119-
parser.add_option("", "--tag-filters",
120-
dest="tag_filters",
121-
default="",
122-
type=str,
123-
help="Comma seperated list of device tags used when allocating a target to specify required hardware or attributes [--tag-filters tag1,tag2]",
124-
metavar="TAG_FILTERS")
125-
126-
reset_methods_str = "Plugin support: " + ', '.join(host_tests_plugins.get_plugin_caps('ResetMethod'))
127-
128-
parser.add_option("-r", "--reset",
129-
dest="forced_reset_type",
130-
help="Forces different type of reset. " + reset_methods_str)
131-
132-
parser.add_option("-C", "--program_cycle_s",
133-
dest="program_cycle_s",
134-
default=4,
135-
help="Program cycle sleep. Define how many seconds you want wait after copying binary onto target (Default is 4 second)",
136-
type="float",
137-
metavar="PROGRAM_CYCLE_S")
138-
139-
parser.add_option("-R", "--reset-timeout",
140-
dest="forced_reset_timeout",
141-
default=1,
142-
metavar="NUMBER",
143-
type="float",
144-
help="When forcing a reset using option -r you can set up after reset idle delay in seconds (Default is 1 second)")
145-
146-
parser.add_option("--process-start-timeout",
147-
dest="process_start_timeout",
148-
default=60,
149-
metavar="NUMBER",
150-
type="float",
151-
help="This sets the maximum time in seconds to wait for an internal process to start. This mostly only affects machines under heavy load (Default is 60 seconds)")
152-
153-
parser.add_option("-e", "--enum-host-tests",
154-
dest="enum_host_tests",
155-
action="append",
156-
default=["./test/host_tests"],
157-
help="Define directory with local host tests")
158-
159-
parser.add_option('', '--test-cfg',
160-
dest='json_test_configuration',
161-
help='Pass to host test class data about host test configuration')
162-
163-
parser.add_option('', '--list',
164-
dest='list_reg_hts',
165-
default=False,
166-
action="store_true",
167-
help='Prints registered host test and exits')
168-
169-
parser.add_option('', '--plugins',
170-
dest='list_plugins',
171-
default=False,
172-
action="store_true",
173-
help='Prints registered plugins and exits')
174-
175-
parser.add_option('-g', '--grm',
176-
dest='global_resource_mgr',
177-
help='[Experimental] Global resource manager service module name, IP and port, example remote_client:10.2.123.43:3334')
178-
179-
# Show --fm option only if "fm_agent" module installed
180-
try:
181-
imp.find_module('fm_agent')
182-
except ImportError:
183-
fm_help=SUPPRESS_HELP
184-
else:
185-
fm_help='Fast Model connection, This option requires mbed-fastmodel-agent module installed, list CONFIGs via "mbedfm"'
186-
parser.add_option('', '--fm',
187-
dest='fast_model_connection',
188-
metavar="CONFIG",
189-
default=None,
190-
help=fm_help)
191-
192-
parser.add_option('', '--run',
193-
dest='run_binary',
194-
default=False,
195-
action="store_true",
196-
help='Runs binary image on target (workflow: flash, reset, output console)')
197-
198-
parser.add_option('', '--skip-flashing',
199-
dest='skip_flashing',
200-
default=False,
201-
action="store_true",
202-
help='Skips use of copy/flash plugin. Note: target will not be reflashed')
203-
204-
parser.add_option('', '--skip-reset',
205-
dest='skip_reset',
206-
default=False,
207-
action="store_true",
208-
help='Skips use of reset plugin. Note: target will not be reset')
209-
210-
parser.add_option('-P', '--polling-timeout',
211-
dest='polling_timeout',
212-
default=60,
213-
metavar="NUMBER",
214-
type="int",
215-
help='Timeout in sec for readiness of mount point and serial port of local or remote device. Default 60 sec')
216-
217-
parser.add_option('-b', '--send-break',
218-
dest='send_break_cmd',
219-
default=False,
220-
action="store_true",
221-
help='Send reset signal to board on specified port (-p PORT) and print serial output. You can combine this with (-r RESET_TYPE) switch')
222-
223-
parser.add_option('', '--baud-rate',
224-
dest='baud_rate',
225-
help="Baud rate of target, overrides values from mbed-ls, disk/mount point (-d, --disk-path), and serial port -p <port>:<baud rate>",
226-
metavar="BAUD_RATE")
227-
228-
parser.add_option('-v', '--verbose',
229-
dest='verbose',
230-
default=False,
231-
action="store_true",
232-
help='More verbose mode')
233-
234-
parser.add_option('', '--serial-output-file',
235-
dest='serial_output_file',
236-
default=None,
237-
help='Save target serial output to this file.')
238-
239-
parser.add_option('', '--compare-log',
240-
dest='compare_log',
241-
default=None,
242-
help='Log file to compare with the serial output from target.')
243-
244-
parser.add_option('', '--version',
245-
dest='version',
246-
default=False,
247-
action="store_true",
248-
help='Prints package version and exits')
249-
250-
parser.description = """Flash, reset and perform host supervised tests on mbed platforms"""
251-
parser.epilog = """Example: mbedhtrun -d E: -p COM5 -f "test.bin" -C 4 -c shell -m K64F"""
252-
253-
(options, _) = parser.parse_args()
254-
255-
if len(sys.argv) == 1:
256-
parser.print_help()
257-
sys.exit()
258-
259-
return options
28+
from mbed_os_tools.test import (
29+
host_tests_plugins,
30+
HostRegistry,
31+
BaseHostTest,
32+
event_callback,
33+
DEFAULT_BAUD_RATE,
34+
get_plugin_caps,
35+
init_host_test_cli_params,
36+
)

0 commit comments

Comments
 (0)