Commit eecedc69 authored by Ossama Othman's avatar Ossama Othman Committed by Erich Keane

Refactor duplicated SCons/Python test run code.

Moved duplicated code test run code to a Python module under
tools/scons.  Support for Valgrind suppressions was also added.

Change-Id: I31d0bf7879116a358439e387dcd5fd87bbbecc9d
Signed-off-by: default avatarOssama Othman <ossama.othman@intel.com>
Reviewed-on: https://gerrit.iotivity.org/gerrit/1678Tested-by: default avatarjenkins-iotivity <jenkins-iotivity@opendaylight.org>
Reviewed-by: default avatarJon A. Cruz <jonc@osg.samsung.com>
Reviewed-by: default avatarCaiwen Zhang <caiwen.zhang@intel.com>
Reviewed-by: default avatarErich Keane <erich.keane@intel.com>
parent 1789c9d4
......@@ -29,8 +29,7 @@ src_dir = malloctest_env.get('SRC_DIR')
######################################################################
malloctest_env.PrependUnique(CPPPATH = [
'../include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
])
'#extlibs/gtest/gtest-1.7.0/include' ])
malloctest_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
malloctest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
......@@ -50,12 +49,7 @@ env.AppendTarget('test')
if env.get('TEST') == '1':
target_os = env.get('TARGET_OS')
if target_os == 'linux':
out_dir = env.get('BUILD_DIR')
result_dir = env.get('BUILD_DIR') + '/test_out/'
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
malloctest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
malloctest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
malloctest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = malloctest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_ccommon_malloc_test.memcheck ' + out_dir + 'resource/c_common/oic_malloc/test/malloctests')
AlwaysBuild ('ut')
from tools.scons.RunTest import *
run_test(malloctest_env,
'resource_ccommon_malloc_test.memcheck',
'resource/c_common/oic_malloc/test/malloctests')
......@@ -29,8 +29,7 @@ src_dir = stringtest_env.get('SRC_DIR')
######################################################################
stringtest_env.PrependUnique(CPPPATH = [
'../include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
])
'#extlibs/gtest/gtest-1.7.0/include' ])
stringtest_env.AppendUnique(LIBPATH = [os.path.join(env.get('BUILD_DIR'), 'resource/c_common')])
stringtest_env.AppendUnique(LIBPATH = [src_dir + '/extlibs/gtest/gtest-1.7.0/lib/.libs'])
......@@ -50,12 +49,7 @@ env.AppendTarget('test')
if env.get('TEST') == '1':
target_os = env.get('TARGET_OS')
if target_os == 'linux':
out_dir = env.get('BUILD_DIR')
result_dir = env.get('BUILD_DIR') + '/test_out/'
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
stringtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
stringtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
stringtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = stringtest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_ccommon_string_test.memcheck ' + out_dir + 'resource/c_common/oic_string/test/stringtests')
AlwaysBuild ('ut')
from tools.scons.RunTest import *
run_test(stringtest_env,
'resource_ccommon_string_test.memcheck',
'resource/c_common/oic_string/test/stringtests')
......@@ -82,12 +82,7 @@ env.AppendTarget('test')
if env.get('TEST') == '1':
target_os = env.get('TARGET_OS')
if target_os == 'linux':
out_dir = env.get('BUILD_DIR')
result_dir = env.get('BUILD_DIR') + '/test_out/'
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
catest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
catest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
catest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = catest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_connectivity_test.memcheck ' + out_dir + 'resource/csdk/connectivity/test/catests')
AlwaysBuild ('ut')
from tools.scons.RunTest import *
run_test(catest_env,
'resource_csdk_connectivity_test.memcheck',
'resource/csdk/connectivity/test/catests')
......@@ -60,12 +60,7 @@ env.AppendTarget('test')
if env.get('TEST') == '1':
target_os = env.get('TARGET_OS')
if target_os == 'linux':
out_dir = env.get('BUILD_DIR')
result_dir = env.get('BUILD_DIR') + '/test_out/'
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
randomtest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
randomtest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
randomtest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = randomtest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_random_test.memcheck ' + out_dir + 'resource/csdk/ocrandom/test/randomtests')
AlwaysBuild ('ut')
from tools.scons.RunTest import *
run_test(randomtest_env,
'resource_csdk_random_test.memcheck',
'resource/csdk/ocrandom/test/randomtests')
......@@ -39,7 +39,7 @@ stacktest_env.PrependUnique(CPPPATH = [
'../../connectivity/external/inc',
'../../extlibs/cjson',
'../../../oc_logger/include',
'../../../../extlibs/gtest/gtest-1.7.0/include'
'#extlibs/gtest/gtest-1.7.0/include'
])
stacktest_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
......@@ -76,12 +76,7 @@ env.AppendTarget('test')
if env.get('TEST') == '1':
target_os = env.get('TARGET_OS')
if target_os == 'linux':
out_dir = env.get('BUILD_DIR')
result_dir = env.get('BUILD_DIR') + '/test_out/'
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
stacktest_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
stacktest_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
stacktest_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = stacktest_env.Command ('ut', None, 'valgrind -q --leak-check=full --xml=yes --xml-file=resource_csdk_stack_test.memcheck ' + out_dir + 'resource/csdk/stack/test/stacktests')
AlwaysBuild ('ut')
from tools.scons.RunTest import *
run_test(stacktest_env,
'resource_csdk_stack_test.memcheck',
'resource/csdk/stack/test/stacktests')
......@@ -38,9 +38,9 @@ unittests_env.PrependUnique(CPPPATH = [
'../csdk/ocsocket/include',
'../csdk/ocrandom/include',
'../csdk/logger/include',
'../../extlibs/gtest/gtest-1.7.0/include',
'../../extlibs/hippomocks-master/HippoMocks',
'../../extlibs/hippomocks-master/HippoMocksTest'
'#extlibs/gtest/gtest-1.7.0/include',
'#extlibs/hippomocks-master/HippoMocks',
'#extlibs/hippomocks-master/HippoMocksTest'
])
unittests_env.AppendUnique(CXXFLAGS = ['-std=c++0x', '-Wall', '-pthread'])
......@@ -80,19 +80,15 @@ env.AppendTarget('unittests')
if env.get('TEST') == '1':
target_os = env.get('TARGET_OS')
if target_os == 'linux':
out_dir = env.get('BUILD_DIR')
result_dir = env.get('BUILD_DIR') + '/test_out/'
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
unittests_env.AppendENVPath('GTEST_OUTPUT', ['xml:'+ result_dir])
unittests_env.AppendENVPath('LD_LIBRARY_PATH', [out_dir])
unittests_env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
ut = unittests_env.Command ('ut', None,
[ 'valgrind --leak-check=full --xml=yes --xml-file=resource_unittests_unittests.memcheck ' + out_dir + 'resource/unittests/unittests'])
AlwaysBuild ('ut')
from tools.scons.RunTest import *
run_test(unittests_env,
'resource_unittests_unittests.memcheck',
'resource/unittests/unittests')
src_dir = unittests_env.get('SRC_DIR')
svr_db_src_dir = src_dir + '/resource/examples/'
svr_db_build_dir = env.get('BUILD_DIR') +'/resource/unittests/'
unittests_env.Alias("install", unittests_env.Install( svr_db_build_dir,
svr_db_src_dir + 'oic_svr_db_client.json'))
svr_db_src_dir = os.path.join(src_dir, 'resource/examples/')
svr_db_build_dir = os.path.join(env.get('BUILD_DIR'), 'resource/unittests/')
unittests_env.Alias("install",
unittests_env.Install(svr_db_build_dir,
os.path.join(svr_db_src_dir,
'oic_svr_db_client.json')))
# ------------------------------------------------------------------------
# Copyright 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------
__all__ = [ "scons" ]
# ------------------------------------------------------------------------
# Copyright 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------
import os
def run_test(env, xml_file, test):
"""
Run test with the given SCons Environment, dumping Valgrind
results to the given XML file. If no Valgrind run is desired
simply pass in an empty string or None for the xml_file
parameter.
Note that the test path should not include the build directory
where binaries are placed. The build directory will be prepended
to the test path automatically.
"""
build_dir = env.get('BUILD_DIR')
result_dir = os.path.join(build_dir, 'test_out/')
if not os.path.isdir(result_dir):
os.makedirs(result_dir)
# Dump test report in XML format to the results directory.
env.AppendENVPath('GTEST_OUTPUT', ['xml:' + result_dir])
# Make sure the Google Test libraries are in the dynamic
# linker/loader path.
env.AppendENVPath('LD_LIBRARY_PATH', [build_dir])
env.AppendENVPath('LD_LIBRARY_PATH', ['./extlibs/gtest/gtest-1.7.0/lib/.libs'])
test_cmd = os.path.join(build_dir, test)
if xml_file:
# Environment variables to be made available during the
# Valgrind run.
valgrind_environment = ''
# Valgrind suppressions file.
suppression_file = env.File('#tools/valgrind/iotivity.supp').srcnode().path
# Set up to run the test under Valgrind.
test_cmd = '%s valgrind --leak-check=full --suppressions=%s --xml=yes --xml-file=%s %s' % (valgrind_environment, suppression_file, xml_file, test_cmd)
ut = env.Command('ut', None, test_cmd)
env.AlwaysBuild('ut')
# ------------------------------------------------------------------------
# Copyright 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------
__all__ = [ "RunTest" ]
# ------------------------------------------------------------------------
# Copyright 2015 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ------------------------------------------------------------------------
# This file contains Valgrind suppressions. It is meant to make
# Valgrind ignore memory violations that are out of the control of
# IoTivity developers. Do NOT abuse this file by adding suppressions
# for memory violations that can be addressed in IoTivity itself.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment