1 #******************************************************************
3 # Copyright 2016 Samsung Electronics All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
7 # Licensed under the Apache License, Version 2.0 (the "License");
8 # you may not use this file except in compliance with the License.
9 # You may obtain a copy of the License at
11 # http://www.apache.org/licenses/LICENSE-2.0
13 # Unless required by applicable law or agreed to in writing, software
14 # distributed under the License is distributed on an "AS IS" BASIS,
15 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 # See the License for the specific language governing permissions and
17 # limitations under the License.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 # Mediator[RichSDK] Unit Test build script
27 if env.get('RELEASE'):
28 env.AppendUnique(CCFLAGS = ['-Os'])
29 env.AppendUnique(CPPDEFINES = ['NDEBUG'])
31 env.AppendUnique(CCFLAGS = ['-g'])
33 if env.get('LOGGING'):
34 env.AppendUnique(CPPDEFINES = ['TB_LOG'])
36 # Add third party libraries
38 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
40 target_os = env.get('TARGET_OS')
41 if target_os == 'linux':
42 # Verify that 'google unit test' library is installed. If not,
43 # get it and install it
44 SConscript(env.get('SRC_DIR') + '/extlibs/gtest/SConscript')
46 # Verify that 'hippomocks' mocking code is installed. If not,
47 # get it and install it
48 SConscript(env.get('SRC_DIR') + '/extlibs/hippomocks.scons')
50 mediator_rich_test_env = lib_env.Clone()
52 ######################################################################
54 ######################################################################
55 src_dir = lib_env.get('SRC_DIR')
56 gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
58 ######################################################################
60 ######################################################################
61 gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
62 gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
64 mediator_rich_test_env.AppendUnique(
66 src_dir + '/extlibs/hippomocks-master',
67 src_dir + '/extlibs/gtest/gtest-1.7.0/include',
72 if target_os not in ['windows', 'winrt']:
73 mediator_rich_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
74 if target_os != 'android':
75 mediator_rich_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
76 mediator_rich_test_env.AppendUnique(LIBS = ['pthread'])
79 if env.get('SECURED') == '1':
80 mediator_rich_test_env.PrependUnique(LIBS = ['tinydtls','ocprovision', 'ocpmapi'])
82 mediator_rich_test_env.PrependUnique(LIBS = [
87 'connectivity_abstraction',
93 mediator_rich_test_env.AppendUnique(LIBS = ['dl'])
95 ######################################################################
97 ######################################################################
98 mediator_richsdk_test_src = env.Glob('./*.cpp')
100 mediator_richsdk_test = mediator_rich_test_env.Program('mediator_richsdk_test', mediator_richsdk_test_src)
101 Alias("mediator_richsdk_test", mediator_richsdk_test)
102 env.AppendTarget('mediator_richsdk_test')
104 if env.get('TEST') == '1':
105 target_os = env.get('TARGET_OS')
106 if target_os == 'linux':
107 from tools.scons.RunTest import *
108 run_test(mediator_rich_test_env, '', 'service/easy-setup/mediator/richsdk/unittests/mediator_richsdk_test')