tests: Python regression scripts using new print function
authorGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 9 Mar 2018 11:47:25 +0000 (11:47 +0000)
committerGiacomo Travaglini <giacomo.travaglini@arm.com>
Fri, 9 Mar 2018 22:45:20 +0000 (22:45 +0000)
Change-Id: I92060da4537e4ff1c0ff665f2f6ffc3850c50e88
Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com>
Reviewed-by: Giacomo Gabrielli <giacomo.gabrielli@arm.com>
Reviewed-on: https://gem5-review.googlesource.com/8892
Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
Reviewed-by: Gabe Black <gabeblack@google.com>
Maintainer: Jason Lowe-Power <jason@lowepower.com>

tests/configs/checkpoint.py
tests/configs/switcheroo.py
tests/long/se/70.twolf/test.py
tests/quick/se/04.gpu/test.py
tests/quick/se/70.twolf/test.py
tests/run.py
tests/testing/helpers.py
tests/tests.py

index bea481be524469784c7fb06c3a8cba410464af55..e57b6a7b9432c61fc06f7c356543a0c09b6f64d5 100644 (file)
@@ -35,6 +35,8 @@
 #
 # Authors: Andreas Sandberg
 
+from __future__ import print_function
+
 from multiprocessing import Process
 import sys
 import os
@@ -80,7 +82,7 @@ def _run_step(name, restore=None, interval=0.5):
     elif cause in _exit_normal:
         sys.exit(_exitcode_done)
     else:
-        print "Test failed: Unknown exit cause: %s" % cause
+        print("Test failed: Unknown exit cause: %s" % cause)
         sys.exit(_exitcode_fail)
 
 def run_test(root, interval=0.5, max_checkpoints=5):
@@ -112,12 +114,12 @@ def run_test(root, interval=0.5, max_checkpoints=5):
         restore = cpt_name
 
         if p.exitcode == _exitcode_done:
-            print >> sys.stderr, "Test done."
+            print("Test done.", file=sys.stderr)
             sys.exit(0)
         elif p.exitcode == _exitcode_checkpoint:
             pass
         else:
-            print >> sys.stderr, "Test failed."
+            print("Test failed.", file=sys.stderr)
             sys.exit(1)
 
     # Maximum number of checkpoints reached. Just run full-speed from
@@ -128,5 +130,5 @@ def run_test(root, interval=0.5, max_checkpoints=5):
     if cause in _exit_normal:
         sys.exit(0)
     else:
-        print "Test failed: Unknown exit cause: %s" % cause
+        print("Test failed: Unknown exit cause: %s" % cause)
         sys.exit(1)
index 43bd5eba158052b09231e8455160cc49bba1fe13..21c6d241d73323607720b4b3ded4badd0917886f 100644 (file)
@@ -35,6 +35,8 @@
 #
 # Authors: Andreas Sandberg
 
+from __future__ import print_function
+
 import m5
 import _m5
 from m5.objects import *
@@ -122,19 +124,20 @@ def run_test(root, switcher=None, freq=1000, verbose=False):
             next_cpu = switcher.next()
 
             if verbose:
-                print "Switching CPUs..."
-                print "Next CPU: %s" % type(next_cpu)
+                print("Switching CPUs...")
+                print("Next CPU: %s" % type(next_cpu))
             m5.drain()
             if current_cpu != next_cpu:
                 m5.switchCpus(system, [ (current_cpu, next_cpu) ],
                               verbose=verbose)
             else:
-                print "Source CPU and destination CPU are the same, skipping..."
+                print("Source CPU and destination CPU are the same,"
+                    " skipping...")
             current_cpu = next_cpu
         elif exit_cause == "target called exit()" or \
                 exit_cause == "m5_exit instruction encountered":
 
             sys.exit(0)
         else:
-            print "Test failed: Unknown exit cause: %s" % exit_cause
+            print("Test failed: Unknown exit cause: %s" % exit_cause)
             sys.exit(1)
index a63442ad1179f5cae8c4c23835e98e2774b785ef..eecca305ac0a6ac8a09b4aa32447fadf6210de02 100644 (file)
@@ -26,6 +26,8 @@
 #
 # Authors: Korey Sewell
 
+from __future__ import print_function
+
 m5.util.addToPath('../configs/common')
 from cpu2000 import twolf
 import os
@@ -40,8 +42,8 @@ sv2_file = os.path.join(cwd, workload.input_set + '.sv2')
 try:
     os.unlink(sav_file)
 except:
-    print "Couldn't unlink ", sav_file
+    print("Couldn't unlink ", sav_file)
 try:
     os.unlink(sv2_file)
 except:
-    print "Couldn't unlink ", sv2_file
+    print("Couldn't unlink ", sv2_file)
index 0de781c8876d54fc42824bec3e71bcf8cef1afe6..14cd74be3cb30e4e0839af113eebcd83f16aee2f 100644 (file)
 #
 #  Author: Brad Beckmann
 #
