b9230db99c2993c4965fe8370ac03602cbce8efd
[platform/upstream/iotivity.git] / service / notification / cpp-wrapper / unittest / 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 # Notification Unit Test build script
23 ##
24
25 Import('env')
26
27 if env.get('RELEASE'):
28         env.AppendUnique(CCFLAGS = ['-Os'])
29         env.AppendUnique(CPPDEFINES = ['NDEBUG'])
30 else:
31         env.AppendUnique(CCFLAGS = ['-g'])
32
33 if env.get('LOGGING'):
34         env.AppendUnique(CPPDEFINES = ['TB_LOG'])
35
36 lib_env = env.Clone()
37 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
38
39 ######################################################################
40 #unit test setting
41 ######################################################################
42 src_dir = lib_env.get('SRC_DIR')
43 gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
44
45 notification_wrapper_test_env = lib_env.Clone()
46 target_os = env.get('TARGET_OS')
47
48 ######################################################################
49 # Build flags
50 ######################################################################
51 GTest = File(gtest_dir + '/lib/.libs/libgtest.a')
52 GTest_Main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
53
54 notification_wrapper_test_env.AppendUnique(LIBPATH = [lib_env.get('BUILD_DIR')])
55 notification_wrapper_test_env.AppendUnique(LIBS = [
56     'connectivity_abstraction', 'oc', 'octbstack', 'oc_logger', 'coap', 'notification_provider', 'notification_consumer' ,
57     GTest_Main, GTest])
58
59 if env.get('WITH_TCP') == True:
60         notification_wrapper_test_env.AppendUnique(CPPDEFINES = ['WITH_TCP'])
61         if env.get('SECURED') == '1':
62                 notification_wrapper_test_env.AppendUnique(LIBS = ['mbedtls', 'mbedx509', 'mbedcrypto'])
63
64 if target_os not in ['windows', 'winrt']:
65     notification_wrapper_test_env.AppendUnique(CXXFLAGS = ['-O2', '-g', '-Wall', '-fmessage-length=0', '-std=c++0x'])
66
67 notification_wrapper_test_env.AppendUnique(LINKFLAGS = ['-Wl,--no-as-needed'])
68
69 notification_wrapper_test_env.AppendUnique(CXXFLAGS = ['-pthread'])
70 notification_wrapper_test_env.AppendUnique(LIBS = ['pthread'])
71
72 notification_wrapper_test_env.PrependUnique(CPPPATH = [ src_dir + '/extlibs/hippomocks-master', gtest_dir + '/include'])
73 notification_wrapper_test_env.AppendUnique(CPPPATH = ['../provider/inc'])
74 notification_wrapper_test_env.AppendUnique(CPPPATH = ['../consumer/inc'])
75 notification_wrapper_test_env.AppendUnique(CPPPATH = ['../common'])
76 notification_wrapper_test_env.AppendUnique(CPPPATH = ['../../include'])
77 notification_wrapper_test_env.AppendUnique(CPPPATH = ['../../src/provider'])
78 notification_wrapper_test_env.AppendUnique(CPPPATH = ['../../src/consumer'])
79
80 ######################################################################
81 # Build Test
82 ######################################################################
83
84 notification_consumer_wrapper_test_env = notification_wrapper_test_env.Clone()
85 notification_consumer_wrapper_test_env.AppendUnique(LIBS = ['notification_consumer_wrapper'])
86
87 notification_provider_wrapper_test_env = notification_wrapper_test_env.Clone()
88 notification_provider_wrapper_test_env.AppendUnique(LIBS = ['notification_provider_wrapper'])
89
90 notification_consumer_wrapper_test_src = env.Glob('./NSConsumerServiceTest.cpp')
91 notification_consumer_wrapper_test = notification_consumer_wrapper_test_env.Program('notification_consumer_wrapper_test', notification_consumer_wrapper_test_src)
92 Alias("notification_consumer_wrapper_test", notification_consumer_wrapper_test)
93 env.AppendTarget('notification_consumer_wrapper_test')
94
95 notification_provider_wrapper_test_src = env.Glob('./NSProviderServiceTest.cpp')
96 notification_provider_wrapper_test = notification_provider_wrapper_test_env.Program('notification_provider_wrapper_test', notification_provider_wrapper_test_src)
97 Alias("notification_provider_wrapper_test", notification_provider_wrapper_test)
98 env.AppendTarget('notification_provider_wrapper_test')
99
100 if env.get('TEST') == '1':
101     if target_os == 'linux':
102             from tools.scons.RunTest import *
103             run_test(notification_consumer_wrapper_test_env, '', 'service/notification/cpp-wrapper/unittest/notification_consumer_wrapper_test')
104             run_test(notification_provider_wrapper_test_env, '', 'service/notification/cpp-wrapper/unittest/notification_provider_wrapper_test')