Imported Upstream version 1.1.0
[platform/upstream/iotivity.git] / resource / unittests / 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 unittests_env = env.Clone()
25
26 src_dir = unittests_env.get('SRC_DIR')
27 ######################################################################
28 # Build flags
29 ######################################################################
30 unittests_env.PrependUnique(CPPPATH = [
31                 '../include',
32                 '../oc_logger/include',
33                 '../csdk/stack/include',
34                 '../csdk/security/include',
35                 '../csdk/stack/include/internal',
36                 '../csdk/connectivity/api',
37                 '../csdk/connectivity/external/inc',
38                 '../csdk/ocsocket/include',
39                 '../c_common/ocrandom/include',
40                 '../csdk/logger/include',
41                 '#extlibs/gtest/gtest-1.7.0/include',
42                 '#extlibs/hippomocks-master/HippoMocks',
43                 '#extlibs/hippomocks-master/HippoMocksTest'
44                 ])
45
46 unittests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
47 unittests_env.AppendUnique(LIBS = ['-lpthread'])
48 unittests_env.AppendUnique(LIBPATH = [env.get('BUILD_DIR')])
49 unittests_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
50 unittests_env.PrependUnique(LIBS = [
51                 'oc',
52                 'octbstack',
53                 'oc_logger',
54                 'connectivity_abstraction',
55                 'coap',
56                 'gtest',
57                 'gtest_main'
58                 ])
59
60 if env.get('SECURED') == '1':
61     unittests_env.AppendUnique(LIBS = ['tinydtls'])
62
63 if env.get('LOGGING'):
64         unittests_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
65
66 ######################################################################
67 # Source files and Targets
68 ######################################################################
69 unittests = unittests_env.Program('unittests', ['ConstructResourceTest.cpp',
70                                                 'OCPlatformTest.cpp',
71                                                 'OCRepresentationTest.cpp',
72                                                 'OCRepresentationEncodingTest.cpp',
73                                                 'OCResourceTest.cpp',
74                                                 'OCExceptionTest.cpp',
75                                                 'OCResourceResponseTest.cpp',
76                                                 'OCHeaderOptionTest.cpp'])
77
78 Alias("unittests", [unittests])
79
80 env.AppendTarget('unittests')
81 if env.get('TEST') == '1':
82         target_os = env.get('TARGET_OS')
83         if target_os == 'linux':
84                 from tools.scons.RunTest import *
85                 run_test(unittests_env,
86                          'resource_unittests_unittests.memcheck',
87                          'resource/unittests/unittests')
88
89 src_dir = unittests_env.get('SRC_DIR')
90 svr_db_src_dir = os.path.join(src_dir, 'resource/examples/')
91 svr_db_build_dir = os.path.join(env.get('BUILD_DIR'), 'resource/unittests/')
92 unittests_env.Alias("install",
93                     unittests_env.Install(svr_db_build_dir,
94                                           os.path.join(svr_db_src_dir,
95                                                        'oic_svr_db_client.dat')))