arm/lib: Decouple console parsing from the FVPRunner

To simplify the FVPRunner class, create a separate ConsolePortParser
class to handle reading an iterator of lines and parsing port numbers
for FVP consoles. Use this in runfvp and the test targets.

This refactor also allows the stream being monitored to be changed more
easily, e.g. to a log file.

Issue-Id: SCM-5314
Signed-off-by: Peter Hoyes <Peter.Hoyes@arm.com>
Change-Id: Iade3a4c803fb355b04af7afa298d0a41fe707d94
Signed-off-by: Jon Mason <jon.mason@arm.com>
This commit is contained in:
Peter Hoyes authored and Jon Mason committed 2022-11-23 11:20:03 -05:00
1 parent c6418d6d59
commit 8eba0eecec
3 files changed
+47 -45

No files matched your search

+5 -4
View File
@@ -52,17 +52,18 @@ def start_fvp(args, config, extra_args):
fvp.start(config, extra_args, args.terminals)
if args.console:
fvp.add_line_callback(lambda line: logger.debug(f"FVP output: {line}"))
expected_terminal = config["consoles"]["default"]
if not expected_terminal:
logger.error("--console used but FVP_CONSOLE not set in machine configuration")
return 1
telnet = fvp.create_telnet(expected_terminal)
parser = runner.ConsolePortParser(fvp.stdout)
port = parser.parse_port(expected_terminal)
telnet = fvp.create_telnet(port)
telnet.wait()
logger.debug(f"Telnet quit, cancelling tasks")
else:
fvp.add_line_callback(lambda line: print(line))
fvp.run()
for line in fvp.stdout:
print(line.strip().decode(errors='ignore'))
finally:
fvp.stop()