From 78957f332b0c7b9209c613bf368120ddb6bfa523 Mon Sep 17 00:00:00 2001 From: Christian Kern Date: Tue, 31 Mar 2015 15:39:04 +0200 Subject: [PATCH] Modified tests, to only execute opencl tests when opencl project was build with opencl. This involves also generating test batch files completely, therefore tests executables need no longer to be added manually to the respective batch files. --- CMakeLists.txt | 24 ++++++++++++++++++++---- scripts/run_tests_cygwin.sh | 45 --------------------------------------------- scripts/run_tests_cygwin.sh.cmake | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/run_tests_unix.sh | 45 --------------------------------------------- scripts/run_tests_unix.sh.cmake | 42 ++++++++++++++++++++++++++++++++++++++++++ scripts/run_tests_windows.bat | 59 ----------------------------------------------------------- scripts/run_tests_windows.bat.cmake | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 7 files changed, 162 insertions(+), 153 deletions(-) delete mode 100755 scripts/run_tests_cygwin.sh create mode 100755 scripts/run_tests_cygwin.sh.cmake delete mode 100755 scripts/run_tests_unix.sh create mode 100755 scripts/run_tests_unix.sh.cmake delete mode 100644 scripts/run_tests_windows.bat create mode 100644 scripts/run_tests_windows.bat.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e72b435..ecd1a6d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,8 +124,26 @@ else() endif() message(" (set with command line option -DUSE_EXCEPTIONS=ON/OFF)") +# these are the test executables, we expect to be generated. +set(EXPECTED_EMBB_TEST_EXECUTABLES "embb_algorithms_cpp_test" + "embb_base_c_test" + "embb_base_cpp_test" + "embb_containers_cpp_test" + "embb_dataflow_cpp_test" + "embb_mtapi_c_test" + "embb_mtapi_cpp_test" + "embb_mtapi_network_c_test" + "embb_tasks_cpp_test" + ) + +# if opencl is there, we also expect the mtapi opencl test to be generated +if(OpenCL_FOUND) + list(APPEND EXPECTED_EMBB_TEST_EXECUTABLES "embb_mtapi_opencl_c_test") +endif() + + ## Copy test execution script to local binaries folder -# + if (DEFINED CYGWIN) set(test_script_in run_tests_cygwin.sh) set(test_script_out run_tests.sh) @@ -136,9 +154,7 @@ else() set(test_script_in run_tests_windows.bat) set(test_script_out run_tests.bat) endif() -execute_process( - COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_SOURCE_DIR}/scripts/${test_script_in} binaries/${test_script_out} - ) +CONFIGURE_FILE( ${CMAKE_SOURCE_DIR}/scripts/${test_script_in}.cmake binaries/${test_script_out} ) ## Test and Partest build # diff --git a/scripts/run_tests_cygwin.sh b/scripts/run_tests_cygwin.sh deleted file mode 100755 index 43ae62d..0000000 --- a/scripts/run_tests_cygwin.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# Copyright (c) 2014-2015, Siemens AG. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -# Needs to be located in the folder containing the tests!! -# Is copied automatically there when generating build files with cmake. - -SCRIPT_LOCATION="$0" - -# case we have symlinks... -while [ -h "$SCRIPT_LOCATION" ] ; do - SCRIPT_LOCATION=`readlink "$SCRIPT_LOCATION"` -done - -DIR=`dirname "$SCRIPT_LOCATION"` - -TESTS="embb_base_c_test embb_base_cpp_test embb_mtapi_c_test \ - embb_mtapi_cpp_test embb_tasks_cpp_test embb_algorithms_cpp_test \ - embb_containers_cpp_test embb_dataflow_cpp_test" - -for TEST in $TESTS; do - "$DIR/$TEST".exe; -done diff --git a/scripts/run_tests_cygwin.sh.cmake b/scripts/run_tests_cygwin.sh.cmake new file mode 100755 index 0000000..2fce866 --- /dev/null +++ b/scripts/run_tests_cygwin.sh.cmake @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# Needs to be located in the folder containing the tests!! +# Is copied automatically there when generating build files with cmake. + +EMBB_TEST_EXECUTABLES="@EXPECTED_EMBB_TEST_EXECUTABLES@" +SCRIPT_LOCATION="$0" + +# case we have symlinks... +while [ -h "$SCRIPT_LOCATION" ] ; do + SCRIPT_LOCATION=`readlink "$SCRIPT_LOCATION"` +done + +DIR=`dirname "$SCRIPT_LOCATION"` + +for TEST in $(echo $EMBB_TEST_EXECUTABLES | tr ";" " "); do + "$DIR/$TEST".exe; +done diff --git a/scripts/run_tests_unix.sh b/scripts/run_tests_unix.sh deleted file mode 100755 index a39ede6..0000000 --- a/scripts/run_tests_unix.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/sh -# Copyright (c) 2014-2015, Siemens AG. All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - - -# Needs to be located in the folder containing the tests!! -# Is copied automatically there when generating build files with cmake. - -SCRIPT_LOCATION="$0" - -# case we have symlinks... -while [ -h "$SCRIPT_LOCATION" ] ; do - SCRIPT_LOCATION=`readlink "$SCRIPT_LOCATION"` -done - -DIR=`dirname "$SCRIPT_LOCATION"` - -TESTS="embb_base_c_test embb_base_cpp_test embb_mtapi_c_test \ - embb_mtapi_cpp_test embb_tasks_cpp_test embb_algorithms_cpp_test \ - embb_containers_cpp_test embb_dataflow_cpp_test" - -for TEST in $TESTS; do - $DIR/$TEST; -done diff --git a/scripts/run_tests_unix.sh.cmake b/scripts/run_tests_unix.sh.cmake new file mode 100755 index 0000000..b668b9b --- /dev/null +++ b/scripts/run_tests_unix.sh.cmake @@ -0,0 +1,42 @@ +#!/bin/sh +# Copyright (c) 2014-2015, Siemens AG. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + + +# Needs to be located in the folder containing the tests!! +# Is copied automatically there when generating build files with cmake. + +EMBB_TEST_EXECUTABLES="@EXPECTED_EMBB_TEST_EXECUTABLES@" +SCRIPT_LOCATION="$0" + +# case we have symlinks... +while [ -h "$SCRIPT_LOCATION" ] ; do + SCRIPT_LOCATION=`readlink "$SCRIPT_LOCATION"` +done + +DIR=`dirname "$SCRIPT_LOCATION"` + +for TEST in $(echo $EMBB_TEST_EXECUTABLES | tr ";" " "); do + $DIR/$TEST; +done diff --git a/scripts/run_tests_windows.bat b/scripts/run_tests_windows.bat deleted file mode 100644 index 1621f08..0000000 --- a/scripts/run_tests_windows.bat +++ /dev/null @@ -1,59 +0,0 @@ -:: Copyright (c) 2014-2015, Siemens AG. All rights reserved. -:: -:: Redistribution and use in source and binary forms, with or without -:: modification, are permitted provided that the following conditions are met: -:: -:: 1. Redistributions of source code must retain the above copyright notice, -:: this list of conditions and the following disclaimer. -:: -:: 2. Redistributions in binary form must reproduce the above copyright notice, -:: this list of conditions and the following disclaimer in the documentation -:: and/or other materials provided with the distribution. -:: -:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -:: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -:: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -:: ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -:: LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -:: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -:: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -:: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -:: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -:: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -:: POSSIBILITY OF SUCH DAMAGE. - -:: Needs to be located in the folder containing the tests!! -:: Is copied automatically there when generating build files with cmake. -@echo off -setlocal EnableDelayedExpansion -SET NUM_ERRORS=0 -SET DIR=%~dp0 -"%DIR:~0,-1%\embb_base_c_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_base_cpp_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_mtapi_c_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_mtapi_cpp_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_tasks_cpp_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_algorithms_cpp_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_containers_cpp_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -echo. -"%DIR:~0,-1%\embb_dataflow_cpp_test.exe" -if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 -if not !NUM_ERRORS! ==0 ( - echo. - SET ERRORLEVEL=1 - echo "Number of failed tests: !NUM_ERRORS!" - exit /b !NUM_ERRORS! -) diff --git a/scripts/run_tests_windows.bat.cmake b/scripts/run_tests_windows.bat.cmake new file mode 100644 index 0000000..c3d4a44 --- /dev/null +++ b/scripts/run_tests_windows.bat.cmake @@ -0,0 +1,58 @@ +:: Copyright (c) 2014-2015, Siemens AG. All rights reserved. +:: +:: Redistribution and use in source and binary forms, with or without +:: modification, are permitted provided that the following conditions are met: +:: +:: 1. Redistributions of source code must retain the above copyright notice, +:: this list of conditions and the following disclaimer. +:: +:: 2. Redistributions in binary form must reproduce the above copyright notice, +:: this list of conditions and the following disclaimer in the documentation +:: and/or other materials provided with the distribution. +:: +:: THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +:: AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +:: IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +:: ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +:: LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +:: CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +:: SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +:: INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +:: CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +:: ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +:: POSSIBILITY OF SUCH DAMAGE. + +:: Needs to be located in the folder containing the tests!! +:: Is copied automatically there when generating build files with cmake. +@echo off +setlocal EnableDelayedExpansion +SET NUM_ERRORS=0 +SET DIR=%~dp0 +SET EMBB_EXECUTABLES=@EXPECTED_EMBB_TEST_EXECUTABLES@ + +call :parse "%EMBB_EXECUTABLES%" +goto :end + +:parse +set list=%1 +set list=%list:"=% +FOR /f "tokens=1* delims=;" %%a IN ("%list%") DO ( + if not "%%a" == "" call :sub %%a + if not "%%b" == "" call :parse "%%b" +) +exit /b + +:sub +call "%DIR:~0,-1%\%1.exe" +if not !ERRORLEVEL! ==0 set /a NUM_ERRORS=!NUM_ERRORS!+1 +exit /b + + +:end + +if not !NUM_ERRORS! ==0 ( + echo. + SET ERRORLEVEL=1 + echo "Number of failed tests: !NUM_ERRORS!" + exit /b !NUM_ERRORS! +) -- libgit2 0.26.0