sw:vec: Update test_runner timeout message
Use customized message to print out the full execution log for better
debugging.
Change-Id: Ie8b59973dd55c7f9ca0a3ae35424531d57dc728f
diff --git a/scripts/test_runner.py b/scripts/test_runner.py
index fa95c68..afb22c2 100755
--- a/scripts/test_runner.py
+++ b/scripts/test_runner.py
@@ -49,7 +49,15 @@
""" Run the simulation command and quit the simulation."""
self.child = pexpect.spawn(self.simulator_cmd, encoding="utf-8")
self.child.logfile = self.buffer
- self.child.expect(self.termination_strings, timeout=timeout)
+ try:
+ self.child.expect(self.termination_strings, timeout=timeout)
+ except pexpect.exceptions.TIMEOUT:
+ self.buffer.seek(0)
+ message = ("Runner times out with the execution log: \n\n" +
+ cleanup_message(self.buffer.read()))
+ exc = pexpect.exceptions.TIMEOUT(message)
+ exc.__cause__ = None
+ raise exc
self.child.send("\nq\n")
self.child.expect(pexpect.EOF, timeout=timeout)
self.child.close()
@@ -144,6 +152,11 @@
"spike": args.spike_path,
}
+def cleanup_message(message: str) -> str:
+ """ Clean up the message to get rid of the non-ascii code generated by Mono. """
+ ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
+ output = ansi_escape.sub("", message)
+ return output
def main():
""" Run a test and check for Pass or Fail """
@@ -156,10 +169,7 @@
simulator_class = Simulators[args.simulator]
simulator = simulator_class(simulator_path, args.elf)
output = simulator.run(timeout=args.timeout)
- # mono API generates escape characters at the termination. Need to clean up.
- # TODO(hcindyl): Remove this when Renode fix the mono call.
- ansi_escape = re.compile(r"\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])")
- output = ansi_escape.sub("", output)
+ output = cleanup_message(output)
print(output)
failure_strings = [
"FAILED",