1 #******************************************************************
3 # Copyright 2015 Samsung Electronics All Rights Reserved.
5 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
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
11 # http://www.apache.org/licenses/LICENSE-2.0
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.
19 #-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
22 # ResourceContainer (rcs_container) Unit Test build script
29 containerJavaSupport = ARGUMENTS.get('containerJavaSupport',0)
31 def filtered_glob(env, pattern, omit=[],
32 ondisk=True, source=False, strings=False):
34 lambda f: os.path.basename(f.path) not in omit,
37 env.AddMethod(filtered_glob, "FilteredGlob");
39 if env.get('RELEASE'):
40 env.AppendUnique(CCFLAGS = ['-Os'])
41 env.AppendUnique(CPPDEFINES = ['NDEBUG'])
43 env.AppendUnique(CCFLAGS = ['-g'])
45 if env.get('LOGGING'):
46 env.AppendUnique(CPPDEFINES = ['TB_LOG'])
51 # Add third party libraries
53 SConscript(env.get('SRC_DIR') + '/service/third_party_libs.scons', 'lib_env')
55 container_gtest_env = lib_env.Clone()
57 if int(containerJavaSupport):
59 print 'Java Home: ', os.environ['JAVA_HOME']
60 print 'Java Lib: ', os.environ['JAVA_LIB']
61 container_gtest_env.Append(CPPDEFINES={'JAVA_SUPPORT_TEST':1})
64 *********************************** Error *************************************
65 * Building resource container without Java support. JAVA_HOME or JAVA_LIB are not set properly
66 * Please configure JAVA_HOME to point to your Java 7 JDK and
67 * JAVA_LIB to your folder containing libjvm
68 * Example: export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-i386
69 * export JAVA_LIB=/usr/lib/jvm/java-7-openjdk-i386/jre/lib/i386/server/
70 *******************************************************************************
72 container_gtest_env.Append(CPPDEFINES={'JAVA_SUPPORT_TEST':0})
75 target_os = env.get('TARGET_OS')
77 ######################### unit test setting ##########################
78 src_dir = lib_env.get('SRC_DIR')
79 gtest_dir = src_dir + '/extlibs/gtest/gtest-1.7.0'
80 ######################################################################
83 ######################################################################
85 ######################################################################
86 gtest = File(gtest_dir + '/lib/.libs/libgtest.a')
87 gtest_main = File(gtest_dir + '/lib/.libs/libgtest_main.a')
89 container_gtest_env.AppendUnique(
91 env.get('SRC_DIR')+'/extlibs',
93 '../../resource-encapsulation/include',
94 '../../resource-encapsulation/src/common/utils/include',
95 '../bundle-api/include',
99 if int(containerJavaSupport):
101 container_gtest_env.AppendUnique(
103 os.environ['JAVA_HOME']+'/include',
104 os.environ['JAVA_HOME']+'/include/linux'
109 if target_os not in ['windows', 'winrt']:
110 container_gtest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall'])
111 if target_os != 'android':
112 container_gtest_env.AppendUnique(CXXFLAGS = ['-pthread'])
113 container_gtest_env.AppendUnique(LIBS = ['pthread'])
115 if target_os == 'android':
116 container_gtest_env.AppendUnique(CXXFLAGS = ['-frtti', '-fexceptions'])
117 container_gtest_env.PrependUnique(LIBS = ['gnustl_shared', 'compatibility', 'log'])
119 container_gtest_env.PrependUnique(CPPPATH = [env.get('SRC_DIR')+'/extlibs/hippomocks-master',
120 gtest_dir + '/include'])
122 if int(containerJavaSupport):
124 container_gtest_env.AppendUnique(LIBPATH = [os.environ['JAVA_LIB']])
128 container_gtest_env.AppendUnique(CCFLAGS = ['-Wnoexcept'])
130 container_gtest_env.PrependUnique(LIBS = ['rcs_container', 'rcs_client', 'rcs_server', 'rcs_common', 'oc','octbstack', 'oc_logger', 'oc_logger_core', 'connectivity_abstraction', gtest, gtest_main])
132 container_gtest_env.AppendUnique(LIBS = ['dl'])
134 if int(containerJavaSupport):
136 print 'Java Lib: ', os.environ['JAVA_LIB']
137 container_gtest_env.AppendUnique(LIBS = ['jvm'])
141 ######################################################################
143 ######################################################################
144 test_bundle_env = container_gtest_env.Clone()
145 test_bundle_env.AppendUnique(CCFLAGS = ['-fPIC'])
147 if target_os not in ['darwin', 'ios', 'windows', 'winrt']:
148 test_bundle_env.AppendUnique(LINKFLAGS = ['-Wl,--no-undefined'])
150 TEST_BUNDLE_DIR = 'TestBundle/'
151 test_bundle_env.AppendUnique(CPPPATH = [
152 TEST_BUNDLE_DIR + 'include'
155 test_bundle_src = [ Glob(TEST_BUNDLE_DIR + 'src/*.cpp'), Glob('src/*.cpp')]
157 TestBundle = test_bundle_env.SharedLibrary('TestBundle', test_bundle_src)
158 test_bundle_env.InstallTarget(TestBundle, 'libTestBundle')
161 ######################################################################
163 ######################################################################
164 container_gtest_src = env.Glob('./*.cpp')
166 container_test = container_gtest_env.Program('container_test', container_gtest_src)
167 Alias("container_test", container_test)
168 env.AppendTarget('container_test')
170 # Copy test configuration
171 Command("./ResourceContainerTestConfig.xml","./ResourceContainerTestConfig.xml", Copy("$TARGET", "$SOURCE"))
172 Ignore("./ResourceContainerTestConfig.xml", "./ResourceContainerTestConfig.xml")
173 Command("./ResourceContainerInvalidConfig.xml","./ResourceContainerInvalidConfig.xml", Copy("$TARGET", "$SOURCE"))
174 Ignore("./ResourceContainerInvalidConfig.xml", "./ResourceContainerInvalidConfig.xml")
175 Command("./TestBundleJava/hue-0.1-jar-with-dependencies.jar","./TestBundleJava/hue-0.1-jar-with-dependencies.jar", Copy("$TARGET", "$SOURCE"))
176 Ignore("./TestBundleJava/hue-0.1-jar-with-dependencies.jar", "./TestBundleJava/hue-0.1-jar-with-dependencies.jar")
178 if env.get('TEST') == '1':
179 target_os = env.get('TARGET_OS')
180 if target_os == 'linux':
181 from tools.scons.RunTest import *
182 run_test(container_gtest_env,
184 'service/resource-container/unittests/container_test')