summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndreas Sandberg <Andreas.Sandberg@ARM.com>2013-01-07 13:05:37 -0500
committerAndreas Sandberg <Andreas.Sandberg@ARM.com>2013-01-07 13:05:37 -0500
commit9c5ef235cc595d0f51b0810786c2b512bef7c69f (patch)
treefa0b5e5d9e28267c001732210a548debe143e7ce /tests
parent35bdee72cbbced98bb93f9e5310c4dbd014dd911 (diff)
downloadgem5-9c5ef235cc595d0f51b0810786c2b512bef7c69f.tar.xz
tests: Add support for skipping tests, skip EIO tests if not enabled
The EIO tests depend on the EIO support from the "encumbered" repository, which means that they are not normally built with gem5. This causes all EIO related tests to fail, which is both annoying and confusing. This patch addresses this by adding support for skipping tests if certain conditions (e.g., the presence of a SimObject) can not be met. It introduces the following Python functions that can be called from within a test case: * skip_test -- Skip a test and optionally print why the test was skipped. * has_sim_object -- Test if a SimObject exists. * require_sim_object -- Test if a SimObject exists and skip, or optionally fail, the test if not. Additionally, this patch updates the EIO tests to check for the presence of EioProcess.
Diffstat (limited to 'tests')
-rw-r--r--tests/SConscript7
-rw-r--r--tests/quick/se/20.eio-short/test.py2
-rw-r--r--tests/quick/se/30.eio-mp/test.py2
-rw-r--r--tests/run.py58
4 files changed, 69 insertions, 0 deletions
diff --git a/tests/SConscript b/tests/SConscript
index 9bf9e3aeb..bfdc9a566 100644
--- a/tests/SConscript
+++ b/tests/SConscript
@@ -150,6 +150,9 @@ def run_test(target, source, env):
# Hand the return status to scons and let scons decide what
# to do about it (typically terminate unless run with -k).
return status
+ elif status == 2:
+ # The test was skipped
+ pass
else:
print 'M5 exited with non-zero status', status
# complete but failed execution (call to exit() with non-zero
@@ -159,6 +162,8 @@ def run_test(target, source, env):
# Generate status file contents based on exit status of m5 or diff-out
if status == 0:
status_str = "passed."
+ elif status == 2:
+ status_str = "skipped."
else:
status_str = "FAILED!"
f = file(str(target[0]), 'w')
@@ -188,6 +193,8 @@ def print_test(target, source, env):
status = termcap.Red + status[:-1] + termcap.Normal + status[-1]
elif status == "passed.":
status = termcap.Green + status[:-1] + termcap.Normal + status[-1]
+ elif status == "skipped.":
+ status = termcap.Yellow + status[:-1] + termcap.Normal + status[-1]
# put it back in the list and join with space
words[-1] = status
diff --git a/tests/quick/se/20.eio-short/test.py b/tests/quick/se/20.eio-short/test.py
index 210f21b14..67d8a582c 100644
--- a/tests/quick/se/20.eio-short/test.py
+++ b/tests/quick/se/20.eio-short/test.py
@@ -26,6 +26,8 @@
#
# Authors: Steve Reinhardt
+require_sim_object("EioProcess")
+
root.system.cpu.workload = EioProcess(file = binpath('anagram',
'anagram-vshort.eio.gz'))
root.system.cpu.max_insts_any_thread = 500000
diff --git a/tests/quick/se/30.eio-mp/test.py b/tests/quick/se/30.eio-mp/test.py
index 3dbb7614a..dcf6fb007 100644
--- a/tests/quick/se/30.eio-mp/test.py
+++ b/tests/quick/se/30.eio-mp/test.py
@@ -26,6 +26,8 @@
#
# Authors: Lisa Hsu
+require_sim_object("EioProcess")
+
process = EioProcess(file = binpath('anagram', 'anagram-vshort.eio.gz'))
for i in xrange(nb_cores):
diff --git a/tests/run.py b/tests/run.py
index 1671d1714..e4474ac5c 100644
--- a/tests/run.py
+++ b/tests/run.py
@@ -1,3 +1,15 @@
+# Copyright (c) 2012 ARM Limited
+# All rights reserved
+#
+# The license below extends only to copyright in the software and shall
+# not be construed as granting a license to any other intellectual
+# property including but not limited to intellectual property relating
+# to a hardware implementation of the functionality of the software
+# licensed hereunder. You may use the software subject to the license
+# terms below provided that you ensure that this notice is replicated
+# unmodified and in its entirety in all distributions of the software,
+# modified or unmodified, in source code or in binary form.
+#
# Copyright (c) 2006-2007 The Regents of The University of Michigan
# All rights reserved.
#
@@ -35,6 +47,52 @@ from os.path import join as joinpath
import m5
+def skip_test(reason=""):
+ """Signal that a test should be skipped and optionally print why.
+
+ Keyword arguments:
+ reason -- Reason why the test failed. Output is omitted if empty.
+ """
+
+ if reason:
+ print "Skipping test: %s" % reason
+ sys.exit(2)
+
+def has_sim_object(name):
+ """Test if a SimObject exists in the simulator.
+
+ Arguments:
+ name -- Name of SimObject (string)
+
+ Returns: True if the object exists, False otherwise.
+ """
+
+ try:
+ cls = getattr(m5.objects, name)
+ return issubclass(cls, m5.objects.SimObject)
+ except AttributeError:
+ return False
+
+def require_sim_object(name, fatal=False):
+ """Test if a SimObject exists and abort/skip test if not.
+
+ Arguments:
+ name -- Name of SimObject (string)
+
+ Keyword arguments:
+ fatal -- Set to True to indicate that the test should fail
+ instead of being skipped.
+ """
+
+ if has_sim_object(name):
+ return
+ else:
+ msg = "Test requires the '%s' SimObject." % name
+ if fatal:
+ m5.fatal(msg)
+ else:
+ skip_test(msg)
+
# Since we're in batch mode, dont allow tcp socket connections
m5.disableAllListeners()