7c36b065a251d79b48a50d298a381198bddde6de
[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
22 Import('env')
23 import os
24 import os.path
25 sptest_env = env.Clone()
26
27 src_dir = sptest_env.get('SRC_DIR')
28 target_os = env.get('TARGET_OS')
29
30 ######################################################################
31 # Build flags
32 ######################################################################
33 sptest_env.PrependUnique(CPPPATH = [
34                 '../include',
35                 '../../include',
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',
45                 '../include/oxm',
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'
55                 ])
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',
61                                     'oc',
62                                     'ocsrm',
63                                     'octbstack',
64                                     'oc_logger',
65                                     'connectivity_abstraction',
66                                     'coap',
67                                     'gtest',
68                                     'gtest_main'])
69
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'])
76
77 if not env.get('RELEASE'):
78         sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
79
80 if target_os in ['msys_nt', 'windows']:
81     sptest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
82     sptest_env.AppendUnique(LIBS = ['ws2_32',
83                                     'advapi32',
84                                     'iphlpapi'])
85
86 ######################################################################
87 # Source files and Targets
88 ######################################################################
89 unittest_src = ['pmutilitytest.cpp',
90                 'secureresourceprovider.cpp',
91                 'provisioningdatabasemanager.cpp',
92                 'ocprovisioningmanager.cpp',
93                 'credentialgeneratortest.cpp',
94                 ]
95
96 if target_os not in ['windows']:
97     unittest_src += [ 'otmunittest.cpp' ]
98
99 unittest = sptest_env.Program('unittest', unittest_src)
100
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])
105
106 Alias("test", [unittest])
107
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')
120                 AlwaysBuild ('ut')
121