ee406d52f96dc65606979a27ea24b1208e58ac39
[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
29 ######################################################################
30 # Build flags
31 ######################################################################
32 sptest_env.PrependUnique(CPPPATH = [
33                 '../../../connectivity/inc',
34                 '../../../connectivity/api',
35                 '../../include',
36                 '../../../../../extlibs/tinydtls',
37                 '../include/internal',
38                 '../include/oxm',
39                 '../../../logger/include',
40                 '../../../stack/include',
41                 '../../../../oc_logger/include',
42                 '../../../../../extlibs/gtest/gtest-1.7.0/include',
43                 '../include',
44                 '../include/internal'
45                 ])
46 sptest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
47 sptest_env.AppendUnique(LIBS = ['-lpthread','-ldl'])
48 sptest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
49 sptest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
50 sptest_env.PrependUnique(LIBS = [   'ocpmapi',
51                                     'oc',
52                                     'ocsrm',
53                                     'octbstack',
54                                     'oc_logger',
55                                     'connectivity_abstraction',
56                                     'coap',
57                                     'gtest',
58                                     'gtest_main'])
59
60 if env.get('SECURED') == '1':
61     sptest_env.AppendUnique(LIBS = ['tinydtls'])
62 if env.get('DTLS_WITH_X509') == '1':
63         sptest_env.AppendUnique(LIBS = ['CKManager'])
64         sptest_env.AppendUnique(LIBS = ['asn1'])
65
66 if not env.get('RELEASE'):
67         sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
68
69 ######################################################################
70 # Source files and Targets
71 ######################################################################
72 unittest = sptest_env.Program('unittest', ['pmutilitytest.cpp', 'otmunittest.cpp',
73                                            'secureresourceprovider.cpp',
74                                            'provisioningdatabasemanager.cpp',
75                                            'ocprovisioningmanager.cpp' ])
76
77 Alias("test", [unittest])
78
79 env.AppendTarget('test')
80 if env.get('TEST') == '1':
81         target_os = env.get('TARGET_OS')
82         if target_os == 'linux':
83                 out_dir = env.get('BUILD_DIR')
84                 result_dir = env.get('BUILD_DIR') + '/test_out/'
85                 if not os.path.isdir(result_dir):
86                         os.makedirs(result_dir)
87                 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
88                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
89                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
90                 ut = sptest_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/unittest/unittest')
91                 AlwaysBuild ('ut')
92