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 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 from tools.scons.RunTest import run_test
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')
31 ######################################################################
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'])
39 # For bring up purposes only, the forked version will live here.
40 sptest_env.AppendUnique(CPPPATH = ['../../../connectivity/lib/libcoap-4.1.1/include'])
42 sptest_env.PrependUnique(CPPPATH = [
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',
55 '../../../../../extlibs/cjson',
56 '../../../../../extlibs/base64',
57 '../../../connectivity/inc',
58 '../../../connectivity/inc/pkix',
59 '../../../connectivity/common/inc',
60 '../../../connectivity/api'
62 sptest_env.AppendUnique(LIBPATH = [sptest_env.get('BUILD_DIR')])
63 sptest_env.PrependUnique(LIBS = [ 'ocpmapi',
67 'connectivity_abstraction',
70 if sptest_env.get('SECURED') == '1':
71 sptest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
73 if not sptest_env.get('RELEASE'):
74 sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
76 if sptest_env.get('MULTIPLE_OWNER') == '1':
77 sptest_env.AppendUnique(CPPDEFINES=['MULTIPLE_OWNER'])
79 if target_os in ['msys_nt', 'windows']:
80 sptest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
81 sptest_env.AppendUnique(LIBS = ['ws2_32',
87 sptest_env.AppendUnique(LIBS = ['octbstack'])
89 ######################################################################
90 # Source files and Targets
91 ######################################################################
92 unittest_src = ['pmutilitytest.cpp',
93 'secureresourceprovider.cpp',
94 'provisioningdatabasemanager.cpp',
95 'ocprovisioningmanager.cpp',
96 'credentialgeneratortest.cpp',
99 if target_os not in ['windows']:
100 unittest_src += [ 'otmunittest.cpp' ]
102 unittest = sptest_env.Program('unittest', unittest_src)
104 if target_os not in ['windows']:
105 sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
106 sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
107 Alias("test", [sample_server1, sample_server2])
109 Alias("test", [unittest])
111 sptest_env.AppendTarget('test')
112 # TODO: fix this test on linux and remove this comment line
113 if sptest_env.get('TEST') == '1':
114 if target_os in ['windows']:
115 out_dir = sptest_env.get('BUILD_DIR')
116 result_dir = os.path.join(sptest_env.get('BUILD_DIR'), 'test_out') + os.sep
117 if not os.path.isdir(result_dir):
118 os.makedirs(result_dir)
119 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
120 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
121 sptest_env.AppendENVPath('PATH', sptest_env.get('BUILD_DIR'))
123 'resource_csdk_security_provisioning_unittest.memcheck',
124 'resource/csdk/security/provisioning/unittest/unittest')