Imported Upstream version 0.9.1
[platform/upstream/iotivity.git] / resource / csdk / ocrandom / 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 randomtest_env = env.Clone()
25
26 src_dir = randomtest_env.get('SRC_DIR')
27
28 ######################################################################
29 # Build flags
30 ######################################################################
31 randomtest_env.PrependUnique(CPPPATH = [
32         '../include',
33                 '../../logger/include',
34                 '../../ocmalloc/include',
35                 '../../../oc_logger/include',
36                 '../../../../extlibs/gtest/gtest-1.7.0/include'
37                 ])
38
39 randomtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
40 randomtest_env.AppendUnique(LIBS = ['-lpthread'])
41 randomtest_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
42 randomtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
43 randomtest_env.PrependUnique(LIBS = ['m',
44                                     'octbstack',
45                                     'uuid',
46                                     'gtest',
47                                     'gtest_main'])
48
49
50 if env.get('LOGGING'):
51         randomtest_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
52
53 ######################################################################
54 # Source files and Targets
55 ######################################################################
56 randomtests = randomtest_env.Program('randomtests', ['linux/randomtest.cpp'])
57
58 Alias("test", [randomtests])
59
60 env.AppendTarget('test')
61 if env.get('TEST') == '1':
62         target_os = env.get('TARGET_OS')
63         if target_os == 'linux':
64                 out_dir = env.get('BUILD_DIR')
65                 result_dir = env.get('BUILD_DIR') + '/test_out/'
66                 if not os.path.isdir(result_dir):
67                         os.makedirs(result_dir)
68                 randomtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
69                 randomtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
70                 randomtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
71                 ut = randomtest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_random_test.memcheck ' + out_dir + 'resource/csdk/ocrandom/test/randomtests')
72                 AlwaysBuild ('ut')