Merge branch 'master' into windows-port
[platform/upstream/iotivity.git] / resource / csdk / stack / test / SConscript
1 #******************************************************************
2 #
3 # Copyright 2014 Intel Mobile Communications GmbH 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 stacktest_env = env.Clone()
25
26 src_dir = stacktest_env.get('SRC_DIR')
27
28 ######################################################################
29 # Build flags
30 ######################################################################
31 stacktest_env.PrependUnique(CPPPATH = [
32                 '../../security/include',
33                 '../../ocsocket/include',
34                 '../../logger/include',
35                 '../../../c_common/ocrandom/include',
36                 '../../stack/include',
37                 '../../stack/include/internal',
38                 '../../connectivity/api',
39                 '../../connectivity/external/inc',
40                 '../../extlibs/cjson',
41                 '../../../oc_logger/include',
42                 '#extlibs/gtest/gtest-1.7.0/include'
43                 ])
44
45 stacktest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
46 stacktest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
47 stacktest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
48 stacktest_env.PrependUnique(LIBS = ['octbstack',
49                                     'ocsrm',
50                                     'connectivity_abstraction',
51                                     'coap',
52                                     'gtest',
53                                     'gtest_main'])
54
55 target_os = env.get('TARGET_OS')
56 if target_os != 'darwin':
57     stacktest_env.PrependUnique(LIBS = ['oc_logger'])
58
59
60 if env.get('SECURED') == '1':
61     stacktest_env.AppendUnique(LIBS = ['tinydtls'])
62
63 if env.get('LOGGING'):
64         stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
65
66 if target_os in ['msys_nt', 'windows']:
67         stacktest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
68         stacktest_env.AppendUnique(LIBS = ['ws2_32', 'iphlpapi', 'kernel32'])
69 else:
70         stacktest_env.PrependUnique(LIBS = ['m', 'pthread'])
71
72 ######################################################################
73 # Source files and Targets
74 ######################################################################
75 stacktests = stacktest_env.Program('stacktests', ['stacktests.cpp'])
76 cbortests = stacktest_env.Program('cbortests', ['cbortests.cpp'])
77
78 Alias("test", [stacktests, cbortests])
79
80 env.AppendTarget('test')
81 if env.get('TEST') == '1':
82         if target_os in ['windows']:
83                 stacktest_env.AppendENVPath('PATH', [os.path.join(env.get('BUILD_DIR'), 'resource', 'csdk')])
84         if target_os in ['linux', 'windows']:
85                 from tools.scons.RunTest import *
86                 run_test(stacktest_env,
87                          'resource_csdk_stack_test.memcheck',
88                          'resource/csdk/stack/test/stacktests')