Giacomo Travaglini has uploaded this change for review. ( https://gem5-review.googlesource.com/8892

Change subject: tests: Python regression scripts using new print function
......................................................................

tests: Python regression scripts using new print function

Change-Id: I92060da4537e4ff1c0ff665f2f6ffc3850c50e88
Signed-off-by: Giacomo Travaglini <giacomo.travagl...@arm.com>
Reviewed-by: Giacomo Gabrielli <giacomo.gabrie...@arm.com>
---
M tests/configs/checkpoint.py
M tests/configs/switcheroo.py
M tests/long/se/70.twolf/test.py
M tests/quick/se/04.gpu/test.py
M tests/quick/se/70.twolf/test.py
M tests/run.py
M tests/testing/helpers.py
M tests/tests.py
8 files changed, 42 insertions(+), 23 deletions(-)



diff --git a/tests/configs/checkpoint.py b/tests/configs/checkpoint.py
index bea481b..e57b6a7 100644
--- a/tests/configs/checkpoint.py
+++ b/tests/configs/checkpoint.py
@@ -35,6 +35,8 @@
 #
 # Authors: Andreas Sandberg

+from __future__ import print_function
+
 from multiprocessing import Process
 import sys
 import os
@@ -80,7 +82,7 @@
     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 @@
         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 @@
     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)
diff --git a/tests/configs/switcheroo.py b/tests/configs/switcheroo.py
index 43bd5eba..21c6d24 100644
--- a/tests/configs/switcheroo.py
+++ b/tests/configs/switcheroo.py
@@ -35,6 +35,8 @@
 #
 # Authors: Andreas Sandberg

+from __future__ import print_function
+
 import m5
 import _m5
 from m5.objects import *
@@ -122,19 +124,20 @@
             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)
diff --git a/tests/long/se/70.twolf/test.py b/tests/long/se/70.twolf/test.py
index a63442a..eecca30 100644
--- a/tests/long/se/70.twolf/test.py
+++ b/tests/long/se/70.twolf/test.py
@@ -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 @@
 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)
diff --git a/tests/quick/se/04.gpu/test.py b/tests/quick/se/04.gpu/test.py
index 0de781c..14cd74b 100644
--- a/tests/quick/se/04.gpu/test.py
+++ b/tests/quick/se/04.gpu/test.py
@@ -32,11 +32,14 @@
 #
 #  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)

diff --git a/tests/quick/se/70.twolf/test.py b/tests/quick/se/70.twolf/test.py
index a63442a..cc131b0 100644
--- a/tests/quick/se/70.twolf/test.py
+++ b/tests/quick/se/70.twolf/test.py
@@ -26,7 +26,10 @@
 #
 # Authors: Korey Sewell

+from __future__ import print_function
+
 m5.util.addToPath('../configs/common')
+
 from cpu2000 import twolf
 import os

@@ -40,8 +43,8 @@
 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)
diff --git a/tests/run.py b/tests/run.py
index ff5be23..845a3eb 100644
--- a/tests/run.py
+++ b/tests/run.py
@@ -38,6 +38,8 @@
 #
 # Authors: Steve Reinhardt

+from __future__ import print_function
+
 import os
 import sys
 import re
@@ -57,7 +59,7 @@
     """

     if reason:
-        print "Skipping test: %s" % reason
+        print("Skipping test: %s" % reason)
     sys.exit(2)

 def has_sim_object(name):
@@ -143,7 +145,7 @@

     # 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()
diff --git a/tests/testing/helpers.py b/tests/testing/helpers.py
index e2f3fbe..29c6bf5 100755
--- a/tests/testing/helpers.py
+++ b/tests/testing/helpers.py
@@ -37,6 +37,8 @@
 #
 # Authors: Andreas Sandberg

+from __future__ import print_function
+
 import subprocess
 from threading import Timer
 import time
@@ -187,4 +189,4 @@
     ignore_list.rules.append(FileIgnoreList.simple("bar.txt"))
     assert "bar.txt" in ignore_list

-    print "SUCCESS!"
+    print("SUCCESS!")
diff --git a/tests/tests.py b/tests/tests.py
index 2ae4a78..a57a972 100755
--- a/tests/tests.py
+++ b/tests/tests.py
@@ -37,6 +37,8 @@
 #
 # Authors: Andreas Sandberg

+from __future__ import print_function
+
 import argparse
 import sys
 import os
@@ -126,7 +128,7 @@
         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):
     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 @@
                         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 @@
         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 @@
     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):

--
To view, visit https://gem5-review.googlesource.com/8892
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I92060da4537e4ff1c0ff665f2f6ffc3850c50e88
Gerrit-Change-Number: 8892
Gerrit-PatchSet: 1
Gerrit-Owner: Giacomo Travaglini <giacomo.travagl...@arm.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list
gem5-dev@gem5.org
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to