Imported Upstream version 1.1.1
[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 import os
22 import os.path
23
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 sptest_env = gtest_env.Clone()
27 src_dir = sptest_env.get('SRC_DIR')
28 target_os = sptest_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                 ])
55 sptest_env.AppendUnique(LIBPATH = [sptest_env.get('BUILD_DIR')])
56 sptest_env.PrependUnique(LIBS = [   'ocpmapi',
57                                     'oc',
58                                     'ocsrm',
59                                     'octbstack',
60                                     'oc_logger',
61                                     'connectivity_abstraction',
62                                     'coap',
63                                     'gtest',
64                                     'gtest_main'])
65
66 if sptest_env.get('SECURED') == '1':
67     sptest_env.AppendUnique(LIBS = ['tinydtls'])
68
69 if sptest_env.get('DTLS_WITH_X509') == '1':
70         sptest_env.AppendUnique(LIBS = ['CKManager'])
71         sptest_env.AppendUnique(LIBS = ['asn1'])
72
73 if not sptest_env.get('RELEASE'):
74         sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
75
76 if target_os not in ['msys_nt', 'windows']:
77         sptest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
78         sptest_env.AppendUnique(LIBS = ['dl', 'pthread'])
79
80 ######################################################################
81 # Source files and Targets
82 ######################################################################
83 unittest = sptest_env.Program('unittest', ['pmutilitytest.cpp',
84                                            'secureresourceprovider.cpp',
85                                            'provisioningdatabasemanager.cpp',
86                                            'ocprovisioningmanager.cpp', 'otmunittest.cpp', 
87                                            'credentialgeneratortest.cpp' ])
88
89 sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
90 sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
91
92 provisioning_unittest_src_dir = src_dir + '/resource/csdk/security/provisioning/unittest/'
93 provisioning_unittest_build_dir = sptest_env.get('BUILD_DIR') +'/resource/csdk/security/provisioning/unittest/'
94
95 Alias("test", [unittest, sample_server1, sample_server2])
96
97
98 sptest_env.AppendTarget('test')
99 if sptest_env.get('TEST') == '1':
100         if target_os in ['linux']:
101                 out_dir = sptest_env.get('BUILD_DIR')
102                 result_dir = os.path.join(sptest_env.get('BUILD_DIR'), 'test_out') + os.sep
103                 if not os.path.isdir(result_dir):
104                         os.makedirs(result_dir)
105                 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
106                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
107                 sptest_env.AppendENVPath('PATH', sptest_env.get('BUILD_DIR'))
108                 ut = sptest_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/unittest/unittest')
109                 AlwaysBuild ('ut')
110