Skip to content

Commit e54d2cc

Browse files
rivos-eblotloiclefort
authored andcommitted
[ot] scripts/opentitan: pyot.py: add a quieter log option
Signed-off-by: Emmanuel Blot <eblot@rivosinc.com>
1 parent 78f658d commit e54d2cc

File tree

2 files changed

+13
-7
lines changed

2 files changed

+13
-7
lines changed

docs/opentitan/pyot.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ usage: pyot.py [-h] [-D DELAY] [-i ICOUNT] [-L LOG_FILE] [-M VARIANT] [-N LOG]
1010
[-t TRACE] [-S FIRST_SOC] [-s] [-U] [-b file] [-c JSON] [-e]
1111
[-f RAW] [-g file] [-K] [-l file] [-O RAW] [-o VMEM] [-r ELF]
1212
[-w CSV] [-x file] [-X] [-F TEST] [-k SECONDS] [-z] [-R]
13-
[-T FACTOR] [-Z] [-v] [-V] [-d] [--log-time] [--debug LOGGER]
14-
[--info LOGGER] [--warn LOGGER]
13+
[-T FACTOR] [-Z] [-v] [-V] [-d] [--quiet] [--log-time]
14+
[--debug LOGGER] [--info LOGGER] [--warn LOGGER]
1515
1616
OpenTitan QEMU unit test sequencer.
1717
@@ -82,6 +82,7 @@ Extras:
8282
-v, --verbose increase verbosity
8383
-V, --vcp-verbose increase verbosity of QEMU virtual comm ports
8484
-d enable debug mode
85+
--quiet quiet logging: only be verbose on errors
8586
--log-time show local time in log messages
8687
--debug LOGGER assign debug level to logger(s)
8788
--info LOGGER assign info level to logger(s)
@@ -182,6 +183,7 @@ This tool may be used in two ways, which can be combined:
182183
* `-V` / `--vcp-verbose` can be repeated to increase verbosity of the QEMU virtual comm ports
183184
* `-v` / `--verbose` can be repeated to increase verbosity of the script, mostly for debug purpose.
184185
* `-d` only useful to debug the script, reports any Python traceback to the standard error stream.
186+
* `--quiet` only emit verbose log traces if an error is detected
185187
* `--log-time` show local time before each logged message
186188
* `--debug` enable the debug level for the selected logger, may be repeated
187189
* `--info` enable the info level for the selected logger, may be repeated

scripts/opentitan/pyot.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,8 +288,9 @@ def trig_match(bline):
288288
vcplogname = 'pyot.vcp'
289289
while connect_map:
290290
if now() > timeout:
291-
raise TimeoutError(f'Cannot connect to QEMU VCPs '
292-
f'{", ".join(connect_map)}')
291+
minfo = ', '.join(f'{d} @ {r[0]}:{r[1]}'
292+
for d, r in connect_map.items())
293+
raise TimeoutError(f'Cannot connect to QEMU VCPs: {minfo}')
293294
connected = []
294295
for vcpid, (host, port) in connect_map.items():
295296
try:
@@ -1778,7 +1779,7 @@ def main():
17781779
exe.add_argument('-F', '--filter', metavar='TEST', action='append',
17791780
help='run tests with matching filter, prefix with "!" '
17801781
'to exclude matching tests')
1781-
exe.add_argument('-k', '--timeout', metavar='SECONDS', type=int,
1782+
exe.add_argument('-k', '--timeout', metavar='SECONDS', type=float,
17821783
help=f'exit after the specified seconds '
17831784
f'(default: {DEFAULT_TIMEOUT} secs)')
17841785
exe.add_argument('-z', '--list', action='store_true',
@@ -1797,6 +1798,8 @@ def main():
17971798
help='increase verbosity of QEMU virtual comm ports')
17981799
extra.add_argument('-d', action='store_true',
17991800
help='enable debug mode')
1801+
extra.add_argument('--quiet', action='store_true',
1802+
help='quiet logging: only be verbose on errors')
18001803
extra.add_argument('--log-time', action='store_true',
18011804
help='show local time in log messages')
18021805
extra.add_argument('--debug', action='append', metavar='LOGGER',
@@ -1826,8 +1829,9 @@ def main():
18261829
log = configure_loggers(args.verbose, 'pyot',
18271830
args.vcp_verbose or 0,
18281831
'pyot.vcp', name_width=16,
1829-
ms=args.log_time, debug=args.debug,
1830-
info=args.info, warning=args.warn)[0]
1832+
ms=args.log_time, quiet=args.quiet,
1833+
debug=args.debug, info=args.info,
1834+
warning=args.warn)[0]
18311835

18321836
qfm = QEMUFileManager(args.keep_tmp)
18331837
qfm.set_qemu_src_dir(qemu_dir)

0 commit comments

Comments
 (0)