Added UTC to cover uncovered APIs and Corrected build issue in credentialgenerator.h
[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                 '../include',
34                 '../../include',
35                 '../include/internal',
36                 '../../../stack/include',
37                 '../../../ocrandom/include',
38                 '../../../logger/include',
39                 '../../../stack/include',
40                 '../../../security/include',
41                 '../../../security/include/internal',
42                 '../../../security/provisioning/include/internal',
43                 '../../../../oc_logger/include',
44                 '../include/oxm',
45                 '../../../../../extlibs/tinydtls',
46                 '../../../../../extlibs/cjson',
47                 '../../../../../extlibs/base64',
48                 '../../../connectivity/inc',
49                 '../../../connectivity/common/inc',
50                 '../../../connectivity/lib/libcoap-4.1.1',
51                 '../../../connectivity/api',
52                 '../../../../../extlibs/tinydtls',
53                 '../../../../../extlibs/gtest/gtest-1.7.0/include'
54                 ])
55 sptest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
56 sptest_env.AppendUnique(LIBS = ['-lpthread','-ldl'])
57 sptest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
58 sptest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
59 sptest_env.PrependUnique(LIBS = [   'ocpmapi',
60                                     'oc',
61                                     'ocsrm',
62                                     'octbstack',
63                                     'oc_logger',
64                                     'connectivity_abstraction',
65                                     'coap',
66                                     'gtest',
67                                     'gtest_main'])
68
69 if env.get('SECURED') == '1':
70     sptest_env.AppendUnique(LIBS = ['tinydtls'])
71 if env.get('DTLS_WITH_X509') == '1':
72         sptest_env.AppendUnique(LIBS = ['CKManager'])
73         sptest_env.AppendUnique(LIBS = ['asn1'])
74
75 if not env.get('RELEASE'):
76         sptest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
77
78 ######################################################################
79 # Source files and Targets
80 ######################################################################
81 unittest = sptest_env.Program('unittest', ['pmutilitytest.cpp',
82                                            'secureresourceprovider.cpp',
83                                            'provisioningdatabasemanager.cpp',
84                                            'ocprovisioningmanager.cpp', 'otmunittest.cpp', 
85                                            'credentialgeneratortest.cpp' ])
86
87 sample_server1 = sptest_env.Program('sample_server1', ['sampleserver1.cpp'])
88 sample_server2 = sptest_env.Program('sample_server2', ['sampleserver2.cpp'])
89
90 provisioning_unittest_src_dir = src_dir + '/resource/csdk/security/provisioning/unittest/'
91 provisioning_unittest_build_dir = env.get('BUILD_DIR') +'/resource/csdk/security/provisioning/unittest/'
92
93 Alias("test", [unittest, sample_server1, sample_server2])
94
95 env.AppendTarget('test')
96 if env.get('TEST') == '1':
97         target_os = env.get('TARGET_OS')
98         if target_os == 'linux':
99                 out_dir = env.get('BUILD_DIR')
100                 result_dir = env.get('BUILD_DIR') + '/test_out/'
101                 if not os.path.isdir(result_dir):
102                         os.makedirs(result_dir)
103                 sptest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
104                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
105                 sptest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
106                 ut = sptest_env.Command ('ut', None, out_dir + '/resource/csdk/security/provisioning/unittest/unittest')
107                 AlwaysBuild ('ut')
108