Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / service / resource-encapsulation / src / resourceBroker / unittest / SConscript
1 #******************************************************************
2 #
3 # Copyright 2015 Samsung Electronics 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 ##
22 # ResourceBroker Unit Test build script
23 ##
24 # SConscript file for Local PKI google tests
25 gtest_env = SConscript('#extlibs/gtest/SConscript')
26 lib_env = gtest_env.Clone()
27
28 if lib_env.get('RELEASE'):
29     lib_env.AppendUnique(CCFLAGS = ['-Os'])
30     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
31 else:
32     lib_env.AppendUnique(CCFLAGS = ['-g'])
33
34 if lib_env.get('LOGGING'):
35     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
36
37 SConscript('#service/third_party_libs.scons', 'lib_env')
38
39 ######################################################################
40 #unit test setting
41 ######################################################################
42 broker_test_env = lib_env.Clone()
43 src_dir = broker_test_env.get('SRC_DIR')
44 target_os = broker_test_env.get('TARGET_OS')
45
46 ######################################################################
47 # Build flags
48 ######################################################################
49
50 broker_test_env.AppendUnique(CPPPATH = ['../include'])
51 broker_test_env.AppendUnique(CPPPATH = ['../../../include'])
52 broker_test_env.AppendUnique(CPPPATH = ['../../common/primitiveResource/include'])
53 broker_test_env.AppendUnique(CPPPATH = ['../../common/expiryTimer/include'])
54 broker_test_env.AppendUnique(CPPPATH = ['../../common/expiryTimer/src'])
55 broker_test_env.AppendUnique(CPPPATH = ['../../common/utils/include'])
56
57 broker_test_env.PrependUnique(CPPPATH = [broker_test_env.get('SRC_DIR')+'/extlibs/hippomocks-master'])
58 broker_test_env.AppendUnique(LIBPATH = [broker_test_env.get('BUILD_DIR')])
59
60 broker_test_env.PrependUnique(LIBS = ['coap'])
61 broker_test_env.AppendUnique(LIBS = ['connectivity_abstraction'])
62 broker_test_env.AppendUnique(LIBS = ['oc_logger'])
63 broker_test_env.AppendUnique(LIBS = ['octbstack'])
64 broker_test_env.AppendUnique(LIBS = ['oc'])
65 broker_test_env.AppendUnique(LIBS = ['rcs_client'])
66 broker_test_env.AppendUnique(LIBS = ['rcs_common'])
67 broker_test_env.AppendUnique(LIBS = ['gtest'])
68 broker_test_env.AppendUnique(LIBS = ['gtest_main'])
69
70 compiler = broker_test_env.get('CXX')
71 if 'g++' in compiler:
72     broker_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
73
74 if target_os not in ['windows']:
75     broker_test_env.AppendUnique(LIBS = ['pthread'])
76
77 ######################################################################
78 # Build Test
79 ######################################################################
80
81 broker_test_src = broker_test_env.Glob('./*.cpp')
82 broker_test = broker_test_env.Program('broker_test', broker_test_src)
83 Alias("broker_test", broker_test)
84 broker_test_env.AppendTarget('broker_test')
85
86 if broker_test_env.get('TEST') == '1':
87         if target_os in ['linux']:
88                 from tools.scons.RunTest import *
89                 run_test(broker_test_env,
90                          '',
91                          'service/resource-encapsulation/src/resourceBroker/unittest/broker_test')