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