Imported Upstream version 1.1.1
[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
28 src_dir = catest_env.get('SRC_DIR')
29 target_os = catest_env.get('TARGET_OS')
30 target_transport = catest_env.get('TARGET_TRANSPORT')
31
32 ######################################################################
33 # Build flags
34 ######################################################################
35 catest_env.PrependUnique(CPPPATH = [
36                 '../../ocsocket/include',
37                 '../../logger/include',
38                 '../../stack/include',
39                 '../../extlibs/cjson',
40                 '../../../oc_logger/include',
41                ])
42
43 tmplist = catest_env['LINKFLAGS'][:]
44 if '-lpthread' in tmplist:
45     tmplist.remove('-lpthread')
46     catest_env.Replace(LINKFLAGS = tmplist)
47
48 if target_os not in ['windows']:
49         catest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
50 catest_env.AppendUnique(LIBPATH = [catest_env.get('BUILD_DIR')])
51 catest_env.PrependUnique(LIBS = ['gtest', 'gtest_main'])
52 catest_env.PrependUnique(LIBS = ['octbstack',
53                                     'connectivity_abstraction',
54                                     'coap'])
55
56 if target_os not in ['arduino', 'darwin', 'ios']:
57         catest_env.AppendUnique(LIBS=['rt'])
58
59 if catest_env.get('SECURED') == '1':
60         catest_env.AppendUnique(LIBS = ['tinydtls'])
61
62 if catest_env.get('LOGGING'):
63         catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
64
65 if target_os not in ['msys_nt', 'windows']:
66         catest_env.AppendUnique(LIBS = ['m'])
67         catest_env.PrependUnique(LIBS = ['pthread'])
68
69 ######################################################################
70 # Source files and Targets
71 ######################################################################
72 catests = catest_env.Program('catests', ['catests.cpp',
73                                          'caprotocolmessagetest.cpp',
74                                                'ca_api_unittest.cpp',
75                                                'camutex_tests.cpp',
76                                                'uarraylist_test.cpp'
77                                                ])
78
79 Alias("test", [catests])
80
81 catest_env.AppendTarget('test')
82 if catest_env.get('TEST') == '1':
83         if target_os in ['linux']:
84                 catest_env.AppendENVPath('PATH', catest_env.get('BUILD_DIR'))
85                 from tools.scons.RunTest import *
86                 run_test(catest_env,
87                          'resource_csdk_connectivity_test.memcheck',
88                          'resource/csdk/connectivity/test/catests')