summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorGiacomo Travaglini <giacomo.travaglini@arm.com>2018-03-09 11:47:25 +0000
committerGiacomo Travaglini <giacomo.travaglini@arm.com>2018-03-09 22:45:20 +0000
commitb3d0f2d66a5bf79f66893adcb85b0ac78daf3f65 (patch)
treeb69b4472d7a21b9bdb8a5d43f197d03c850fd7e0 /tests
parentee16a95ec8a7f2d207320670a135065981033f61 (diff)
downloadgem5-b3d0f2d66a5bf79f66893adcb85b0ac78daf3f65.tar.xz
tests: Python regression scripts using new print function
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>
Diffstat (limited to 'tests')
-rw-r--r--tests/configs/checkpoint.py10
-rw-r--r--tests/configs/switcheroo.py11
-rw-r--r--tests/long/se/70.twolf/test.py6
-rw-r--r--tests/quick/se/04.gpu/test.py5
-rw-r--r--tests/quick/se/70.twolf/test.py7
-rw-r--r--tests/run.py6
-rwxr-xr-xtests/testing/helpers.py4
-rwxr-xr-xtests/tests.py16
8 files changed, 42 insertions, 23 deletions
diff --git a/tests/configs/checkpoint.py b/tests/configs/checkpoint.py
index bea481be5..e57b6a7b9 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 @@ 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)
diff --git a/tests/configs/switcheroo.py b/tests/configs/switcheroo.py
index 43bd5eba1..21c6d241d 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 @@ 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)
diff --git a/tests/long/se/70.twolf/test.py b/tests/long/se/70.twolf/test.py
index a63442ad1..eecca305a 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 @@ 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)
diff --git a/tests/quick/se/04.gpu/test.py b/tests/quick/se/04.gpu/test.py
index 0de781c88..14cd74be3 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 a63442ad1..cc131b047 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 @@ 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)
diff --git a/tests/run.py b/tests/run.py
index ff5be230d..845a3eb62 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 @@ 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()
diff --git a/tests/testing/helpers.py b/tests/testing/helpers.py
index e2f3fbe7d..29c6bf5ea 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 @@ if __name__ == "__main__":
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 2ae4a7879..a57a97228 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 @@ 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):