Merge branch 'master' into resource-manipulation
[platform/upstream/iotivity.git] / resource / c_common / oic_malloc / 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
24 malloctest_env = env.Clone()
25 src_dir = malloctest_env.get('SRC_DIR')
26
27 ######################################################################
28 # Build flags
29 ######################################################################
30 malloctest_env.PrependUnique(CPPPATH = [
31         '../include',
32                 '../../../../extlibs/gtest/gtest-1.7.0/include'
33         ])
34
35 malloctest_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
36 malloctest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
37 malloctest_env.PrependUnique(LIBS = ['c_common', 'gtest', 'gtest_main', 'pthread'])
38
39 if env.get('LOGGING'):
40         malloctest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
41 #
42 ######################################################################
43 # Source files and Targets
44 ######################################################################
45 malloctests = malloctest_env.Program('malloctests', ['linux/oic_malloc_tests.cpp'])
46
47 Alias("test", [malloctests])
48
49 env.AppendTarget('test')
50 if env.get('TEST') == '1':
51         target_os = env.get('TARGET_OS')
52         if target_os == 'linux':
53                 out_dir = env.get('BUILD_DIR')
54                 result_dir = env.get('BUILD_DIR') + '/test_out/'
55                 if not os.path.isdir(result_dir):
56                         os.makedirs(result_dir)
57                 malloctest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
58                 malloctest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
59                 malloctest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
60                 ut = malloctest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_ccommon_malloc_test.memcheck ' + out_dir + 'resource/c_common/oic_malloc/test/malloctests')
61                 AlwaysBuild ('ut')