[systemtest] Ensure all produced data is matched
`utils.find_in_files()` is a helper used by most of the systemtest
framework to search through output such as STDOUT/STDERR of a
simulation, UART logs, etc. It searches for a pattern match in the
output. As an optimization, the function returns early if it "knows"
that no more data will be produced, e.g. because the producing
simulation has terminated.
Until now, we returned immediately if the producer terminated, causing
us to miss the last output from it shortly before shutting down. This
commit changes that to also include this last output in the matching.
Signed-off-by: Philipp Wagner <phw@lowrisc.org>
diff --git a/test/systemtest/utils.py b/test/systemtest/utils.py
index 17d8e8f..4af3205 100644
--- a/test/systemtest/utils.py
+++ b/test/systemtest/utils.py
@@ -425,6 +425,7 @@
for file_object in file_objects:
file_object.seek(0)
+ end_loop = False
while True:
for file_object in file_objects:
for line in file_object:
@@ -432,12 +433,17 @@
if m is not None:
return m
+ if end_loop:
+ break
+
if timeout is not None and time.time() >= t_end:
raise subprocess.TimeoutExpired(None, timeout)
+ # The wait function returns True to indicate that no more data will be
+ # produced (e.g. because the producing process terminated). But we still
+ # need to check one last time if the already produced data is matching
+ # the `pattern`.
end_loop = wait_func()
- if end_loop:
- break
return None