Imported Upstream version 1.1.1
[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 os
22 import os.path
23
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 provisiontests_env = gtest_env.Clone()
27 src_dir = provisiontests_env.get('SRC_DIR')
28 target_os = provisiontests_env.get('TARGET_OS')
29 with_ra = provisiontests_env.get('WITH_RA')
30 with_ra_ibb = provisiontests_env.get('WITH_RA_IBB')
31
32 ######################################################################
33 # Build flags
34 ######################################################################
35 provisiontests_env.PrependUnique(CPPPATH = [
36                 '../../include',
37                 '../../oc_logger/include',
38                 '../../csdk/stack/include',
39                 '../../csdk/security/include',
40                 '../../csdk/security/provisioning/include',
41                 '../../csdk/security/provisioning/include/oxm',
42                 '../../csdk/security/provisioning/include/internal',
43                 '../../csdk/stack/include/internal',
44                 '../../csdk/connectivity/api',
45                 '../../csdk/connectivity/external/inc',
46                 '../../csdk/ocsocket/include',
47                 '../../csdk/ocrandom/include',
48                 '../../csdk/logger/include',
49                 '../../../extlibs/hippomocks-master/HippoMocks',
50                 '../../../extlibs/hippomocks-master/HippoMocksTest'
51                 ])
52
53 if target_os not in ['windows']:
54         provisiontests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
55         provisiontests_env.AppendUnique(LIBS = ['-lpthread', '-ldl'])
56
57 provisiontests_env.AppendUnique(LIBPATH = [provisiontests_env.get('BUILD_DIR')])
58 provisiontests_env.PrependUnique(LIBS = [
59         'ocprovision',
60                 'oc',
61                 'ocpmapi',
62                 'octbstack',
63                 'oc_logger',
64                 'connectivity_abstraction',
65                 'coap',
66                 'gtest',
67                 'gtest_main',
68                 ])
69
70 if with_ra_ibb:
71         provisiontests_env.AppendUnique(LIBS = provisiontests_env['RALIBS'], LIBPATH = provisiontests_env['RALIBPATH'], RPATH = provisiontests_env['RARPATH'])
72         print "RALIBS = %s" % provisiontests_env['RALIBS']
73         print "RALIBPATH = %s" % provisiontests_env['RALIBPATH']
74         print "RARPATH = %s" % provisiontests_env['RARPATH']
75 else :
76         if with_ra:
77                 provisiontests_env.AppendUnique(LIBS = ['ra_xmpp'])
78
79 if provisiontests_env.get('SECURED') == '1':
80     provisiontests_env.AppendUnique(LIBS = ['tinydtls'])
81     provisiontests_env.AppendUnique(LIBS = ['timer'])
82 if provisiontests_env.get('DTLS_WITH_X509') == '1':
83         provisiontests_env.AppendUnique(LIBS = ['CKManager'])
84         provisiontests_env.AppendUnique(LIBS = ['asn1'])
85
86
87 if provisiontests_env.get('LOGGING'):
88         provisiontests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
89
90 ######################################################################
91 # Source files and Targets
92 ######################################################################
93 unittests = provisiontests_env.Program('provisiontests', ['OCProvisioningTest.cpp'])
94
95 Alias("provisiontests", [unittests])
96
97 provisiontests_env.AppendTarget('provisiontests')
98 if provisiontests_env.get('TEST') == '1':
99         if target_os in ['linux']:
100                 out_dir = provisiontests_env.get('BUILD_DIR')
101                 result_dir = os.path.join(provisiontests_env.get('BUILD_DIR'), 'test_out') + os.sep
102                 if not os.path.isdir(result_dir):
103                         os.makedirs(result_dir)
104                 provisiontests_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
105                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
106                 ut = provisiontests_env.Command ('ut', None, out_dir + 'resource/provisioning/unittests/provisiontests')
107                 AlwaysBuild ('ut')
108
109 src_dir = provisiontests_env.get('SRC_DIR')
110 svr_db_src_dir = src_dir + '/resource/provisioning/examples/'
111 svr_db_build_dir = os.path.join(provisiontests_env.get('BUILD_DIR'), 'resource', 'provisioning', 'unittests')
112 provisiontests_env.Alias("install", provisiontests_env.Install( svr_db_build_dir,
113                                 svr_db_src_dir + 'oic_svr_db_client.json'))