7c31688248e9f2ff40e0af0e395885e2f0b5835c
[platform/upstream/iotivity.git] / service / resource-encapsulation / 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 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 lib_env = gtest_env.Clone()
27 target_os = lib_env.get('TARGET_OS')
28
29 if lib_env.get('RELEASE'):
30     lib_env.AppendUnique(CCFLAGS = ['-Os'])
31     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
32 else:
33     lib_env.AppendUnique(CCFLAGS = ['-g'])
34
35 if lib_env.get('LOGGING'):
36     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
37
38 # Add third party libraries
39 SConscript('#service/third_party_libs.scons', 'lib_env')
40
41 if target_os in ['linux']:
42     # Verify that 'hippomocks' mocking code is installed.  If not,
43     # get it and install it
44     SConscript('#extlibs/hippomocks.scons')
45
46 rcs_test_env = lib_env.Clone()
47
48 ######################################################################
49 #unit test setting
50 ######################################################################
51 src_dir = lib_env.get('SRC_DIR')
52
53 ######################################################################
54 # Build flags
55 ######################################################################
56 rcs_test_env.AppendUnique(
57         CPPPATH = [
58                 src_dir + '/extlibs/hippomocks-master',
59                 '../include',
60                 '../src/common/utils/include',
61         ])
62
63 if target_os not in ['windows']:
64     rcs_test_env.AppendUnique(LIBS = ['dl'])
65     rcs_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
66     if target_os != 'android':
67         rcs_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
68         rcs_test_env.AppendUnique(LIBS = ['pthread'])
69
70 rcs_test_env.PrependUnique(LIBS = [
71     'connectivity_abstraction',
72     'oc_logger',
73     'oc_logger_core',
74     'octbstack',
75     'oc',
76     'rcs_client',
77     'rcs_server',
78     'rcs_common',
79     'gtest',
80     'gtest_main'])
81
82 ######################################################################
83 # Build Test
84 ######################################################################
85 rcs_test_src = rcs_test_env.Glob('./*.cpp')
86
87 rcs_client_test = rcs_test_env.Program('rcs_client_test', rcs_test_src)
88 Alias("rcs_client_test", rcs_client_test)
89 rcs_test_env.AppendTarget('rcs_client_test')
90
91 if rcs_test_env.get('TEST') == '1':
92     target_os = rcs_test_env.get('TARGET_OS')
93     if target_os in ['linux']:
94         from tools.scons.RunTest import *
95         run_test(rcs_test_env, '', 'service/resource-encapsulation/unittests/rcs_client_test')