From 08fc1d5ee3e03578b59fa6a6331281e8d123c746 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Sun, 3 Dec 2017 02:10:42 -0800 Subject: [PATCH] tests: Add a pseudo target to run all the unit tests for build/variant. Telling scons to build build/${BUILD_OPTS}/unittests.${VARIANT} will get it to build and run all googletest based unit tests under the ${BUILD_OPTS} build options (ARM, ALPHA, X86, etc.), and compiled with the flags, etc., for the ${VARIANT} variant (ie. opt, debug, etc.). This will make it easy to run the unit tests without having to actually know where they are, what tests are available, etc. This target is called unittests* and not something based on gtest or googletest since it's my intention for all unit tests to be based on googletest, making the distinction unnecessary. Since the target is essentially part of the external interface for scons, I wanted to name it something general so it'll be less likely that we have to change it. Change-Id: I8fdec768d821974309c92a2ce4c96dce7df24fa5 Reviewed-on: https://gem5-review.googlesource.com/6282 Reviewed-by: Gabe Black Reviewed-by: Brandon Potter Maintainer: Gabe Black --- src/SConscript | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/SConscript b/src/SConscript index 961df49d9..cd42c27c5 100755 --- a/src/SConscript +++ b/src/SConscript @@ -1049,11 +1049,15 @@ def makeEnv(env, label, objsfx, strip=False, disable_partial=False, **kwargs): gtest_env = new_env.Clone() gtest_env.Append(LIBS=gtest_env['GTEST_LIBS']) gtest_env.Append(CPPFLAGS=gtest_env['GTEST_CPPFLAGS']) + gtests = [] for test in GTest.all: test_sources = Source.all.with_tag(str(test.target)) test_objs = [ s.static(gtest_env) for s in test_sources ] - gtest_env.Program(test.dir.File('%s.%s' % (test.target, label)), - test_objs) + gtests.append(gtest_env.Program( + test.dir.File('%s.%s' % (test.target, label)), test_objs)) + + gtest_target = Dir(new_env['BUILDDIR']).File('unittests.%s' % label) + AlwaysBuild(Command(gtest_target, gtests, gtests)) progname = exename if strip: -- 2.30.2