summaryrefslogtreecommitdiff
path: root/src/SConscript
diff options
context:
space:
mode:
authorNathan Binkert <nate@binkert.org>2008-10-02 11:27:01 -0700
committerNathan Binkert <nate@binkert.org>2008-10-02 11:27:01 -0700
commitb25755993bbc04be0235975e2967533995a493f0 (patch)
tree3295891b4f535535dce20c2f51c4402aba025a2a /src/SConscript
parent52493b27202fb61aaae74779ebcd91ca8f2bbc2c (diff)
downloadgem5-b25755993bbc04be0235975e2967533995a493f0.tar.xz
unittest: Add unit tests to the scons framework.
Also fix the unit tests so they actually compile correctly.
Diffstat (limited to 'src/SConscript')
-rw-r--r--src/SConscript18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/SConscript b/src/SConscript
index 14988bbbe..6b2ea4d60 100644
--- a/src/SConscript
+++ b/src/SConscript
@@ -144,12 +144,26 @@ def SwigSource(package, source):
val = source,package
swig_sources.append(val)
+unit_tests = []
+def UnitTest(target, sources):
+ if not isinstance(sources, (list, tuple)):
+ sources = [ sources ]
+
+ srcs = []
+ for source in sources:
+ if not isinstance(source, SCons.Node.FS.File):
+ source = File(source)
+ srcs.append(source)
+
+ unit_tests.append((target, srcs))
+
# Children should have access
Export('Source')
Export('BinSource')
Export('PySource')
Export('SimObject')
Export('SwigSource')
+Export('UnitTest')
########################################################################
#
@@ -962,6 +976,10 @@ def makeEnv(label, objsfx, strip = False, **kwargs):
m5lib = newEnv.Library('m5_' + label,
make_objs(cc_lib_sources, newEnv) + swig_objs)
+ for target, sources in unit_tests:
+ objs = [ newEnv.StaticObject(s) for s in sources ]
+ newEnv.Program("unittest/%s.%s" % (target, label), objs + m5lib)
+
# Now link a stub with main() and the library.
exe = 'm5.' + label # final executable
objects = [newEnv.Object(s) for s in cc_bin_sources] + m5lib