sw:vec: Remove unwanted escape characters in test_runner.py
mono generates escape characters at renode initializaion/termination,
creating stray characters in stdout. Remove these characters to clean up
stdout.
Useful in CI as well as in ctest --verbose
Change-Id: I59e64944773af55977c2f4baa43ff7553320df13
diff --git a/scripts/test_runner.py b/scripts/test_runner.py
index 5941830..f603d40 100755
--- a/scripts/test_runner.py
+++ b/scripts/test_runner.py
@@ -2,6 +2,7 @@
"""Runs test within Qemu and Renode simulators."""
import argparse
import os
+import re
import sys
import tempfile
@@ -120,6 +121,10 @@
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)
print(output)
failure_strings = ["FAILED", "Exception occurred"]
if any(x in output for x in failure_strings):