Merge branch 'master' into easysetup
[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('env')
22 import os
23 import os.path
24 catest_env = env.Clone()
25
26 src_dir = catest_env.get('SRC_DIR')
27
28 ######################################################################
29 # Build flags
30 ######################################################################
31 catest_env.PrependUnique(CPPPATH = [
32                 '../../ocsocket/include',
33                 '../../logger/include',
34                 '../../stack/include',
35                 '../../ocmalloc/include',
36                 '../../extlibs/cjson',
37                 '../../../oc_logger/include',
38                 '../../../../extlibs/gtest/gtest-1.7.0/include'
39                ])
40
41 tmplist = catest_env['LINKFLAGS'][:]
42 if '-lpthread' in tmplist:
43     tmplist.remove('-lpthread')
44     catest_env.Replace(LINKFLAGS = tmplist)
45
46 catest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
47 catest_env.AppendUnique(LIBS = ['pthread'])
48 catest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
49 catest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
50 catest_env.PrependUnique(LIBS = ['m',
51                                     'octbstack',
52                                     'connectivity_abstraction',
53                                     'coap',
54                                     'gtest',
55                                     'gtest_main'])
56
57 target_os = env.get('TARGET_OS')
58
59 if target_os not in ['arduino', 'darwin', 'ios']:
60         catest_env.AppendUnique(LIBS=['rt'])
61
62 if target_os != 'darwin':
63     catest_env.PrependUnique(LIBS = ['oc_logger'])
64
65 if env.get('SECURED') == '1':
66     catest_env.AppendUnique(LIBS = ['tinydtls'])
67
68 if env.get('LOGGING'):
69         catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
70
71 ######################################################################
72 # Source files and Targets
73 ######################################################################
74 catests = catest_env.Program('catests', ['catests.cpp',
75                                          'caprotocolmessagetest.cpp',
76                                                'ca_api_unittest.cpp',
77                                                'camutex_tests.cpp',
78                                                'oic_string_tests.cpp'])
79
80 Alias("test", [catests])
81
82 env.AppendTarget('test')
83 if env.get('TEST') == '1':
84         target_os = env.get('TARGET_OS')
85         if target_os == 'linux':
86                 out_dir = env.get('BUILD_DIR')
87                 result_dir = env.get('BUILD_DIR') + '/test_out/'
88                 if not os.path.isdir(result_dir):
89                         os.makedirs(result_dir)
90                 catest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
91                 catest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
92                 catest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
93                 ut = catest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_connectivity_test.memcheck ' + out_dir + 'resource/csdk/connectivity/test/catests')
94                 AlwaysBuild ('ut')