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