[Win32] Add msys_nt flags to enable gtest unit tests
[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                 '../../extlibs/cjson',
36                 '../../../oc_logger/include',
37                 '../../../../extlibs/gtest/gtest-1.7.0/include'
38                ])
39
40 tmplist = catest_env['LINKFLAGS'][:]
41 if '-lpthread' in tmplist:
42     tmplist.remove('-lpthread')
43     catest_env.Replace(LINKFLAGS = tmplist)
44
45 catest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
46 catest_env.AppendUnique(LIBS = ['pthread'])
47 catest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
48 catest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
49 catest_env.PrependUnique(LIBS = ['m',
50                                     'octbstack',
51                                     'connectivity_abstraction',
52                                     'coap',
53                                     'gtest',
54                                     'gtest_main'])
55
56 target_os = env.get('TARGET_OS')
57
58 if target_os not in ['arduino', 'darwin', 'ios', 'msys_nt']:
59         catest_env.AppendUnique(LIBS=['rt'])
60
61 if env.get('SECURED') == '1':
62     catest_env.AppendUnique(LIBS = ['tinydtls'])
63
64 if env.get('LOGGING'):
65         catest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
66
67 if target_os in ['msys_nt']:
68         catest_env.AppendUnique(LIBS = ['ws2_32',
69                                         'iphlpapi'])
70
71 ######################################################################
72 # Source files and Targets
73 ######################################################################
74
75 target_os = env.get('TARGET_OS')
76 target_transport = env.get('TARGET_TRANSPORT')
77
78 if (('IP' in target_transport) or ('ALL' in target_transport)):
79         if target_os != 'arduino':
80                 catests = catest_env.Program('catests', ['catests.cpp',
81                                                          'caprotocolmessagetest.cpp',
82                                                          'cablocktransfertest.cpp',
83                                                          'ca_api_unittest.cpp',
84                                                          'camutex_tests.cpp',
85                                                          'uarraylist_test.cpp'
86                                                                ])
87 else:
88         catests = catest_env.Program('catests', ['catests.cpp',
89                                                  'caprotocolmessagetest.cpp',
90                                                  'ca_api_unittest.cpp',
91                                                  'camutex_tests.cpp',
92                                                  'uarraylist_test.cpp'
93                                                        ])
94
95 Alias("test", [catests])
96
97 env.AppendTarget('test')
98 if env.get('TEST') == '1':
99         if target_os == 'linux':
100                 from tools.scons.RunTest import *
101                 run_test(catest_env,
102                          'resource_csdk_connectivity_test.memcheck',
103                          'resource/csdk/connectivity/test/catests')