"Fossies" - the Fresh Open Source Software Archive

Member "darktable-2.6.3/src/external/rawspeed/cmake/sample-based-testing.cmake" (19 Oct 2019, 3891 Bytes) of package /linux/misc/darktable-2.6.3.tar.xz:


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. See also the latest Fossies "Diffs" side-by-side code changes report for "sample-based-testing.cmake": 2.6.2_vs_2.6.3.

    1 message(STATUS "Looking for sample set for sample-based testing")
    2 message(STATUS "Looking for sample set in ${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}")
    3 if(NOT (EXISTS "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}"
    4     AND EXISTS "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}/filelist.sha1"
    5     AND EXISTS "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}/timestamp.txt"))
    6   message(SEND_ERROR "Did not find sample set for sample-based testing! Either pass correct path in RAWSPEED_REFERENCE_SAMPLE_ARCHIVE, or disable RAWSPEED_ENABLE_SAMPLE_BASED_TESTING.")
    7 endif()
    8 
    9 message(STATUS "Found sample set in ${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}")
   10 
   11 file(STRINGS "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}/filelist.sha1" _REFERENCE_SAMPLES ENCODING UTF-8)
   12 
   13 set(REFERENCE_SAMPLES)
   14 set(REFERENCE_SAMPLE_HASHES)
   15 
   16 foreach(STR ${_REFERENCE_SAMPLES})
   17   # There are two schemes:
   18   #   <40-char SHA1><space><space><filename>      <- read in text mode
   19   #   <40-char SHA1><space><asterisk><filename>   <- read in binary mode
   20   # We ignore read mode, so it becomes:
   21   #   <40-char SHA1><char><char><filename>
   22   string(SUBSTRING "${STR}" 0 40 SAMPLEHASH)
   23   string(SUBSTRING "${STR}" 42 -1 SAMPLENAME)
   24   set(SAMPLENAME "${RAWSPEED_REFERENCE_SAMPLE_ARCHIVE}/${SAMPLENAME}")
   25 
   26   if(NOT EXISTS "${SAMPLENAME}")
   27     message(SEND_ERROR "The sample \"${SAMPLENAME}\" does not exist!")
   28   endif()
   29 
   30   # Check the hash.
   31   file(SHA1 "${SAMPLENAME}" ACTUALSAMPLEHASH)
   32   string(COMPARE EQUAL "${ACTUALSAMPLEHASH}" "${SAMPLEHASH}" DOHASHESMATCH)
   33   if(NOT "${DOHASHESMATCH}")
   34     message(SEND_ERROR "SHA1 hash for sample \"${SAMPLENAME}\" mismatch!")
   35     message(SEND_ERROR "${ACTUALSAMPLEHASH} instead of ${SAMPLEHASH}")
   36   endif()
   37 
   38   list(APPEND REFERENCE_SAMPLES "${SAMPLENAME}")
   39   list(APPEND REFERENCE_SAMPLE_HASHES "${SAMPLENAME}.hash")
   40   list(APPEND REFERENCE_SAMPLE_HASHES "${SAMPLENAME}.hash.failed")
   41 endforeach()
   42 
   43 set(EXTRA_ENV "")
   44 if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND
   45    CMAKE_BUILD_TYPE STREQUAL "COVERAGE")
   46   message(WARNING "Warning: sample-based-testing; clang instrumentation profile"
   47                   " does not work with threading! Will be passing "
   48                   "OMP_NUM_THREADS=1 environment variable.")
   49   set(EXTRA_ENV "OMP_NUM_THREADS=1")
   50 endif()
   51 
   52 add_custom_target(rstest-create)
   53 add_custom_command(TARGET rstest-create
   54   COMMAND "${CMAKE_COMMAND}" -E env ${EXTRA_ENV} "$<TARGET_FILE:rstest>" -c ${REFERENCE_SAMPLES}
   55   WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
   56   COMMENT "Running rstest on all the samples in the sample set to generate the missing hashes"
   57   VERBATIM
   58   USES_TERMINAL)
   59 
   60 add_custom_target(rstest-recreate)
   61 add_custom_command(TARGET rstest-recreate
   62   COMMAND "${CMAKE_COMMAND}" -E env ${EXTRA_ENV} "$<TARGET_FILE:rstest>" -c -f ${REFERENCE_SAMPLES}
   63   WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
   64   COMMENT "Running rstest on all the samples in the sample set to [re]generate all the hashes"
   65   VERBATIM
   66   USES_TERMINAL)
   67 
   68 add_custom_target(rstest-test) # hashes must exist beforehand
   69 add_custom_command(TARGET rstest-test
   70   COMMAND "${CMAKE_COMMAND}" -E env ${EXTRA_ENV} "$<TARGET_FILE:rstest>" ${REFERENCE_SAMPLES}
   71   WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
   72   COMMENT "Running rstest on all the samples in the sample set to check for regressions"
   73   VERBATIM
   74   USES_TERMINAL)
   75 
   76 add_custom_target(rstest-check) # hashes should exist beforehand if you want to check for regressions
   77 add_custom_command(TARGET rstest-check
   78   COMMAND "${CMAKE_COMMAND}" -E env ${EXTRA_ENV} "$<TARGET_FILE:rstest>" -f ${REFERENCE_SAMPLES}
   79   WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
   80   COMMENT "Trying to decode all the samples in the sample set"
   81   VERBATIM
   82   USES_TERMINAL)
   83 
   84 add_custom_target(rstest-clean)
   85 add_custom_command(TARGET rstest-clean
   86   COMMAND "${CMAKE_COMMAND}" -E remove ${REFERENCE_SAMPLE_HASHES}
   87   WORKING_DIRECTORY "${PROJECT_BINARY_DIR}"
   88   COMMENT "Removing *.hash, *.hash.failed for the each sample in the set"
   89   VERBATIM)