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