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