Imported Upstream version 1.1.1
[platform/upstream/iotivity.git] / service / easy-setup / mediator / csdk / unittests / SConscript
1 #******************************************************************
2 #
3 # Copyright 2016 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 # Mediator[CSDK] Unit Test build script
23 ##
24 import os
25
26 # SConscript file for Local PKI google tests
27 gtest_env = SConscript('#extlibs/gtest/SConscript')
28 lib_env = gtest_env.Clone()
29
30 if lib_env.get('RELEASE'):
31     lib_env.AppendUnique(CCFLAGS = ['-Os'])
32     lib_env.AppendUnique(CPPDEFINES = ['NDEBUG'])
33 else:
34     lib_env.AppendUnique(CCFLAGS = ['-g'])
35
36 if lib_env.get('LOGGING'):
37     lib_env.AppendUnique(CPPDEFINES = ['TB_LOG'])
38
39 # Add third party libraries
40 SConscript('#service/third_party_libs.scons', 'lib_env')
41
42 target_os = lib_env.get('TARGET_OS')
43 if target_os in ['linux']:
44     # Verify that 'hippomocks' mocking code is installed.  If not,
45     # get it and install it
46     SConscript('#extlibs/hippomocks.scons')
47
48 mediator_csdk_test_env = lib_env.Clone()
49
50 ######################################################################
51 #unit test setting
52 ######################################################################
53 src_dir = lib_env.get('SRC_DIR')
54
55 ######################################################################
56 # Build flags
57 ######################################################################
58
59 mediator_csdk_test_env.AppendUnique(
60         CPPPATH = [
61                 src_dir + '/extlibs/hippomocks-master',
62                 '../inc',
63                 '../../../inc',
64         ])
65
66 if target_os not in ['windows']:
67     mediator_csdk_test_env.AppendUnique(LIBS = ['dl'])
68     mediator_csdk_test_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
69     if target_os != 'android':
70         mediator_csdk_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
71         mediator_csdk_test_env.AppendUnique(LIBS = ['pthread'])
72
73 mediator_csdk_test_env.PrependUnique(LIBS = [
74     'ESMediatorCSDK',
75     'oc',
76     'octbstack',
77     'oc_logger',
78     'oc_logger_core',
79     'connectivity_abstraction',
80     'gtest',
81     'gtest_main'])
82
83 ######################################################################
84 # Build Test
85 ######################################################################
86 mediator_csdk_test_src = mediator_csdk_test_env.Glob('./*.cpp')
87
88 mediator_csdk_test = mediator_csdk_test_env.Program('mediator_csdk_test', mediator_csdk_test_src)
89 Alias("mediator_csdk_test", mediator_csdk_test)
90 mediator_csdk_test_env.AppendTarget('mediator_csdk_test')
91
92 if mediator_csdk_test_env.get('TEST') == '1':
93     target_os = mediator_csdk_test_env.get('TARGET_OS')
94     if target_os in ['linux']:
95         from tools.scons.RunTest import *
96         run_test(mediator_csdk_test_env, '', 'service/easy-setup/mediator/csdk/unittests/mediator_csdk_test')