[IOT-2011] linker changes for oc_logger
[contrib/iotivity.git] / resource / csdk / security / provisioning / unittest / 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 import os
22 import os.path
23 from tools.scons.RunTest import run_test
24
25 Import('test_env')
26
27 # SConscript file for Local PKI google tests
28 sptest_env = test_env.Clone()
29 src_dir = sptest_env.get('SRC_DIR')
30 target_os = sptest_env.get('TARGET_OS')
31 rd_mode = sptest_env.get('RD_MODE')
32
33 ######################################################################
34 # Build flags
35 ######################################################################
36 with_upstream_libcoap = sptest_env.get('WITH_UPSTREAM_LIBCOAP')
37 if with_upstream_libcoap == '1':
38         # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
39         sptest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
40 else:
41         # For bring up purposes only, the forked version will live here.
42         sptest_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
43
44 sptest_env.PrependUnique(CPPPATH = [
45                 '../include',
46                 '../../include',
47                 '../include/internal',
48                 '../../../include',
49                 '../../../ocrandom/include',
50                 '../../../logger/include',
51                 '../../../stack/include',
52                 '../../../security/include',
53                 '../../../security/include/internal',
54                 '../../../security/provisioning/include/internal',
55                 '../../../../oc_logger/include',
56                 '../include/oxm',
57                 '../../../../../extlibs/base64',
58                 '../../../connectivity/inc',
59                 '../../../connectivity/inc/pkix',
60                 '../../../connectivity/common/inc',
61                 '../../../connectivity/api'
62                 ])
63
64 sptest_env.PrependUnique(LIBS = [   'ocpmapi',
65                                     'oc',
66                                     'octbstack_test',
67                                     'ocsrm',
68                                     'oc_logger_internal',
69                                     'connectivity_abstraction',
70                                     'coap'])
71
72 if sptest_env.get('SECURED') == '1':
73     sptest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
74
75 if not sptest_env.get('RELEASE'):
76         sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
77
78 if sptest_env.get('MULTIPLE_OWNER') == '1':
79         sptest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
80
81 if target_os in ['msys_nt', 'windows']:
82     sptest_env.AppendUnique(LIBS = ['octbstack_static', 'sqlite3'])
83 else:
84         sptest_env.AppendUnique(LIBS = ['octbstack'])
85
86 ######################################################################
87 # Source files and Targets
88 ######################################################################
89 unittest_src = ['pmutilitytest.cpp',
90                 'secureresourceprovider.cpp',
91                 'provisioningdatabasemanager.cpp',
92                 'ocprovisioningmanager.cpp',
93                 'credentialgeneratortest.cpp',
94                 ]
95
96 if target_os not in ['windows']:
97     unittest_src += [ 'otmunittest.cpp' ]
98
99 unittest = sptest_env.Program('unittest', unittest_src)
100
101 if target_os not in ['windows']:
102     sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
103     sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
104     Alias("test", [sample_server1, sample_server2])
105
106 Alias("test", [unittest])
107
108 sptest_env.AppendTarget('test')
109 # TODO: fix test for all supported configurations
110 if sptest_env.get('TEST') == '1' and sptest_env.get('SECURED') != '1':
111         if target_os in ['linux', 'windows']:
112                 out_dir = sptest_env.get('BUILD_DIR')
113                 result_dir = os.path.join(sptest_env.get('BUILD_DIR'), 'test_out') + os.sep
114                 if not os.path.isdir(result_dir):
115                         os.makedirs(result_dir)
116                 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
117                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
118                 sptest_env.AppendENVPath('PATH', sptest_env.get('BUILD_DIR'))
119                 run_test(sptest_env,
120                                  'resource_csdk_security_provisioning_unittest.memcheck',
121                                  'resource/csdk/security/provisioning/unittest/unittest')