-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
Showing
1 changed file
with
35 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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 |