riscv64: Add support for RISC-V
[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 from tools.scons.RunTest import run_test
24
25 # SConscript file for Local PKI google tests
26 gtest_env = SConscript('#extlibs/gtest/SConscript')
27 provisiontests_env = gtest_env.Clone()
28 src_dir = provisiontests_env.get('SRC_DIR')
29 target_os = provisiontests_env.get('TARGET_OS')
30 with_ra = provisiontests_env.get('WITH_RA')
31 with_ra_ibb = provisiontests_env.get('WITH_RA_IBB')
32
33 ######################################################################
34 # Build flags
35 ######################################################################
36 provisiontests_env.PrependUnique(CPPPATH = [
37                 '../../include',
38                 '../../oc_logger/include',
39                 '../../csdk/stack/include',
40                 '../../csdk/security/include',
41                 '../../csdk/security/provisioning/include',
42                 '../../csdk/security/provisioning/include/oxm',
43                 '../../csdk/security/provisioning/include/internal',
44                 '../../csdk/security/provisioning/include/cloud',
45                 '../../csdk/stack/include/internal',
46                 '../../csdk/connectivity/api',
47                 '../../csdk/connectivity/inc/pkix',
48                 '../../csdk/connectivity/external/inc',
49                 '../../csdk/ocsocket/include',
50                 '../../csdk/ocrandom/include',
51                 '../../csdk/logger/include',
52                 '../../csdk/connectivity/lib/libcoap-4.1.1/include',
53                 '../../../extlibs/cjson/',
54                 '../../../extlibs/hippomocks-master/HippoMocks',
55                 '../../../extlibs/hippomocks-master/HippoMocksTest'
56                 ])
57
58 provisiontests_env.AppendUnique(LIBPATH = [provisiontests_env.get('BUILD_DIR')])
59 provisiontests_env.PrependUnique(LIBS = [
60         'ocprovision',
61                 'oc',
62                 'ocpmapi',
63                 'octbstack',
64                 'oc_logger',
65                 'connectivity_abstraction',
66                 'coap'
67                 ])
68
69 if with_ra_ibb:
70         provisiontests_env.AppendUnique(LIBS = provisiontests_env['RALIBS'], LIBPATH = provisiontests_env['RALIBPATH'], RPATH = provisiontests_env['RARPATH'])
71         print "RALIBS = %s" % provisiontests_env['RALIBS']
72         print "RALIBPATH = %s" % provisiontests_env['RALIBPATH']
73         print "RARPATH = %s" % provisiontests_env['RARPATH']
74 else :
75         if with_ra:
76                 provisiontests_env.AppendUnique(LIBS = ['ra_xmpp'])
77
78 if provisiontests_env.get('SECURED') == '1':
79         provisiontests_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
80
81
82 if provisiontests_env.get('LOGGING'):
83         provisiontests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
84
85 ######################################################################
86 # Source files and Targets
87 ######################################################################
88 ocprovisiontest_src = [
89         'OCProvisioningTest.cpp'
90         ]
91
92 if provisiontests_env.get('WITH_TCP') == True:
93         ocprovisiontest_src = ocprovisiontest_src + [
94         'OCCloudProvisioningTest.cpp'
95         ]
96
97 unittests = provisiontests_env.Program('provisiontests', ocprovisiontest_src)
98
99 Alias("provisiontests", [unittests])
100
101 provisiontests_env.AppendTarget('provisiontests')
102 if provisiontests_env.get('TEST') == '1':
103         if target_os in ['linux']:
104                 out_dir = provisiontests_env.get('BUILD_DIR')
105                 result_dir = os.path.join(provisiontests_env.get('BUILD_DIR'), 'test_out') + os.sep
106                 if not os.path.isdir(result_dir):
107                         os.makedirs(result_dir)
108                 provisiontests_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
109                 provisiontests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
110                 run_test(provisiontests_env,
111 # TODO: fix this test on linux and remove this comment line
112 #                                'resource_provisioning_unittests.memcheck',
113                                  '',
114                                  'resource/provisioning/unittests/provisiontests')
115
116 src_dir = provisiontests_env.get('SRC_DIR')
117 svr_db_src_dir = src_dir + '/resource/provisioning/examples/'
118 svr_db_build_dir = os.path.join(provisiontests_env.get('BUILD_DIR'), 'resource', 'provisioning', 'unittests')
119 provisiontests_env.Alias("install", provisiontests_env.Install( svr_db_build_dir,
120                                 svr_db_src_dir + 'oic_svr_db_client.json'))