[IOT-1612] Fix OCRDPublishWithDeviceId() to publish with a specific id
[platform/upstream/iotivity.git] / resource / unittests / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH 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 unittests_env = gtest_env.Clone()
27 src_dir = unittests_env.get('SRC_DIR')
28 target_os = unittests_env.get('TARGET_OS')
29 with_mq = unittests_env.get('WITH_MQ')
30 rd_mode = unittests_env.get('RD_MODE')
31
32 ######################################################################
33 # Build flags
34 ######################################################################
35 unittests_env.PrependUnique(CPPPATH = [
36                 '../include',
37                 '../oc_logger/include',
38                 '../csdk/stack/include',
39                 '../csdk/security/include',
40                 '../csdk/stack/include/internal',
41                 '../csdk/connectivity/api',
42                 '../csdk/connectivity/external/inc',
43                 '../csdk/ocsocket/include',
44                 '../c_common/ocrandom/include',
45                 '../csdk/logger/include',
46                 '#extlibs/hippomocks-master/HippoMocks',
47                 '#extlibs/hippomocks-master/HippoMocksTest'
48                 ])
49
50 unittests_env.AppendUnique(LIBPATH = [unittests_env.get('BUILD_DIR')])
51 unittests_env.PrependUnique(LIBS = [
52                 'oc',
53                 'octbstack',
54                 'oc_logger',
55                 'connectivity_abstraction',
56                 'coap'
57                 ])
58
59 if unittests_env.get('SECURED') == '1':
60         unittests_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
61
62 if unittests_env.get('LOGGING'):
63         unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
64
65 if unittests_env.get('WITH_CLOUD'):
66         unittests_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
67
68 ######################################################################
69 # Source files and Targets
70 ######################################################################
71
72 unittests_src = [
73                 'ConstructResourceTest.cpp',
74                 'OCPlatformTest.cpp',
75                 'OCRepresentationTest.cpp',
76                 'OCRepresentationEncodingTest.cpp',
77                 'OCResourceTest.cpp',
78                 'OCExceptionTest.cpp',
79                 'OCResourceResponseTest.cpp',
80                 'OCHeaderOptionTest.cpp'
81         ]
82
83 if (('SUB' in with_mq) or ('PUB' in with_mq) or ('BROKER' in with_mq)):
84         unittests_src = unittests_src + ['OCMQResourceTest.cpp']
85
86 if unittests_env.get('WITH_CLOUD'):
87         unittests_src = unittests_src + ['OCAccountManagerTest.cpp']
88
89 unittests = unittests_env.Program('unittests', unittests_src)
90
91 Alias("unittests", [unittests])
92
93 unittests_env.AppendTarget('unittests')
94 if unittests_env.get('TEST') == '1':
95         if target_os in ['linux']:
96                 from tools.scons.RunTest import *
97                 run_test(unittests_env,
98                          'resource_unittests_unittests.memcheck',
99                          'resource/unittests/unittests')
100
101 src_dir = unittests_env.get('SRC_DIR')
102 svr_db_src_dir = os.path.join(src_dir, 'resource/examples/')
103 svr_db_build_dir = os.path.join(unittests_env.get('BUILD_DIR'), 'resource', 'unittests') + os.sep
104 unittests_env.Alias("install",
105                     unittests_env.Install(svr_db_build_dir,
106                                           os.path.join(svr_db_src_dir,
107                                                        'oic_svr_db_client.dat')))