python: Flush the simulation stdout/stderr buffers

Occasionally gem5's stdout/stderr, when run within the TestLib
framework, will be shuffled. This is resolved by flushing the
stdout/stderr buffer before and after simulation.

In addition to this, the verifier.py has been improved to remove
boilerplate gem5 code from the stdout comparison.

Change-Id: I04c8f9cee4475b8eab2f1ba9bb76bfa3cfcca6ec
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/34995
Reviewed-by: Jason Lowe-Power <power.jg@gmail.com>
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Jason Lowe-Power <power.jg@gmail.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
Bobby R. Bruce
2020-09-22 12:37:34 -07:00
parent d9d4203e04
commit b715c2d513
13 changed files with 12 additions and 45 deletions

View File

@@ -175,7 +175,15 @@ def simulate(*args, **kwargs):
if _drain_manager.isDrained():
_drain_manager.resume()
return _m5.event.simulate(*args, **kwargs)
# We flush stdout and stderr before and after the simulation to ensure the
# output arrive in order.
sys.stdout.flush()
sys.stderr.flush()
sim_out = _m5.event.simulate(*args, **kwargs)
sys.stdout.flush()
sys.stderr.flush()
return sim_out
def drain():
"""Drain the simulator in preparation of a checkpoint or memory mode

View File

@@ -1,6 +1,2 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
-50000

View File

@@ -1,6 +1,2 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
-776.000061

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
--- Done DRAM low power sweep ---
Fixed params -

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
**** REAL SIMULATION ****
Hello world!

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
**** REAL SIMULATION ****
Begining test of difficult SPARC instructions...

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
Beginning simulation!
Hello world!

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
Beginning simulation!
Exiting @ tick 10944163 because Goodbye hello!! Goodbye hello!! Goodbye hello!! Goodbye hello!! Goodbye hello!! Goodbye hello!! Goo

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
Hello World! From a SimObject!
Beginning simulation!

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000 ticks per second
Beginning simulation!
Exiting @ tick 9981 because Ruby Tester completed

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
Beginning simulation!
Running on 2 cores. with 100 values

View File

@@ -1,7 +1,3 @@
gem5 Simulator System. http://gem5.org
gem5 is copyrighted software; use the --copyright option for details.
Global frequency set at 1000000000000 ticks per second
Init done
[Iteration 1, Thread 1] Got lock

View File

@@ -115,6 +115,9 @@ class DerivedGoldStandard(MatchGoldStandard):
class MatchStdout(DerivedGoldStandard):
_file = constants.gem5_simulation_stdout
_default_ignore_regex = [
re.compile('^\s+$'), # Remove blank lines.
re.compile('^gem5 Simulator System'),
re.compile('^gem5 is copyrighted software'),
re.compile('^Redirecting (stdout|stderr) to'),
re.compile('^gem5 version '),
re.compile('^gem5 compiled '),