[IOT-2060] Don't force-link with routingmanager
[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 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         sptest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
39 else:
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                 '../../../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/base64',
56                 '../../../connectivity/inc',
57                 '../../../connectivity/inc/pkix',
58                 '../../../connectivity/common/inc',
59                 '../../../connectivity/api'
60                 ])
61
62 sptest_env.PrependUnique(LIBS = [   'ocpmapi_internal',
63                                     'oc',
64                                     'octbstack_internal',
65                                     'ocsrm',
66                                     'routingmanager',
67                                     'oc_logger_internal',
68                                     'connectivity_abstraction',
69                                     'coap'])
70
71 if sptest_env.get('SECURED') == '1':
72     sptest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
73
74 if not sptest_env.get('RELEASE'):
75         sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
76
77 if sptest_env.get('MULTIPLE_OWNER') == '1':
78         sptest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
79
80 sptest_env.AppendUnique(LIBS = ['octbstack_internal'])
81
82 if target_os in ['msys_nt', 'windows']:
83     sptest_env.AppendUnique(LIBS = ['sqlite3'])
84 else:
85     if target_os in ['linux', 'tizen']:
86         sptest_env.ParseConfig('pkg-config --cflags --libs sqlite3')
87
88 ######################################################################
89 # Source files and Targets
90 ######################################################################
91 unittest_src = ['pmutilitytest.cpp',
92                 'secureresourceprovider.cpp',
93                 'provisioningdatabasemanager.cpp',
94                 'ocprovisioningmanager.cpp',
95                 'credentialgeneratortest.cpp',
96                 ]
97
98 if target_os not in ['windows']:
99     unittest_src += [ 'otmunittest.cpp' ]
100
101 unittest = sptest_env.Program('unittest', unittest_src)
102
103 if target_os not in ['windows']:
104     sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
105     sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
106     Alias("test", [sample_server1, sample_server2])
107
108 Alias("test", [unittest])
109
110 sptest_env.AppendTarget('test')
111 # TODO: fix test for all supported configurations
112 if sptest_env.get('TEST') == '1' and sptest_env.get('SECURED') != '1':
113         if target_os in ['linux', 'windows']:
114                 out_dir = sptest_env.get('BUILD_DIR')
115                 result_dir = os.path.join(sptest_env.get('BUILD_DIR'), 'test_out') + os.sep
116                 if not os.path.isdir(result_dir):
117                         os.makedirs(result_dir)
118                 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
119                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
120                 sptest_env.AppendENVPath('PATH', sptest_env.get('BUILD_DIR'))
121                 run_test(sptest_env,
122                                  'resource_csdk_security_provisioning_unittest.memcheck',
123                                  'resource/csdk/security/provisioning/unittest/unittest')