Skip to content

Commit

Permalink
Filter Corstone's stdout (#61)
Browse files Browse the repository at this point in the history
Corstone prints out some informational text to stdout, but this text
conflicts with expectations from tests about the contents of stdout.

This patch filters out this text to send to stdout only what matters.
  • Loading branch information
vhscampos authored Feb 3, 2025
1 parent 79cd9b8 commit 4430235
Showing 1 changed file with 35 additions and 2 deletions.
37 changes: 35 additions & 2 deletions arm-software/embedded/arm-runtimes/test-support/run_fvp.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

# SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <[email protected]>

import re
import subprocess
import sys
from os import path
Expand Down Expand Up @@ -92,6 +93,38 @@ def run_fvp(
cwd=working_directory,
check=False,
)
sys.stdout.buffer.write(result.stdout)
return result.returncode

# Corstone-310 prints out boilerplate text on stdout alongside the actual
# output of the image. Some tests, for instance in libcxx, check the
# contents of stdout, and may treat the unexpected text as a condition for
# failure. To work around this, we cut out the model's boilerplate output.
if fvp_model == "corstone-310":
decoded_stdout = result.stdout.decode()
expected_stdout_format = r"""
Ethos-U rev [0-9a-z]+ --- \w{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}
\(C\) COPYRIGHT (?:\d{4}|\d{4}-\d{4})(?:,\s?(?:\d{4}|\d{4}-\d{4}))* Arm Limited
ALL RIGHTS RESERVED
(.*)
Info: /OSCI/SystemC: Simulation stopped by user.
\[warning \]\[main@0\]\[\d+ ns\] Simulation stopped by user
"""

regex_result = re.fullmatch(
expected_stdout_format, decoded_stdout, flags=re.DOTALL
)
if not regex_result:
error_msg = (
f"Corstone's output format is different than expected\n"
f"Expected (regex): {expected_stdout_format}\n"
f"Got: {decoded_stdout}"
)
raise RuntimeError(error_msg)

relevant_stdout = regex_result[1]
result_stdout = relevant_stdout.encode()
else:
result_stdout = result.stdout

sys.stdout.buffer.write(result_stdout)
return result.returncode

0 comments on commit 4430235

Please sign in to comment.