"Fossies" - the Fresh Open Source Software Archive

Member "pocl-1.8/cmake/add_test_pocl.cmake" (12 Oct 2021, 3088 Bytes) of package /linux/misc/pocl-1.8.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) CMake source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #=============================================================================
    2 #   CMake build system files - add_test_pocl() test wrapper
    3 #
    4 #   Copyright (c) 2014-2017 pocl developers
    5 #
    6 #   Permission is hereby granted, free of charge, to any person obtaining a copy
    7 #   of this software and associated documentation files (the "Software"), to deal
    8 #   in the Software without restriction, including without limitation the rights
    9 #   to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
   10 #   copies of the Software, and to permit persons to whom the Software is
   11 #   furnished to do so, subject to the following conditions:
   12 #
   13 #   The above copyright notice and this permission notice shall be included in
   14 #   all copies or substantial portions of the Software.
   15 #
   16 #   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
   17 #   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
   18 #   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
   19 #   AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
   20 #   LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
   21 #   OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
   22 #   THE SOFTWARE.
   23 #
   24 #=============================================================================
   25 
   26 include(CMakeParseArguments)
   27 
   28 # This is a wrapper around add_test
   29 # Solves several problems:
   30 # 1) allows expected outputs (optionally sorted)
   31 # 2) handles the exit status problem (test properties WILL_FAIL does not work if
   32 #    the test exits with !0 exit status)
   33 
   34 function(add_test_pocl)
   35 
   36   set(options SORT_OUTPUT)
   37   set(oneValueArgs EXPECTED_OUTPUT NAME WORKING_DIRECTORY)
   38   set(multiValueArgs COMMAND)
   39   cmake_parse_arguments(POCL_TEST "${options}" "${oneValueArgs}"
   40                         "${multiValueArgs}" ${ARGN})
   41 
   42   unset(RUN_CMD)
   43   foreach(LOOPVAR ${POCL_TEST_COMMAND})
   44     if(NOT RUN_CMD)
   45       set(RUN_CMD "${CMAKE_CURRENT_BINARY_DIR}/${LOOPVAR}")
   46     else()
   47       set(RUN_CMD "${RUN_CMD}####${LOOPVAR}")
   48     endif()
   49   endforeach()
   50 
   51   set(POCL_TEST_ARGLIST "NAME" "${POCL_TEST_NAME}")
   52   if(POCL_TEST_WORKING_DIRECTORY)
   53     list(APPEND POCL_TEST_ARGLIST "WORKING_DIRECTORY")
   54     list(APPEND POCL_TEST_ARGLIST "${POCL_TEST_WORKING_DIRECTORY}")
   55   endif()
   56 
   57   list(APPEND POCL_TEST_ARGLIST "COMMAND" "${CMAKE_COMMAND}" "-Dtest_cmd=${RUN_CMD}")
   58   if(INTEL_SDE_AVX512)
   59     list(APPEND POCL_TEST_ARGLIST "-DSDE=${INTEL_SDE_AVX512}")
   60   endif()
   61 
   62   if(POCL_TEST_EXPECTED_OUTPUT)
   63     list(APPEND POCL_TEST_ARGLIST
   64       "-Doutput_blessed=${CMAKE_CURRENT_SOURCE_DIR}/${POCL_TEST_EXPECTED_OUTPUT}")
   65   endif()
   66   if(POCL_TEST_SORT_OUTPUT)
   67     list(APPEND POCL_TEST_ARGLIST "-Dsort_output=1")
   68     endif()
   69   list(APPEND POCL_TEST_ARGLIST "-P" "${CMAKE_SOURCE_DIR}/cmake/run_test.cmake")
   70 
   71   add_test(${POCL_TEST_ARGLIST} )
   72   if(NOT ENABLE_ANYSAN)
   73     set_tests_properties("${POCL_TEST_NAME}" PROPERTIES
   74                          PASS_REGULAR_EXPRESSION "OK"
   75                          FAIL_REGULAR_EXPRESSION "FAIL")
   76   endif()
   77 
   78 endfunction()