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 # //-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
25 sptest_env = env.Clone()
27 src_dir = sptest_env.get('SRC_DIR')
28 target_os = env.get('TARGET_OS')
30 ######################################################################
32 ######################################################################
33 sptest_env.PrependUnique(CPPPATH = [
36 '../include/internal',
37 '../../../stack/include',
38 '../../../ocrandom/include',
39 '../../../logger/include',
40 '../../../stack/include',
41 '../../../security/include',
42 '../../../security/include/internal',
43 '../../../security/provisioning/include/internal',
44 '../../../../oc_logger/include',
46 '../../../../../extlibs/tinydtls',
47 '../../../../../extlibs/cjson',
48 '../../../../../extlibs/base64',
49 '../../../connectivity/inc',
50 '../../../connectivity/common/inc',
51 '../../../connectivity/lib/libcoap-4.1.1',
52 '../../../connectivity/api',
53 '../../../../../extlibs/tinydtls',
54 '../../../../../extlibs/gtest/gtest-1.7.0/include'
56 sptest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
57 sptest_env.AppendUnique(LIBS = ['-lpthread','-ldl'])
58 sptest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
59 sptest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
60 sptest_env.PrependUnique(LIBS = [ 'ocpmapi',
65 'connectivity_abstraction',
70 if env.get('SECURED') == '1':
71 sptest_env.AppendUnique(LIBS = ['timer'])
72 sptest_env.AppendUnique(LIBS = ['tinydtls'])
73 if env.get('DTLS_WITH_X509') == '1':
74 sptest_env.AppendUnique(LIBS = ['CKManager'])
75 sptest_env.AppendUnique(LIBS = ['asn1'])
77 if not env.get('RELEASE'):
78 sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
80 if target_os in ['msys_nt', 'windows']:
81 sptest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
82 sptest_env.AppendUnique(LIBS = ['ws2_32',
86 ######################################################################
87 # Source files and Targets
88 ######################################################################
89 unittest_src = ['pmutilitytest.cpp',
90 'secureresourceprovider.cpp',
91 'provisioningdatabasemanager.cpp',
92 'ocprovisioningmanager.cpp',
93 'credentialgeneratortest.cpp',
96 if target_os not in ['windows']:
97 unittest_src += [ 'otmunittest.cpp' ]
99 unittest = sptest_env.Program('unittest', unittest_src)
101 if target_os not in ['windows']:
102 sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
103 sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
104 Alias("test", [sample_server1, sample_server2])
106 Alias("test", [unittest])
108 env.AppendTarget('test')
109 if env.get('TEST') == '1':
110 if target_os in ['linux', 'windows']:
111 out_dir = env.get('BUILD_DIR')
112 result_dir = env.get('BUILD_DIR') + '/test_out/'
113 if not os.path.isdir(result_dir):
114 os.makedirs(result_dir)
115 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
116 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
117 sptest_env.AppendENVPath('PATH', env.get('BUILD_DIR'))
118 sptest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
119 ut = sptest_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/unittest/unittest')