Remove resource directory dependency in lib OC
[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 os
22 import os.path
23
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 stacktest_env = gtest_env.Clone()
27 target_os = stacktest_env.get('TARGET_OS')
28
29 ######################################################################
30 # Build flags
31 ######################################################################
32 stacktest_env.PrependUnique(CPPPATH = [
33                 '../../security/include',
34                 '../../ocsocket/include',
35                 '../../logger/include',
36                 '../../../c_common/ocrandom/include',
37                 '../../stack/include',
38                 '../../stack/include/internal',
39                 '../../connectivity/api',
40                 '../../connectivity/inc/pkix',
41                 '../../connectivity/external/inc',
42                 '../../extlibs/cjson',
43                 '../../../oc_logger/include',
44                 ])
45
46 stacktest_env.AppendUnique(LIBPATH = [stacktest_env.get('BUILD_DIR')])
47 stacktest_env.PrependUnique(LIBS = ['octbstack',
48                                     'ocsrm',
49                                     'connectivity_abstraction',
50                                     'coap'])
51 if target_os != 'darwin':
52     stacktest_env.PrependUnique(LIBS = ['oc_logger'])
53
54 if stacktest_env.get('SECURED') == '1':
55         stacktest_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509','mbedcrypto'])
56
57 if stacktest_env.get('LOGGING'):
58         stacktest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
59
60 if target_os in ['msys_nt', 'windows']:
61         stacktest_env.AppendUnique(LINKFLAGS = ['/subsystem:CONSOLE'])
62         stacktest_env.AppendUnique(LIBS = ['ws2_32', 'iphlpapi', 'kernel32'])
63 else:
64         stacktest_env.PrependUnique(LIBS = ['m'])
65
66 ######################################################################
67 # Source files and Targets
68 ######################################################################
69 stacktests = stacktest_env.Program('stacktests', ['stacktests.cpp'])
70 cbortests = stacktest_env.Program('cbortests', ['cbortests.cpp'])
71
72 Alias("test", [stacktests, cbortests])
73
74
75 stacktest_env.AppendTarget('test')
76 if stacktest_env.get('TEST') == '1':
77         if target_os in ['windows']:
78                 stacktest_env.AppendENVPath('PATH', [os.path.join(stacktest_env.get('BUILD_DIR'), 'resource', 'csdk')])
79         if target_os in ['linux', 'windows']:
80                 from tools.scons.RunTest import *
81                 run_test(stacktest_env,
82                          'resource_csdk_stack_test.memcheck',
83                          'resource/csdk/stack/test/stacktests')