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