Add DeviceID Parameter on SingleDeviceDiscovery function
[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/security/provisioning/include/cloud',
44                 '../../csdk/stack/include/internal',
45                 '../../csdk/connectivity/api',
46                 '../../csdk/connectivity/inc/pkix',
47                 '../../csdk/connectivity/external/inc',
48                 '../../csdk/ocsocket/include',
49                 '../../csdk/ocrandom/include',
50                 '../../csdk/logger/include',
51                 '../../csdk/connectivity/lib/libcoap-4.1.1/include',
52                 '../../../extlibs/cjson/',
53                 '../../../extlibs/hippomocks-master/HippoMocks',
54                 '../../../extlibs/hippomocks-master/HippoMocksTest'
55                 ])
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                 ])
67
68 if with_ra_ibb:
69         provisiontests_env.AppendUnique(LIBS = provisiontests_env['RALIBS'], LIBPATH = provisiontests_env['RALIBPATH'], RPATH = provisiontests_env['RARPATH'])
70         print "RALIBS = %s" % provisiontests_env['RALIBS']
71         print "RALIBPATH = %s" % provisiontests_env['RALIBPATH']
72         print "RARPATH = %s" % provisiontests_env['RARPATH']
73 else :
74         if with_ra:
75                 provisiontests_env.AppendUnique(LIBS = ['ra_xmpp'])
76
77 if provisiontests_env.get('SECURED') == '1':
78         provisiontests_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
79
80
81 if provisiontests_env.get('LOGGING'):
82         provisiontests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
83
84 ######################################################################
85 # Source files and Targets
86 ######################################################################
87 ocprovisiontest_src = [
88         'OCProvisioningTest.cpp'
89         ]
90
91 if provisiontests_env.get('WITH_TCP') == True:
92         ocprovisiontest_src = ocprovisiontest_src + [
93         'OCCloudProvisioningTest.cpp'
94         ]
95
96 unittests = provisiontests_env.Program('provisiontests', ocprovisiontest_src)
97
98 Alias("provisiontests", [unittests])
99
100 provisiontests_env.AppendTarget('provisiontests')
101 if provisiontests_env.get('TEST') == '1':
102         if target_os in ['linux']:
103                 out_dir = provisiontests_env.get('BUILD_DIR')
104                 result_dir = os.path.join(provisiontests_env.get('BUILD_DIR'), 'test_out') + os.sep
105                 if not os.path.isdir(result_dir):
106                         os.makedirs(result_dir)
107                 provisiontests_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
108                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
109                 ut = provisiontests_env.Command ('ut', None, out_dir + 'resource/provisioning/unittests/provisiontests')
110                 AlwaysBuild ('ut')
111
112 src_dir = provisiontests_env.get('SRC_DIR')
113 svr_db_src_dir = src_dir + '/resource/provisioning/examples/'
114 svr_db_build_dir = os.path.join(provisiontests_env.get('BUILD_DIR'), 'resource', 'provisioning', 'unittests')
115 provisiontests_env.Alias("install", provisiontests_env.Install( svr_db_build_dir,
116                                 svr_db_src_dir + 'oic_svr_db_client.json'))