badcff003514238f44878941d98d3316ff25ecb3
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / resourceClient / unittests / SConscript
1 #******************************************************************
2 #
3 # Copyright 2015 Samsung Electronics All Rights Reserved.
4 #
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
6 #
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
10 #
11 #      http://www.apache.org/licenses/LICENSE-2.0
12 #
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.
18 #
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
20
21 ##
22 # ResourceClient Unit Test build script
23 ##
24 import os
25 Import('env')
26
27 if env.get('RELEASE'):
28         env.AppendUnique(CCFLAGS = ['-Os'])
29         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
30 else:
31         env.AppendUnique(CCFLAGS = ['-g'])
32
33 if env.get('LOGGING'):
34         env.AppendUnique(CPPDEFINES = ['TB_LOG'])
35
36 # Add third party libraries
37 lib_env = env.Clone()
38 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
39
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')
45
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')
49
50 DiscoveryManager_gtest_env = lib_env.Clone()
51
52 ######################################################################
53 #unit test setting
54 ######################################################################
55 src_dir = lib_env.get('SRC_DIR')
56 gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
57
58 ######################################################################
59 # Build flags
60 ######################################################################
61 gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
62 gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
63
64 DiscoveryManager_gtest_env.AppendUnique(
65         CPPPATH = [
66                 src_dir + '/extlibs/hippomocks-master',
67                 src_dir + '/extlibs/gtest/gtest-1.7.0/include',
68                 '../../src/common/utils/include',
69                 '../../src/serverBuilder/include',
70                 '../../src/common/primitiveResource/include',
71                 '../../common/utils/include/',
72                 '../../../include/',
73                 '../../common/primitiveResource/include',
74                 '../../../../../resource/include',
75                 '../../common/expiryTimer/include'
76         ])
77
78 if target_os not in ['windows', 'winrt']:
79         DiscoveryManager_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
80         if target_os != 'android':
81                 DiscoveryManager_gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
82                 DiscoveryManager_gtest_env.AppendUnique(LIBS = ['pthread'])
83
84 DiscoveryManager_gtest_env.PrependUnique(LIBS = [
85     'rcs_client',
86     'rcs_server',
87     'rcs_common',
88     'oc',
89     'octbstack',
90     'oc_logger',
91     'oc_logger_core',
92     'connectivity_abstraction',
93     gtest,
94     gtest_main])
95
96 DiscoveryManager_gtest_env.AppendUnique(LIBS = ['dl'])
97
98 ######################################################################
99 # Build Test
100 ######################################################################
101 DiscoveryManager_gtest_src = env.Glob('./*.cpp')
102
103 DiscoveryManager_test = DiscoveryManager_gtest_env.Program('DiscoveryManagerTest', DiscoveryManager_gtest_src)
104 Alias("DiscoveryManagerTest", DiscoveryManager_test)
105 env.AppendTarget('DiscoveryManager_test')
106
107 if env.get('TEST') == '1':
108     target_os = env.get('TARGET_OS')
109     if target_os == 'linux':
110         from tools.scons.RunTest import *
111         run_test(DiscoveryManager_gtest_env, '',
112                 'service/resource-encapsulation/src/resourceClient/DiscoveryManagerTest')