Imported Upstream version 1.1.1
[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 # SConscript file for Local PKI google tests
22 gtest_env = SConscript('#extlibs/gtest/SConscript')
23 lib_env = gtest_env.Clone()
24
25 ##
26 # ResourceClient Unit Test build script
27 ##
28 if lib_env.get('RELEASE'):
29     lib_env.AppendUnique(CCFLAGS = ['-Os'])
30     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
31 else:
32     lib_env.AppendUnique(CCFLAGS = ['-g'])
33
34 if lib_env.get('LOGGING'):
35     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
36
37 # Add third party libraries
38 SConscript(lib_env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
39
40 target_os = lib_env.get('TARGET_OS')
41 if target_os == 'linux':
42     # Verify that 'hippomocks' mocking code is installed.  If not,
43     # get it and install it
44     SConscript(lib_env.get('SRC_DIR') + '/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', 'winrt']:
64         rcs_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
65         if target_os != 'android':
66                 rcs_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
67                 rcs_test_env.AppendUnique(LIBS = ['pthread'])
68
69 rcs_test_env.PrependUnique(LIBS = [
70     'connectivity_abstraction',
71     'oc_logger',
72     'oc_logger_core',
73     'octbstack',
74     'oc',
75     'rcs_client',
76     'rcs_server',
77     'rcs_common',
78     'gtest',
79     'gtest_main'])
80
81 rcs_test_env.AppendUnique(LIBS = ['dl'])
82
83 ######################################################################
84 # Build Test
85 ######################################################################
86 rcs_test_src = rcs_test_env.Glob('./*.cpp')
87
88 rcs_client_test = rcs_test_env.Program('rcs_client_test', rcs_test_src)
89 Alias("rcs_client_test", rcs_client_test)
90 rcs_test_env.AppendTarget('rcs_client_test')
91
92 if rcs_test_env.get('TEST') == '1':
93     target_os = rcs_test_env.get('TARGET_OS')
94     if target_os == 'linux':
95         from tools.scons.RunTest import *
96         run_test(rcs_test_env, '', 'service/resource-encapsulation/unittests/rcs_client_test')