1 # //******************************************************************
3 # // Copyright 2015 Samsung Electronics All Rights Reserved.
5 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # // http://www.apache.org/licenses/LICENSE-2.0
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.
19 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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')
30 ######################################################################
32 ######################################################################
33 with_upstream_libcoap = sptest_env.get('WITH_UPSTREAM_LIBCOAP')
34 if with_upstream_libcoap == '1':
35 # For bring up purposes only, we manually copy the forked version to where the unforked version is downloaded.
36 sptest_env.AppendUnique(CPPPATH = ['#extlibs/libcoap/libcoap/include'])
38 # For bring up purposes only, the forked version will live here.
39 sptest_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
41 sptest_env.PrependUnique(CPPPATH = [
44 '../include/internal',
45 '../../../stack/include',
46 '../../../ocrandom/include',
47 '../../../logger/include',
48 '../../../stack/include',
49 '../../../security/include',
50 '../../../security/include/internal',
51 '../../../security/provisioning/include/internal',
52 '../../../../oc_logger/include',
54 '../../../../../extlibs/tinydtls',
55 '../../../../../extlibs/cjson',
56 '../../../../../extlibs/base64',
57 '../../../connectivity/inc',
58 '../../../connectivity/inc/pkix',
59 '../../../connectivity/common/inc',
60 '../../../connectivity/api',
61 '../../../../../extlibs/tinydtls'
63 sptest_env.AppendUnique(LIBPATH = [sptest_env.get('BUILD_DIR')])
64 sptest_env.PrependUnique(LIBS = [ 'ocpmapi',
69 'connectivity_abstraction',
72 if sptest_env.get('SECURED') == '1':
73 sptest_env.AppendUnique(LIBS = ['timer'])
74 sptest_env.AppendUnique(LIBS = ['tinydtls'])
76 if sptest_env.get('DTLS_WITH_X509') == '1':
77 sptest_env.AppendUnique(LIBS = ['CKManager'])
78 sptest_env.AppendUnique(LIBS = ['asn1'])
80 if sptest_env.get('WITH_TCP') == True:
81 sptest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
83 if not sptest_env.get('RELEASE'):
84 sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
86 if target_os in ['msys_nt', 'windows']:
87 sptest_env.AppendUnique(LIBS = ['ws2_32',
92 ######################################################################
93 # Source files and Targets
94 ######################################################################
95 unittest_src = ['pmutilitytest.cpp',
96 'secureresourceprovider.cpp',
97 'provisioningdatabasemanager.cpp',
98 'ocprovisioningmanager.cpp',
99 'credentialgeneratortest.cpp',
102 if target_os not in ['windows']:
103 unittest_src += [ 'otmunittest.cpp' ]
105 unittest = sptest_env.Program('unittest', unittest_src)
107 if target_os not in ['windows']:
108 sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
109 sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
110 Alias("test", [sample_server1, sample_server2])
112 Alias("test", [unittest])
114 sptest_env.AppendTarget('test')
115 if sptest_env.get('TEST') == '1':
116 if target_os in ['linux', 'windows']:
117 out_dir = sptest_env.get('BUILD_DIR')
118 result_dir = os.path.join(sptest_env.get('BUILD_DIR'), 'test_out') + os.sep
119 if not os.path.isdir(result_dir):
120 os.makedirs(result_dir)
121 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
122 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
123 sptest_env.AppendENVPath('PATH', sptest_env.get('BUILD_DIR'))
124 ut = sptest_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/unittest/unittest')