diff options
author | Gabe Black <gabeblack@google.com> | 2017-11-22 18:10:06 -0800 |
---|---|---|
committer | Gabe Black <gabeblack@google.com> | 2017-11-28 10:59:51 +0000 |
commit | 16d6ed6660337b7293072da8a8f6ff6f4d9dbb4e (patch) | |
tree | f49f451ace2c984dabad676dabb8de95e738321c /src/SConscript | |
parent | b86f9210ec5be61fa5adade73bb8b84d552ba630 (diff) | |
download | gem5-16d6ed6660337b7293072da8a8f6ff6f4d9dbb4e.tar.xz |
scons: Add in a new type of unit test called GTest.
This type of unit test is almost the same as UnitTest, except that
it builds in the googletest library with the appropriate flags, and
it also omits all the gem5 object files by default.
Change-Id: I230db7ede563a73a9da0ebeed44aca389f724465
Reviewed-on: https://gem5-review.googlesource.com/6084
Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com>
Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
Diffstat (limited to 'src/SConscript')
-rwxr-xr-x | src/SConscript | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/src/SConscript b/src/SConscript index 2930bab55..2a495bffa 100755 --- a/src/SConscript +++ b/src/SConscript @@ -269,7 +269,12 @@ class UnitTest(object): self.sources = srcs self.target = target self.main = kwargs.get('main', False) - UnitTest.all.append(self) + self.all.append(self) + +class GTest(UnitTest): + '''Create a unit test based on the google test framework.''' + + all = [] # Children should have access Export('Source') @@ -277,6 +282,7 @@ Export('PySource') Export('SimObject') Export('ProtoBuf') Export('UnitTest') +Export('GTest') ######################################################################## # @@ -1019,6 +1025,14 @@ def makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs): path = 'unittest/%s.%s' % (test.target, label) new_env.Program(path, test_objs + static_objs) + gtest_env = new_env.Clone() + gtest_env.Append(LIBS=gtest_env['GTEST_LIBS']) + gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS']) + for test in GTest.all: + test_sources = Source.all.with_tag(str(test.target)) + test_objs = [ gtest_env.StaticObject(s.tnode) for s in test_sources ] + gtest_env.Program('unittest/%s.%s' % (test.target, label), test_objs) + progname = exename if strip: progname += '.unstripped' |