Absent client's certificate CB
[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 import os
26 from tools.scons.RunTest import run_test
27
28 gtest_env = SConscript('#extlibs/gtest/SConscript')
29 lib_env = gtest_env.Clone()
30 target_os = lib_env.get('TARGET_OS')
31
32 if lib_env.get('RELEASE'):
33     lib_env.AppendUnique(CCFLAGS = ['-Os'])
34     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
35 else:
36     lib_env.AppendUnique(CCFLAGS = ['-g'])
37
38 if lib_env.get('LOGGING'):
39     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
40
41 # Add third party libraries
42 SConscript('#service/third_party_libs.scons', 'lib_env')
43
44 if target_os in ['linux']:
45     # Verify that 'hippomocks' mocking code is installed.  If not,
46     # get it and install it
47     SConscript('#extlibs/hippomocks.scons')
48
49 rcs_test_env = lib_env.Clone()
50
51 ######################################################################
52 #unit test setting
53 ######################################################################
54 src_dir = lib_env.get('SRC_DIR')
55
56 ######################################################################
57 # Build flags
58 ######################################################################
59 rcs_test_env.AppendUnique(
60         CPPPATH = [
61                 src_dir + '/extlibs/hippomocks-master',
62                 '../include',
63                 '../src/common/utils/include',
64         ])
65
66 rcs_test_env.PrependUnique(LIBS = [
67     'connectivity_abstraction',
68     'oc_logger',
69     'oc_logger_core',
70     'octbstack',
71     'oc',
72     'rcs_client',
73     'rcs_server',
74     'rcs_common'])
75
76 if lib_env.get('SECURED') == '1':
77     rcs_test_env.AppendUnique(CPPDEFINES = ['SECURED'])
78     if lib_env.get('WITH_TCP') == True:
79         rcs_test_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
80
81 if 'g++' in rcs_test_env.get('CXX'):
82     rcs_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x'])
83
84 ######################################################################
85 # Build Test
86 ######################################################################
87 rcs_test_src = rcs_test_env.Glob('./*.cpp')
88
89 rcs_client_test = rcs_test_env.Program('rcs_client_test', rcs_test_src)
90 Alias("rcs_client_test", rcs_client_test)
91 rcs_test_env.AppendTarget('rcs_client_test')
92
93 if rcs_test_env.get('TEST') == '1':
94     target_os = rcs_test_env.get('TARGET_OS')
95 # TODO: fix this test on linux and remove this comment line
96     if target_os in ['linux']:
97         run_test(rcs_test_env,
98                  '',
99 #                'service_resource-encapsulation_unittests_rcs_client_test.memcheck',
100                  'service/resource-encapsulation/unittests/rcs_client_test')
101 else:
102     rcs_test_env.AppendUnique(CPPDEFINES = ['LOCAL_RUNNING'])
103     if lib_env.get('SECURED') == '1':
104         src_dir = rcs_test_env.get('SRC_DIR')
105         svr_db_src_dir = os.path.join(src_dir, 'service/resource-encapsulation/unittests/')
106         svr_db_build_dir = os.path.join(rcs_test_env.get('BUILD_DIR'), 'service', 'resource-encapsulation', 'unittests') + os.sep
107         rcs_test_env.Alias("install",
108             rcs_test_env.Install(svr_db_build_dir,
109                   os.path.join(svr_db_src_dir,
110                                'oic_svr_db_re_client.dat')))
111