1 #******************************************************************
3 # Copyright 2014 Intel Mobile Communications GmbH All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
23 from tools.scons.RunTest import *
27 # SConscript file for Local PKI google tests
28 unittests_env = test_env.Clone()
29 src_dir = unittests_env.get('SRC_DIR')
30 target_os = unittests_env.get('TARGET_OS')
31 with_mq = unittests_env.get('WITH_MQ')
33 ######################################################################
35 ######################################################################
36 unittests_env.PrependUnique(CPPPATH = [
38 '../oc_logger/include',
40 '../csdk/stack/include',
41 '../csdk/security/include',
42 '../csdk/stack/include/internal',
43 '../csdk/connectivity/api',
44 '../csdk/connectivity/external/inc',
45 '../csdk/ocsocket/include',
46 '../c_common/ocrandom/include',
47 '../csdk/logger/include',
48 '#extlibs/hippomocks-master/HippoMocks',
49 '#extlibs/hippomocks-master/HippoMocksTest'
52 if target_os in ['windows']:
53 unittests_env.AppendUnique(CPPPATH = ['#extlibs/boost/boost'])
54 # On Windows, octbstack_test is a static LIB, that makes calls into static LIB ocsrm.
55 # On other platforms, octbstack_test is a shared LIB, that includes static LIB ocsrm.
56 unittests_env.AppendUnique(LIBS = ['ocsrm'])
58 unittests_env.AppendUnique(LIBPATH = [unittests_env.get('BUILD_DIR')])
59 unittests_env.PrependUnique(LIBS = [
63 'connectivity_abstraction',
67 if unittests_env.get('SECURED') == '1':
68 unittests_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
69 unittests_env.AppendUnique(LIBS = ['tinydtls'])
71 if unittests_env.get('LOGGING'):
72 unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
74 if unittests_env.get('WITH_CLOUD'):
75 unittests_env.AppendUnique(CPPDEFINES = ['WITH_CLOUD'])
77 ######################################################################
78 # Source files and Targets
79 ######################################################################
82 'ConstructResourceTest.cpp',
84 'OCRepresentationTest.cpp',
85 'OCRepresentationEncodingTest.cpp',
87 'OCExceptionTest.cpp',
88 'OCResourceResponseTest.cpp',
89 'OCHeaderOptionTest.cpp'
92 # TODO: Fix errors in the following Windows tests.
93 if target_os in ['windows']:
94 if '12.0' == unittests_env['MSVC_VERSION']:
95 unittests_src.remove('OCPlatformTest.cpp')
96 unittests_src.remove('OCRepresentationEncodingTest.cpp')
97 unittests_src.remove('OCRepresentationTest.cpp')
98 unittests_src.remove('OCResourceTest.cpp')
100 if (('SUB' in with_mq) or ('PUB' in with_mq) or ('BROKER' in with_mq)):
101 unittests_src = unittests_src + ['OCMQResourceTest.cpp']
103 if unittests_env.get('WITH_CLOUD'):
104 unittests_src = unittests_src + ['OCAccountManagerTest.cpp']
106 unittests = unittests_env.Program('unittests', unittests_src)
108 Alias("unittests", [unittests])
110 unittests_env.AppendTarget('unittests')
111 if unittests_env.get('TEST') == '1':
112 if target_os in ['windows']:
113 unittests_env.AppendENVPath('PATH', unittests_env.get('BUILD_DIR'))
114 if target_os in ['linux', 'windows']:
115 run_test(unittests_env,
116 'resource_unittests_unittests.memcheck',
117 'resource/unittests/unittests',
120 src_dir = unittests_env.get('SRC_DIR')
121 svr_db_src_dir = os.path.join(src_dir, 'resource/examples/')
122 svr_db_build_dir = os.path.join(unittests_env.get('BUILD_DIR'), 'resource', 'unittests') + os.sep
123 unittests_env.Alias("install",
124 unittests_env.Install(svr_db_build_dir,
125 os.path.join(svr_db_src_dir,
126 'oic_svr_db_client.dat')))