+
+from __future__ import print_function
+
 executable = binpath('gpu-hello')
 kernel_path = os.path.dirname(executable)
 kernel_files = glob.glob(os.path.join(kernel_path, '*.asm'))
 if kernel_files:
-    print "Using GPU kernel code file(s)", ",".join(kernel_files)
+    print("Using GPU kernel code file(s)", ",".join(kernel_files))
 else:
     fatal("Can't locate kernel code (.asm) in " + kernel_path)
 
index a63442ad1179f5cae8c4c23835e98e2774b785ef..cc131b047f9847464b2371676deac2f46ae05f19 100644 (file)
 #
 # Authors: Korey Sewell
 
+from __future__ import print_function
+
 m5.util.addToPath('../configs/common')
+
 from cpu2000 import twolf
 import os
 
@@ -40,8 +43,8 @@ sv2_file = os.path.join(cwd, workload.input_set + '.sv2')
 try:
     os.unlink(sav_file)
 except:
-    print "Couldn't unlink ", sav_file
+    print("Couldn't unlink ", sav_file)
 try:
     os.unlink(sv2_file)
 except:
-    print "Couldn't unlink ", sv2_file
+    print("Couldn't unlink ", sv2_file)
index ff5be230daae86a0225618c7886264f733cc4c3d..845a3eb62dd73daf33b26ecac4573d7ba0f95856 100644 (file)
@@ -38,6 +38,8 @@
 #
 # Authors: Steve Reinhardt
 
+from __future__ import print_function
+
 import os
 import sys
 import re
@@ -57,7 +59,7 @@ def skip_test(reason=""):
     """
 
     if reason:
-        print "Skipping test: %s" % reason
+        print("Skipping test: %s" % reason)
     sys.exit(2)
 
 def has_sim_object(name):
@@ -143,7 +145,7 @@ def run_test(root):
 
     # simulate until program terminates
     exit_event = m5.simulate(maxtick)
-    print 'Exiting @ tick', m5.curTick(), 'because', exit_event.getCause()
+    print('Exiting @ tick', m5.curTick(), 'because', exit_event.getCause())
 
 # Since we're in batch mode, dont allow tcp socket connections
 m5.disableAllListeners()
index e2f3fbe7debf35ea4cdfbf4ac29cc5ab64e2aa13..29c6bf5eaa1a33f3031fe8bb2484c496c45bddad 100755 (executable)
@@ -37,6 +37,8 @@
 #
 # Authors: Andreas Sandberg
 
+from __future__ import print_function
+
 import subprocess
 from threading import Timer
 import time
@@ -187,4 +189,4 @@ if __name__ == "__main__":
     ignore_list.rules.append(FileIgnoreList.simple("bar.txt"))
     assert "bar.txt" in ignore_list
 
-    print "SUCCESS!"
+    print("SUCCESS!")
index 2ae4a787972f221711989f326f4e7cf48cb5e47d..a57a972286b89e1b378431d33de71bfc0ca336c4 100755 (executable)
@@ -37,6 +37,8 @@
 #
 # Authors: Andreas Sandberg
 
+from __future__ import print_function
+
 import argparse
 import sys
 import os
@@ -126,7 +128,7 @@ def _list_tests(args):
         for test in get_tests(isa, categories=categories, modes=modes,
                               ruby_protocol=args.ruby_protocol,
                               gpu_isa=args.gpu_isa):
-            print "/".join(test)
+            print("/".join(test))
     sys.exit(0)
 
 def _run_tests_args(subparsers):
@@ -175,8 +177,8 @@ def _run_tests_args(subparsers):
 
 def _run_tests(args):
     if not os.path.isfile(args.gem5) or not os.access(args.gem5, os.X_OK):
-        print >> sys.stderr, \
-            "gem5 binary '%s' not an executable file" % args.gem5
+        print("gem5 binary '%s' not an executable file" % args.gem5,
+            file=sys.stderr)
         sys.exit(2)
 
     formatter = _create_formatter(args)
@@ -195,9 +197,9 @@ def _run_tests(args):
                         skip_diff_out=args.skip_diff_out))
 
     all_results = []
-    print "Running %i tests" % len(tests)
+    print("Running %i tests" % len(tests))
     for testno, test in enumerate(tests):
-        print "%i: Running '%s'..." % (testno, test)
+        print("%i: Running '%s'..." % (testno, test))
 
         all_results.append(test.run())
 
@@ -249,7 +251,7 @@ def _show(args):
         try:
             return pickle.load(f)
         except EOFError:
-            print >> sys.stderr, 'Could not read file %s' % f.name
+            print('Could not read file %s' % f.name, file=sys.stderr)
             return []
 
     formatter = _create_formatter(args)
@@ -287,7 +289,7 @@ def _test(args):
     try:
         suites = sum([ pickle.load(f) for f in args.result ], [])
     except EOFError:
-        print >> sys.stderr, 'Could not read all files'
+        print('Could not read all files', file=sys.stderr)
         sys.exit(2)
 
     if all(s for s in suites):