Merge branch 'master' into cloud-interface
[platform/upstream/iotivity.git] / resource / provisioning / unittests / 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('env')
22 import os
23 import os.path
24 provisiontests_env = env.Clone()
25
26 src_dir = provisiontests_env.get('SRC_DIR')
27 ######################################################################
28 # Build flags
29 ######################################################################
30 provisiontests_env.PrependUnique(CPPPATH = [
31                 '../../include',
32                 '../../oc_logger/include',
33                 '../../csdk/stack/include',
34                 '../../csdk/security/include',
35                 '../../csdk/security/provisioning/include',
36                 '../../csdk/security/provisioning/include/oxm',
37                 '../../csdk/security/provisioning/include/internal',
38                 '../../csdk/stack/include/internal',
39                 '../../csdk/connectivity/api',
40                 '../../csdk/connectivity/external/inc',
41                 '../../csdk/ocsocket/include',
42                 '../../csdk/ocrandom/include',
43                 '../../csdk/logger/include',
44                 '../../../extlibs/gtest/gtest-1.7.0/include',
45                 '../../../extlibs/hippomocks-master/HippoMocks',
46                 '../../../extlibs/hippomocks-master/HippoMocksTest'
47                 ])
48
49 provisiontests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
50 provisiontests_env.AppendUnique(LIBS = ['-lpthread', '-ldl'])
51 provisiontests_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
52 provisiontests_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
53 provisiontests_env.PrependUnique(LIBS = [
54         'ocprovision',
55                 'oc',
56                 'ocpmapi',
57                 'octbstack',
58                 'oc_logger',
59                 'connectivity_abstraction',
60                 'coap',
61                 'gtest',
62                 'gtest_main',
63                 ])
64
65 if env.get('SECURED') == '1':
66     provisiontests_env.AppendUnique(LIBS = ['tinydtls'])
67 if env.get('DTLS_WITH_X509') == '1':
68         provisiontests_env.AppendUnique(LIBS = ['CKManager'])
69         provisiontests_env.AppendUnique(LIBS = ['asn1'])
70
71
72 if env.get('LOGGING'):
73         provisiontests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
74
75 ######################################################################
76 # Source files and Targets
77 ######################################################################
78 unittests = provisiontests_env.Program('provisiontests', ['OCProvisioningTest.cpp'])
79
80 Alias("provisiontests", [unittests])
81
82 env.AppendTarget('provisiontests')
83 if env.get('TEST') == '1':
84         target_os = env.get('TARGET_OS')
85         if target_os == 'linux':
86                 out_dir = env.get('BUILD_DIR')
87                 result_dir = env.get('BUILD_DIR') + '/test_out/'
88                 if not os.path.isdir(result_dir):
89                         os.makedirs(result_dir)
90                 provisiontests_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
91                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
92                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
93                 ut = provisiontests_env.Command ('ut', None, out_dir + 'resource/provisioning/unittests/provisiontests')
94                 AlwaysBuild ('ut')
95
96 src_dir = provisiontests_env.get('SRC_DIR')
97 svr_db_src_dir = src_dir + '/resource/provisioning/examples/'
98 svr_db_build_dir = env.get('BUILD_DIR') +'/resource/provisioning/unittests/'
99 provisiontests_env.Alias("install", provisiontests_env.Install( svr_db_build_dir,
100                                 svr_db_src_dir + 'oic_svr_db_client.json'))