style: Strip newline when checking lines
[gem5.git] / tests / configs / switcheroo.py
index dadf8db03f2526481dafe68d5c17e5bbf3ecd880..61145bbf6d330c11703864ad4bbae8da99e9cd90 100644 (file)
@@ -40,12 +40,6 @@ from m5.objects import *
 m5.util.addToPath('../configs/common')
 from Caches import *
 
-def _memMode(cclass):
-    if cclass == AtomicSimpleCPU:
-        return "atomic", m5.objects.params.atomic
-    else:
-        return "timing", m5.objects.params.timing
-
 class Sequential:
     """Sequential CPU switcher.
 
@@ -76,7 +70,7 @@ class Sequential:
     def first(self):
         return self.cpus[self.first_cpu]
 
-def run_test(root, switcher=None, freq=1000):
+def run_test(root, switcher=None, freq=1000, verbose=False):
     """Test runner for CPU switcheroo tests.
 
     The switcheroo test runner is used to switch CPUs in a system that
@@ -97,6 +91,7 @@ def run_test(root, switcher=None, freq=1000):
       switcher -- CPU switcher implementation. See Sequential for
                   an example implementation.
       period -- Switching frequency in Hz.
+      verbose -- Enable output at each switch (suppressed by default).
     """
 
     if switcher == None:
@@ -104,7 +99,12 @@ def run_test(root, switcher=None, freq=1000):
 
     current_cpu = switcher.first()
     system = root.system
-    system.mem_mode = _memMode(type(current_cpu))[0]
+    system.mem_mode = type(current_cpu).memory_mode()
+
+    # Suppress "Entering event queue" messages since we get tons of them.
+    # Worse yet, they include the timestamp, which makes them highly
+    # variable and unsuitable for comparing as test outputs.
+    m5.internal.core.cvar.want_info = verbose
 
     # instantiate configuration
     m5.instantiate()
@@ -119,15 +119,15 @@ def run_test(root, switcher=None, freq=1000):
         if exit_cause == "simulate() limit reached":
             next_cpu = switcher.next()
 
-            print "Switching CPUs..."
-            print "Next CPU: %s" % type(next_cpu)
-            m5.drain(system)
-            system.setMemoryMode(_memMode(type(next_cpu))[1])
+            if verbose:
+                print "Switching CPUs..."
+                print "Next CPU: %s" % type(next_cpu)
+            m5.drain()
             if current_cpu != next_cpu:
-                m5.switchCpus([ (current_cpu, next_cpu) ])
+                m5.switchCpus(system, [ (current_cpu, next_cpu) ],
+                              verbose=verbose)
             else:
                 print "Source CPU and destination CPU are the same, skipping..."
-            m5.resume(system)
             current_cpu = next_cpu
         elif exit_cause == "target called exit()" or \
                 exit_cause == "m5_exit instruction encountered":