Skip to content

Commit 30e5ea8

Browse files
Freey0cfriedt
authored andcommitted
twister: Enhanced device-testing Command Help
Collect device-testing commands into a single location to enhance readability of help information and reduce the time spent locating device-testing options. Signed-off-by: WenBin Zhang <[email protected]>
1 parent d58bc08 commit 30e5ea8

File tree

1 file changed

+59
-58
lines changed

1 file changed

+59
-58
lines changed

scripts/pylib/twister/twisterlib/environment.py

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -171,29 +171,31 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
171171
"--emulation-only", action="store_true",
172172
help="Only build and run emulation platforms")
173173

174-
run_group_option.add_argument(
175-
"--device-testing", action="store_true",
176-
help="Test on device directly. Specify the serial device to "
177-
"use with the --device-serial option.")
178-
179-
run_group_option.add_argument("--generate-hardware-map",
180-
help="""Probe serial devices connected to this platform
181-
and create a hardware map file to be used with
182-
--device-testing
183-
""")
184-
185174
run_group_option.add_argument(
186175
"--simulation", dest="sim_name", choices=SUPPORTED_SIMS,
187176
help="Selects which simulation to use. Must match one of the names defined in the board's "
188177
"manifest. If multiple simulator are specified in the selected board and this "
189178
"argument is not passed, then the first simulator is selected.")
190179

180+
run_group_option.add_argument(
181+
"--device-testing", action="store_true",
182+
help="Test on device directly. Specify the serial device to "
183+
"use with the --device-serial option.")
184+
185+
parser.add_argument("--pre-script",
186+
help="""specify a pre script. This will be executed
187+
before device handler open serial port and invoke runner.
188+
""")
191189

192190
device.add_argument("--device-serial",
193191
help="""Serial device for accessing the board
194192
(e.g., /dev/ttyACM0)
195193
""")
196194

195+
parser.add_argument(
196+
"--device-serial-baud", action="store", default=None,
197+
help="Serial device baud rate (default 115200)")
198+
197199
device.add_argument("--device-serial-pty",
198200
help="""Script for controlling pseudoterminal.
199201
Twister believes that it interacts with a terminal
@@ -203,27 +205,71 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
203205
--device-serial-pty <script>
204206
""")
205207

208+
run_group_option.add_argument("--generate-hardware-map",
209+
help="""Probe serial devices connected to this platform
210+
and create a hardware map file to be used with
211+
--device-testing
212+
""")
213+
206214
device.add_argument("--hardware-map",
207215
help="""Load hardware map from a file. This will be used
208216
for testing on hardware that is listed in the file.
209217
""")
210218

211-
parser.add_argument("--device-flash-timeout", type=int, default=60,
212-
help="""Set timeout for the device flash operation in seconds.
219+
parser.add_argument("--persistent-hardware-map", action='store_true',
220+
help="""With --generate-hardware-map, tries to use
221+
persistent names for serial devices on platforms
222+
that support this feature (currently only Linux).
213223
""")
214224

215225
parser.add_argument("--device-flash-with-test", action="store_true",
216226
help="""Add a test case timeout to the flash operation timeout
217227
when flash operation also executes test case on the platform.
218228
""")
219229

230+
parser.add_argument("--device-flash-timeout", type=int, default=60,
231+
help="""Set timeout for the device flash operation in seconds.
232+
""")
233+
220234
parser.add_argument("--flash-before", action="store_true", default=False,
221235
help="""Flash device before attaching to serial port.
222236
This is useful for devices that share the same port for programming
223237
and serial console, or use soft-USB, where flash must come first.
224238
Also, it skips reading remaining logs from the old image run.
225239
""")
226240

241+
parser.add_argument(
242+
"--flash-command",
243+
help="""Instead of 'west flash', uses a custom flash command to flash
244+
when running with --device-testing. Supports comma-separated
245+
argument list, the script is also passed a --build-dir flag with
246+
the build directory as an argument, and a --board-id flag with the
247+
board or probe id if available.
248+
"""
249+
)
250+
251+
parser.add_argument(
252+
"--west-flash", nargs='?', const=[],
253+
help="""Comma separated list of additional flags passed to west when
254+
running with --device-testing.
255+
256+
E.g "twister --device-testing --device-serial /dev/ttyACM0
257+
--west-flash="--board-id=foobar,--erase"
258+
will translate to "west flash -- --board-id=foobar --erase"
259+
"""
260+
)
261+
262+
parser.add_argument(
263+
"--west-runner",
264+
help="""Uses the specified west runner instead of default when running
265+
with --west-flash.
266+
267+
E.g "twister --device-testing --device-serial /dev/ttyACM0
268+
--west-flash --west-runner=pyocd"
269+
will translate to "west flash --runner pyocd"
270+
"""
271+
)
272+
227273
test_or_build.add_argument(
228274
"-b",
229275
"--build-only",
@@ -419,10 +465,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
419465
help="Test level to be used. By default, no levels are used for filtering "
420466
"and do the selection based on existing filters.")
421467

422-
parser.add_argument(
423-
"--device-serial-baud", action="store", default=None,
424-
help="Serial device baud rate (default 115200)")
425-
426468
parser.add_argument(
427469
"--disable-suite-name-check", action="store_true", default=False,
428470
help="Disable extended test suite name verification at the beginning "
@@ -660,12 +702,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
660702
"""
661703
)
662704

663-
parser.add_argument("--persistent-hardware-map", action='store_true',
664-
help="""With --generate-hardware-map, tries to use
665-
persistent names for serial devices on platforms
666-
that support this feature (currently only Linux).
667-
""")
668-
669705
parser.add_argument(
670706
"--vendor", action="append", default=[],
671707
help="Vendor filter for testing")
@@ -691,11 +727,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
691727
help="""Create individual reports for each platform.
692728
""")
693729

694-
parser.add_argument("--pre-script",
695-
help="""specify a pre script. This will be executed
696-
before device handler open serial port and invoke runner.
697-
""")
698-
699730
parser.add_argument(
700731
"--quarantine-list",
701732
action="append",
@@ -815,36 +846,6 @@ def add_parse_arguments(parser = None) -> argparse.ArgumentParser:
815846
parser.add_argument("-W", "--disable-warnings-as-errors", action="store_true",
816847
help="Do not treat warning conditions as errors.")
817848

818-
parser.add_argument(
819-
"--west-flash", nargs='?', const=[],
820-
help="""Comma separated list of additional flags passed to west when
821-
running with --device-testing.
822-
823-
E.g "twister --device-testing --device-serial /dev/ttyACM0
824-
--west-flash="--board-id=foobar,--erase"
825-
will translate to "west flash -- --board-id=foobar --erase"
826-
"""
827-
)
828-
parser.add_argument(
829-
"--west-runner",
830-
help="""Uses the specified west runner instead of default when running
831-
with --west-flash.
832-
833-
E.g "twister --device-testing --device-serial /dev/ttyACM0
834-
--west-flash --west-runner=pyocd"
835-
will translate to "west flash --runner pyocd"
836-
"""
837-
)
838-
parser.add_argument(
839-
"--flash-command",
840-
help="""Instead of 'west flash', uses a custom flash command to flash
841-
when running with --device-testing. Supports comma-separated
842-
argument list, the script is also passed a --build-dir flag with
843-
the build directory as an argument, and a --board-id flag with the
844-
board or probe id if available.
845-
"""
846-
)
847-
848849
parser.add_argument(
849850
"-X", "--fixture", action="append", default=[],
850851
help="Specify a fixture that a board might support.")

0 commit comments

Comments
 (0)