f8a2f659f2c4dac3fadd05060745e949425d5db0
[platform/upstream/iotivity.git] / resource / csdk / connectivity / test / 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 catest_env = gtest_env.Clone()
27 target_os = catest_env.get('TARGET_OS')
28 target_transport = catest_env.get('TARGET_TRANSPORT')
29 rd_mode = catest_env.get('RD_MODE')
30
31 ######################################################################
32 # Build flags
33 ######################################################################
34 catest_env.PrependUnique(CPPPATH = [
35                 '../../logger/include',
36                 '../../stack/include',
37                 '../../extlibs/cjson',
38                 '../../../oc_logger/include',
39                ])
40
41 catest_env.AppendUnique(LIBPATH = [catest_env.get('BUILD_DIR')])
42 catest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
43 catest_env.PrependUnique(LIBS = ['octbstack',
44                                     'connectivity_abstraction',
45                                     'coap'])
46
47 if target_os not in ['arduino', 'darwin', 'ios', 'msys_nt', 'windows']:
48         catest_env.AppendUnique(LIBS=['rt'])
49
50 if catest_env.get('SECURED') == '1':
51         catest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
52
53 if 'CLIENT' in rd_mode or 'SERVER' in rd_mode:
54         catest_env.PrependUnique(LIBS = ['resource_directory'])
55
56 if catest_env.get('LOGGING'):
57         catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
58
59 if target_os in ['msys_nt', 'windows']:
60         catest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
61         catest_env.AppendUnique(LIBS = ['ws2_32',
62                                         'advapi32',
63                                         'bcrypt',
64                                         'iphlpapi'])
65 else:
66         catest_env.AppendUnique(LIBS = ['m'])
67
68 ######################################################################
69 # Source files and Targets
70 ######################################################################
71
72 tests_src = [
73         'catests.cpp',
74         'caprotocolmessagetest.cpp',
75         'ca_api_unittest.cpp',
76         'camutex_tests.cpp',
77         'uarraylist_test.cpp',
78         'ulinklist_test.cpp',
79         'uqueue_test.cpp'
80 ]
81
82 if (('IP' in target_transport) or ('ALL' in target_transport)):
83         if target_os != 'arduino':
84                 tests_src = tests_src + ['cablocktransfertest.cpp']
85
86 if catest_env.get('SECURED') == '1' and catest_env.get('WITH_TCP') == True:
87         tests_src = tests_src + ['ssladapter_test.cpp']
88
89 catests = catest_env.Program('catests', tests_src)
90
91 Alias("test", [catests])
92
93 catest_env.AppendTarget('test')
94 if catest_env.get('TEST') == '1':
95         if target_os in ['linux', 'windows']:
96                 catest_env.AppendENVPath('PATH', catest_env.get('BUILD_DIR'))
97                 from tools.scons.RunTest import *
98                 run_test(catest_env,
99                          'resource_csdk_connectivity_test.memcheck',
100                          'resource/csdk/connectivity/test/catests')