From e839ff257cd2ec247fea95305871e9557ffd1fad Mon Sep 17 00:00:00 2001 From: Philippe Coval Date: Fri, 19 May 2017 18:53:57 +0200 Subject: [PATCH] resource-encapsulation: Isolate unit_tests building Previously gtest libs were propagated to shared libs: g++ -o .../resource-encapsulation/src/common/librcs_common.so \ (...) \ -lgtest -lgtest_main \ -lc_common -llogger -ldl -lpthread -luuid -lrt -loc Change-Id: I9bcaa39d8cd5e1166b2ec7d7ede14d44f79a476e Bug: https://jira.iotivity.org/browse/IOT-1745 Signed-off-by: Philippe Coval Reviewed-on: https://gerrit.iotivity.org/gerrit/20241 Tested-by: jenkins-iotivity Reviewed-by: Dan Mihai Reviewed-by: Dave Thaler Reviewed-by: Ziran Sun Reviewed-by: Gregg Reynolds Reviewed-by: Pawel Winogrodzki --- .../resource-encapsulation/src/common/SConscript | 41 ++------------ .../common/primitiveResource/unittests/SConscript | 63 ++++++++++++++++++++++ 2 files changed, 66 insertions(+), 38 deletions(-) create mode 100644 service/resource-encapsulation/src/common/primitiveResource/unittests/SConscript diff --git a/service/resource-encapsulation/src/common/SConscript b/service/resource-encapsulation/src/common/SConscript index fedc923..83b5605 100644 --- a/service/resource-encapsulation/src/common/SConscript +++ b/service/resource-encapsulation/src/common/SConscript @@ -22,14 +22,9 @@ # rcs_common (primitiveResource and expiryTimer) build script ## import os +Import('env') -# SConscript file for Local PKI google tests -gtest_env = SConscript('#extlibs/gtest/SConscript') -lib_env = gtest_env.Clone() - -# Add third party libraries -SConscript('#service/third_party_libs.scons', exports = 'lib_env') -rcs_common_env = lib_env.Clone() +rcs_common_env = env.Clone() target_os = rcs_common_env.get('TARGET_OS') release = rcs_common_env.get('RELEASE') src_dir = rcs_common_env.get('SRC_DIR') @@ -103,34 +98,4 @@ else: # Build Test Expiry Timer and primitive Resource ###################################################################### if target_os in ['linux']: - rcs_common_test_env = rcs_common_env.Clone(); - - rcs_common_test_env.PrependUnique(CPPPATH = [ - '#/extlibs/hippomocks/hippomocks', - 'utils/include' - ]) - - rcs_common_test_env.PrependUnique(LIBS = [ - 'octbstack', - 'oc_logger', - 'connectivity_abstraction', - 'coap', - 'rcs_common']) - - rcs_common_test_src = [ - rcs_common_test_env.Glob('primitiveResource/unittests/*.cpp'), - 'expiryTimer/unittests/ExpiryTimerTest.cpp' - ] - - rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src) - Alias("rcs_common_test", rcs_common_test) - rcs_common_test_env.AppendTarget('rcs_common_test') - - if rcs_common_test_env.get('TEST') == '1': - from tools.scons.RunTest import run_test -# TODO: fix test on linux and remove commented lines - run_test(rcs_common_test_env, -# 'service_resource-encapsulation_src_common_rcs_common_test.memcheck', - '', - 'service/resource-encapsulation/src/common/rcs_common_test', - rcs_common_test) + SConscript('primitiveResource/unittests/SConscript') diff --git a/service/resource-encapsulation/src/common/primitiveResource/unittests/SConscript b/service/resource-encapsulation/src/common/primitiveResource/unittests/SConscript new file mode 100644 index 0000000..0db2d24 --- /dev/null +++ b/service/resource-encapsulation/src/common/primitiveResource/unittests/SConscript @@ -0,0 +1,63 @@ +#****************************************************************** +# +# Copyright 2015 Samsung Electronics All Rights Reserved. +# +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +Import('env') +gtest_env = SConscript('#extlibs/gtest/SConscript') +rcs_common_test_env = gtest_env.Clone() + +rcs_common_test_env.PrependUnique(CPPPATH = [ + '#/extlibs/hippomocks/hippomocks', + '#/resource/csdk/include', + '#/resource/csdk/stack/include', + '#/resource/include', + '#/resource/oc_logger/include', + '#/service/resource-encapsulation/include/', + '../include', + '../../utils/include', + "../../expiryTimer/include", + "../../expiryTimer/src", +]) + +rcs_common_test_env.PrependUnique(LIBS = [ + 'oc', + 'octbstack', + 'oc_logger', + 'connectivity_abstraction', + 'coap', + 'rcs_common' +]) + +rcs_common_test_src = [ + rcs_common_test_env.Glob('*.cpp'), + '../../expiryTimer/unittests/ExpiryTimerTest.cpp', +] + +rcs_common_test = rcs_common_test_env.Program('rcs_common_test', rcs_common_test_src) +Alias("rcs_common_test", rcs_common_test) +rcs_common_test_env.AppendTarget('rcs_common_test') + +if rcs_common_test_env.get('TEST') == '1': + rcs_common_test_env.AppendUnique(CPPDEFINES = ['HIPPOMOCKS_ISSUE']) + from tools.scons.RunTest import run_test + run_test(rcs_common_test_env, +# 'service_resource-encapsulation_src_common_primitiveResource_unittests_rcs_common_test.memcheck', + '', # TODO: fix leaks + 'service/resource-encapsulation/src/common/primitiveResource/unittests/rcs_common_test', + rcs_common_test) -- 2.7.4