From 8e1aee62d034d985123fb616be60594b2264aaa6 Mon Sep 17 00:00:00 2001 From: Jatin Chaudhary <51944368+cjatin@users.noreply.github.com> Date: Wed, 3 Dec 2025 16:53:17 +0000 Subject: [PATCH] make hip-tests compileable with TheRock (#1624) ## Motivation Resolved: SWDEV-566226 The current implementation of agents inside of rocprof-systems keeps just the minimal necessary set of information required for populating the `info_agent` table inside of rocpd database. There is a sufficient amount of data that is being left out from database, so this change should fix that and store the additional agent information as an `extdata` row inside of `info_agent` table. ## Technical Details This PR introduces additional filed inside of `agent` structure inside which is representing the JSON formatted string of all the additional information we can acquire about particular agent. This data is processed and added during the initial fetching of agents, and afterwards pushed inside of the database. --------- Co-authored-by: David Galiffi * SWDEV-557412 - Incorporate proper chunk offset when remapping virtual memory (#1848) * SWDEV-557412 - Incorporate proper offset when remapping virtual memory * Fix condition to check if VMHeap allocation address matches a chunk address * Move offset calculation outside if/else block --------- Co-authored-by: JeniferC99 <150404595+JeniferC99@users.noreply.github.com> * SWDEV-567852 - Clean-up hip::init() (#1948) * SWDEV-559267 - Use CLPrint to DevLogPrintf with Log Level - detail debug. (#1160) * SWDEV-548892 - Stop using ocml isinf wrapper (#1854) * SWDEV-562708 - change default maximum SVM size to 256GB (#1731) * SWDEV-503089 - Fix and enable disabled HIP tests from math group (#1319) * SWDEV-503089 - Fix and enable disabled HIP tests from math group * SWDEV-503089 - Move single precision reduced run to a common function * SWDEV-548892 - Stop using ockl steadyctr function (#1882) Directly use the builtin * Implement PTL support (#1957) * Implement PTL support Signed-off-by: adapryor (cherry picked from commit 45bc31292e7940a3b8fca044ef7df22047b95733) Signed-off-by: Maisam Arif --------- Signed-off-by: adapryor Signed-off-by: Maisam Arif Co-authored-by: Maisam Arif * SWDEV-558080 - Add recommended granularity (#1176) * Add recommended granularity * Improve granularity testing * Update based on feedback * Fix and enable VMM tests on cuda (#1855) * Fix and enable VMM tests on cuda * Minor syntax fixes --------- Co-authored-by: Rahul Manocha * [rocprofiler-systems] Add support for ompt_callback_thread_begin (#1681) * Add thread_begin callback * Make OMPT callbacks that are instant have start_ts = end_ts * SWDEV-567514: Remove default stream wait (#1977) - when virtual map command is called - can create deadlock Signed-off-by: sdashmiz * Fix flaky test Unit_hipStreamAddCallback_StrmSyncTiming (#2022) * Review comments * skip the 3 failing tests to merge hip-tests rocm-systems PR --------- Signed-off-by: Bindhiya Kanangot Balakrishnan Signed-off-by: adapryor Signed-off-by: Maisam Arif Signed-off-by: sdashmiz Co-authored-by: GunaShekar Co-authored-by: agunashe Co-authored-by: Ethan Trinh Co-authored-by: JeniferC99 <150404595+JeniferC99@users.noreply.github.com> Co-authored-by: Victor Zhang <111778801+victzhan@users.noreply.github.com> Co-authored-by: German Andryeyev <56892148+gandryey@users.noreply.github.com> Co-authored-by: usrihari123 Co-authored-by: Bindhiya Kanangot Balakrishnan Co-authored-by: anujshuk-amd Co-authored-by: itrowbri Co-authored-by: marantic-amd Co-authored-by: David Galiffi Co-authored-by: cadolphe-amd Co-authored-by: Karthik Jayaprakash <54370791+kjayapra-amd@users.noreply.github.com> Co-authored-by: Matt Arsenault Co-authored-by: Todd tiantuo Li <88386084+lttamd@users.noreply.github.com> Co-authored-by: amilanov-amd Co-authored-by: Adam Pryor <61172547+adam360x@users.noreply.github.com> Co-authored-by: Maisam Arif Co-authored-by: AidanBeltonS Co-authored-by: Rahul Manocha <153310294+manocharahul@users.noreply.github.com> Co-authored-by: Rahul Manocha Co-authored-by: Kian Cossettini Co-authored-by: Shadi Dashmiz <94885391+shadidashmiz@users.noreply.github.com> Co-authored-by: Ioannis Assiouras <38722728+iassiour@users.noreply.github.com> Co-authored-by: Ajay GunaShekar <86270081+agunashe@users.noreply.github.com> --- projects/hip-tests/catch/CMakeLists.txt | 261 +- .../hip-tests/catch/cmake/hip-tests.cmake | 87 + .../hip-tests/catch/cmake/relative_paths.py | 106 + .../catch/external/Catch2/LICENSE.txt | 23 - .../hip-tests/catch/external/Catch2/catch.hpp | 17358 ---------------- .../external/Catch2/cmake/Catch2/Catch.cmake | 438 - .../Catch2/cmake/Catch2/Catch2Config.cmake | 34 - .../cmake/Catch2/Catch2ConfigVersion.cmake | 51 - .../Catch2/cmake/Catch2/Catch2Targets.cmake | 99 - .../Catch2/cmake/Catch2/CatchAddTests.cmake | 134 - .../cmake/Catch2/ParseAndAddCatchTests.cmake | 252 - .../Catch2/cmake/Catch2/catch_include.cmake | 32 - .../catch/hipTestMain/CMakeLists.txt | 14 +- .../catch/hipTestMain/config/config_amd_linux | 24 + .../hipTestMain/config/config_amd_windows | 52 + .../catch/hipTestMain/hip_test_context.cc | 23 +- projects/hip-tests/catch/hipTestMain/main.cc | 2 +- .../catch/include/hip_test_common.hh | 2 +- .../hip-tests/catch/include/hip_test_rtc.hh | 3 +- .../hip-tests/catch/include/warp_common.hh | 2 +- .../hip-tests/catch/kernels/CMakeLists.txt | 4 +- .../hip-tests/catch/multiproc/CMakeLists.txt | 10 +- .../catch/multiproc/dummy_kernel.cpp | 2 +- .../hip-tests/catch/packaging/CMakeLists.txt | 136 +- .../catch/packaging/catch_package.cmake.in | 36 + .../catch/performance/event/CMakeLists.txt | 3 +- .../catch/performance/example/CMakeLists.txt | 3 +- .../performance/kernelLaunch/CMakeLists.txt | 3 +- .../catch/performance/memcpy/CMakeLists.txt | 3 +- .../catch/performance/memset/CMakeLists.txt | 3 +- .../catch/performance/stream/CMakeLists.txt | 3 +- .../catch/performance/warpSync/CMakeLists.txt | 3 +- .../catch/perftests/memory/CMakeLists.txt | 7 +- .../catch/stress/module/CMakeLists.txt | 2 +- .../catch/stress/stream/CMakeLists.txt | 3 +- projects/hip-tests/catch/unit/CMakeLists.txt | 27 +- .../catch/unit/assertion/CMakeLists.txt | 4 +- .../catch/unit/atomics/CMakeLists.txt | 4 +- .../catch/unit/c_compilation/CMakeLists.txt | 13 +- .../catch/unit/callback/CMakeLists.txt | 8 +- .../catch/unit/callback/SimpleKernel.cc | 2 +- .../catch/unit/callback/hipApiName.cc | 6 +- .../catch/unit/compiler/CMakeLists.txt | 86 +- .../unit/compiler/hipSquareGenericTarget.cc | 10 +- .../catch/unit/complex/CMakeLists.txt | 2 +- .../unit/complex/complex_basic_common.hh | 2 +- .../unit/cooperativeGrps/coalesced_group.cc | 2 + .../coalesced_group_tiled_partition.cc | 1 + .../unit/cooperativeGrps/thread_block.cc | 1 + .../unit/cooperativeGrps/thread_block_tile.cc | 2 +- .../catch/unit/device/CMakeLists.txt | 43 +- .../unit/device/hipDeviceSetGetScratchExe.cc | 2 +- ...AtomicsWithRandomActiveLanesInWavefront.cc | 8 +- .../catch/unit/deviceLib/CMakeLists.txt | 39 +- .../catch/unit/deviceLib/fp16_ops.cc | 10 +- .../catch/unit/deviceLib/fp8_fnuz.cc | 4 +- .../catch/unit/deviceLib/fp8_host.cc | 8 +- .../hip-tests/catch/unit/deviceLib/fp8_ocp.cc | 4 +- .../unit/deviceLib/hipVectorTypesHost.cc | 34 +- .../catch/unit/deviceLib/kerDevAllocMultCO.cc | 2 +- .../unit/deviceLib/kerDevAllocSingleKer.cc | 2 +- .../catch/unit/deviceLib/kerDevFreeMultCO.cc | 2 +- .../catch/unit/deviceLib/kerDevWriteMultCO.cc | 2 +- .../catch/unit/device_memory/CMakeLists.txt | 7 +- .../catch/unit/dynamicLoading/CMakeLists.txt | 23 +- .../catch/unit/dynamicLoading/liblazyLoad.cc | 8 +- .../catch/unit/errorHandling/CMakeLists.txt | 11 +- .../unit/errorHandling/hipGetErrorName.cc | 4 +- .../unit/executionControl/CMakeLists.txt | 3 +- .../hip-tests/catch/unit/g++/CMakeLists.txt | 31 +- .../hip-tests/catch/unit/gcc/CMakeLists.txt | 46 +- .../catch/unit/gl_interop/CMakeLists.txt | 3 +- .../hip-tests/catch/unit/graph/CMakeLists.txt | 14 +- .../hip-tests/catch/unit/graph/add_Kernel.cpp | 2 +- .../graph_memcpy_to_from_symbol_common.hh | 4 +- .../unit/graph/hipGetProcAddressGraphApis.cc | 4 +- .../catch/unit/graph/hipGraphDebugDotPrint.cc | 3 +- .../hip-tests/catch/unit/graph/hipMatMul.cc | 4 +- .../hipStreamCaptureExtModuleLaunchKernel.cc | 2 +- .../catch/unit/hip_specific/CMakeLists.txt | 4 +- .../catch/unit/launchBounds/CMakeLists.txt | 4 +- .../catch/unit/library/CMakeLists.txt | 12 +- .../hip-tests/catch/unit/math/CMakeLists.txt | 4 +- .../hip-tests/catch/unit/math/unary_common.hh | 2 + .../hip-tests/catch/unit/math/validators.hh | 17 +- .../catch/unit/memory/CMakeLists.txt | 28 +- .../catch/unit/memory/hipArrayCreate.cc | 4 +- .../memory/hipGetProcAddressMemoryApis.cc | 2 + .../catch/unit/memory/hipMallocPitch.cc | 1 + .../hipMemAdvise_AlignedAllocMem_Exe.cc | 2 +- .../catch/unit/memory/hipMemsetFunctional.cc | 36 +- .../catch/unit/module/CMakeLists.txt | 269 +- .../catch/unit/module/coopKernel.cpp | 15 +- .../catch/unit/module/copiousArgKernel.cc | 2 +- .../hip-tests/catch/unit/module/copyKernel.cc | 2 +- .../unit/module/get_global_test_module.cc | 2 +- .../hipExtLaunchMultiKernelMultiDevice.cc | 2 +- .../unit/module/hipGetFuncBySymbol_exe.cc | 2 +- .../unit/module/kernel_composite_test.cpp | 2 +- .../catch/unit/module/kernel_count.cpp | 2 +- .../catch/unit/module/launch_kernel_module.cc | 4 +- .../catch/unit/module/managed_kernel.cpp | 2 +- .../hip-tests/catch/unit/module/matmul.cpp | 2 +- .../catch/unit/module/vcpy_kernel.cpp | 2 +- .../catch/unit/occupancy/CMakeLists.txt | 8 +- .../catch/unit/occupancy/simple_kernel.cc | 2 +- .../hip-tests/catch/unit/p2p/CMakeLists.txt | 6 +- .../catch/unit/printf/CMakeLists.txt | 22 +- .../hip-tests/catch/unit/rtc/CMakeLists.txt | 8 +- .../catch/unit/rtc/hiprtcComplrOptnTesting.cc | 70 +- .../hip-tests/catch/unit/rtc/rtc_reduce.cc | 1 - .../catch/unit/stream/CMakeLists.txt | 10 +- .../catch/unit/stream/hipMultiStream.cc | 2 +- .../catch/unit/stream/hipStreamLegacy_exe.cc | 2 +- .../catch/unit/streamperthread/CMakeLists.txt | 2 +- .../catch/unit/synchronization/CMakeLists.txt | 11 +- .../catch/unit/syncthreads/CMakeLists.txt | 4 +- .../catch/unit/texture/CMakeLists.txt | 5 +- .../catch/unit/vector_types/CMakeLists.txt | 2 +- .../samples/0_Intro/module_api/CMakeLists.txt | 2 +- .../0_Intro/module_api_global/CMakeLists.txt | 2 +- .../1_Utils/hipDispatchLatency/CMakeLists.txt | 2 +- .../samples/1_Utils/hipInfo/CMakeLists.txt | 23 +- .../11_texture_driver/CMakeLists.txt | 2 +- 124 files changed, 1203 insertions(+), 19124 deletions(-) create mode 100644 projects/hip-tests/catch/cmake/hip-tests.cmake create mode 100644 projects/hip-tests/catch/cmake/relative_paths.py delete mode 100644 projects/hip-tests/catch/external/Catch2/LICENSE.txt delete mode 100644 projects/hip-tests/catch/external/Catch2/catch.hpp delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch2Config.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch2ConfigVersion.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch2Targets.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/CatchAddTests.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/ParseAndAddCatchTests.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake create mode 100644 projects/hip-tests/catch/packaging/catch_package.cmake.in diff --git a/projects/hip-tests/catch/CMakeLists.txt b/projects/hip-tests/catch/CMakeLists.txt index 91b282b2fc..b5595f1bbe 100644 --- a/projects/hip-tests/catch/CMakeLists.txt +++ b/projects/hip-tests/catch/CMakeLists.txt @@ -1,16 +1,52 @@ -cmake_minimum_required(VERSION 3.16.8) +cmake_minimum_required(VERSION 3.20) -# to skip the simple compiler test -set(CMAKE_C_COMPILER_WORKS 1) -set(CMAKE_CXX_COMPILER_WORKS 1) - -project(hiptests) +project(hiptests LANGUAGES C CXX HIP) option(ENABLE_ADDRESS_SANITIZER "Option to enable ASAN build" OFF) option(BUILD_SHARED_LIBS "Option for testing shared libraries" ON) - +option(BUILD_UNIT_TESTS "Build unit tests" ON) +option(BUILD_PERF_TESTS "Build perf tests" OFF) +option(BUILD_STRESS_TESTS "Build stress tests" OFF) option(TEST_CLOCK_CYCLE "Option to use clock64" OFF) -if (TEST_CLOCK_CYCLE) +option(GENERATE_COVERATE "Generate coverage" OFF) + +set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED ON) +set(CMAKE_CXX_EXTENSIONS OFF) +set(CMAKE_HIP_STANDARD 17) +set(CMAKE_HIP_STANDARD_REQUIRED ON) +set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../../lib") +set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) + +find_package(hip REQUIRED) +find_package(hiprtc) +find_package(Git) +find_package(Python 3 COMPONENTS Interpreter REQUIRED) +find_program(HIPCONFIG_EXEC hipconfig REQUIRED) +# hip root dir is 3 levels down the hip-config.cmake file path +set(HIP_PATH ${hip_DIR}/../../../) +if(NOT DEFINED ROCM_PATH) + set(ROCM_PATH "/opt/rocm") + if(NOT EXISTS "${ROCM_PATH}") + set(ROCM_PATH ${HIP_PATH}) + endif() +endif() +if(UNIX) + find_program(ROCM_AGENT_ENUMERATOR_EXEC rocm_agent_enumerator REQUIRED) + find_program(GCC_EXEC gcc) + find_program(GXX_EXEC g++) +else() # Win32 + find_program(LLVM_RC_EXEC NAMES llvm-rc llvm-rc.exe + PATHS ${HIP_PATH} ${HIP_PATH}../lc/bin ${ROCM_PATH}) +endif() +find_program(CLANG_CPP_EXEC NAMES clang-cpp clang-cpp.exe + PATHS ${HIP_PATH} ${HIP_PATH}../lc/bin ${ROCM_PATH}/llvm/bin) +message(STATUS "HIP Lib path: ${HIP_LIB_INSTALL_DIR}") + +# used by clang to find hip +set(HIP_PATH_OPT "--hip-path=${HIP_PATH}") + +if(TEST_CLOCK_CYCLE) add_definitions(-DTEST_CLOCK_CYCLE) endif() @@ -26,60 +62,13 @@ if(NOT HIP_PLATFORM STREQUAL "amd" AND NOT HIP_PLATFORM STREQUAL "nvidia") message(FATAL_ERROR "Unexpected HIP_PLATFORM: " ${HIP_PLATFORM}) endif() -if(HIP_PLATFORM STREQUAL "amd") - if(UNIX AND DEFINED ROCM_PATH) - # Read -DROCM_PATH and set CXX_FLAGS for amd platform only - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${ROCM_PATH}") - endif() - - if(DEFINED HIP_PATH) - # Read -DHIP_PATH and set CXX_FLAGS for amd platform only - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --hip-path=${HIP_PATH}") - endif() -endif() - -# Read -DHIP_PATH -# If not set read env{HIP_PATH} only on Windows -if(WIN32) - if(NOT DEFINED HIP_PATH) - if(DEFINED ENV{HIP_PATH}) - set(HIP_PATH $ENV{HIP_PATH} CACHE STRING "HIP Path") - endif() - endif() -endif() - -if(NOT DEFINED HIP_PATH) - if(DEFINED ROCM_PATH) - set(HIP_PATH ${ROCM_PATH}) - else() - set(HIP_PATH "/opt/rocm") - endif() -endif() - -if(NOT DEFINED ROCM_PATH) - set(ROCM_PATH "/opt/rocm") -endif() - -message(STATUS "HIP_PATH: ${HIP_PATH}") -message(STATUS "ROCM_PATH: ${ROCM_PATH}") - -if (WIN32) - set(HIPCC_EXEC "hipcc.exe") - set(HIPCONFIG_EXEC "hipconfig.exe") -else() - set(HIPCC_EXEC "hipcc") - set(HIPCONFIG_EXEC "hipconfig") -endif() - -set(CMAKE_C_COMPILER "${HIP_PATH}/bin/${HIPCC_EXEC}") -set(CMAKE_CXX_COMPILER "${HIP_PATH}/bin/${HIPCC_EXEC}") -execute_process(COMMAND ${HIP_PATH}/bin/${HIPCONFIG_EXEC} --version +execute_process(COMMAND ${HIPCONFIG_EXEC} --version OUTPUT_VARIABLE HIP_VERSION RESULT_VARIABLE result OUTPUT_STRIP_TRAILING_WHITESPACE) if(result AND NOT result EQUAL 0) - message(FATAL_ERROR "Failure trying to obtain HIP version via command: ${HIP_PATH}/bin/${HIPCONFIG_EXEC} --version: ${result}") + message(FATAL_ERROR "Failure trying to obtain HIP version via command: ${HIPCONFIG_EXEC} --version: ${result}") endif() if(NOT WIN32) @@ -93,9 +82,6 @@ if(NOT WIN32) endif() # end BUILD_SHARED_LIBS endif() # end win32 -# enforce c++17 -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++17") - # Address sanitizer options if(ENABLE_ADDRESS_SANITIZER) message(STATUS "Building catch tests with Address Sanitizer options") @@ -118,43 +104,34 @@ else() set(HIP_PACKAGING_VERSION_PATCH ${HIP_VERSION_PATCH}-${HIP_VERSION_GITHASH}) endif() -if(NOT DEFINED CATCH2_PATH) - if(DEFINED ENV{CATCH2_PATH}) - set(CATCH2_PATH $ENV{CATCH2_PATH} CACHE STRING "Catch2 Path") - else() - set(CATCH2_PATH "${CMAKE_CURRENT_LIST_DIR}/external/Catch2") - endif() -endif() -message(STATUS "Catch2 Path: ${CATCH2_PATH}") - -# Set JSON Parser path -if(NOT DEFINED JSON_PARSER) - if(DEFINED ENV{JSON_PARSER}) - set(JSON_PARSER $ENV{JSON_PARSER} CACHE STRING "JSON Parser Path") - else() - set(JSON_PARSER "${CMAKE_CURRENT_LIST_DIR}/external/picojson") - endif() +find_package(Catch2 3.8.1 QUIET) +if(Catch2_FOUND) + message(STATUS "Catch2 v3.8.1 found: ${Catch2_DIR}") + # for packaging + set(CATCH_ADD_TESTS_SCRIPT ${Catch2_DIR}/CatchAddTests.cmake) + file(GLOB CATCH_LIBS "${Catch2_DIR}/../../*Catch2*") +else() + # Setup catch2 manually + include(FetchContent) + FetchContent_Declare( + Catch2 + DOWNLOAD_EXTRACT_TIMESTAMP OFF + URL "https://rocm-third-party-deps.s3.us-east-2.amazonaws.com/Catch2-3.8.1.tar.gz" + URL_HASH SHA256=18b3f70ac80fccc340d8c6ff0f339b2ae64944782f8d2fca2bd705cf47cadb79 + ) + FetchContent_MakeAvailable(Catch2) + # for packaging + set(CATCH_ADD_TESTS_SCRIPT ${Catch2_SOURCE_DIR}/extras/CatchAddTests.cmake) + set(CATCH_LIBS $) endif() -message(STATUS "Searching Catch2 in: ${CMAKE_CURRENT_LIST_DIR}/external") -find_package(Catch2 REQUIRED - PATHS - ${CMAKE_CURRENT_LIST_DIR}/external - PATH_SUFFIXES - Catch2/cmake/Catch2 -) -include(Catch) +include(cmake/hip-tests.cmake) include(CTest) -# path used for generating the *_include.cmake file -set(CATCH2_INCLUDE ${CATCH2_PATH}/cmake/Catch2/catch_include.cmake.in) - include_directories( - ${CATCH2_PATH} "./include" "./kernels" - ${HIP_PATH}/include - ${JSON_PARSER} + "${CMAKE_CURRENT_LIST_DIR}/external/picojson" ) option(RTC_TESTING "Run tests using HIP RTC to compile the kernels" OFF) @@ -171,22 +148,13 @@ foreach(json IN LISTS JSON_FILES) file(COPY ${json} DESTINATION ${HIP_TEST_CONFIG_BINARY_DIR}) endforeach() -set(CATCH_SCRIPT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/script) -file(COPY ./external/Catch2/cmake/Catch2/CatchAddTests.cmake - DESTINATION ${CATCH_SCRIPT_BINARY_DIR}) -file(COPY ./external/Catch2/cmake/Catch2/catch_include.cmake - DESTINATION ${CATCH_SCRIPT_BINARY_DIR}) -set(ADD_SCRIPT_PATH ${CATCH_SCRIPT_BINARY_DIR}/CatchAddTests.cmake) -set(CATCH_INCLUDE_PATH ${CATCH_SCRIPT_BINARY_DIR}/catch_include.cmake) if (WIN32) configure_file(catchProp_in_rc.in ${CMAKE_CURRENT_BINARY_DIR}/catchProp.rc @ONLY) - cmake_path(SET LLVM_RC_PATH "${HIP_PATH}/../lc/bin/llvm-rc.exe") - cmake_path(SET LLVM_RC_PATH NORMALIZE "${LLVM_RC_PATH}") # generates the .res files to be used by executables to populate the properties # expects LC folder with clang, llvm-rc to be present one level up of HIP - execute_process(COMMAND ${LLVM_RC_PATH} ${CMAKE_CURRENT_BINARY_DIR}/catchProp.rc + execute_process(COMMAND ${LLVM_RC_EXEC} ${CMAKE_CURRENT_BINARY_DIR}/catchProp.rc OUTPUT_VARIABLE RC_OUTPUT) set(PROP_RC ${CMAKE_CURRENT_BINARY_DIR}) # When args to linker exceeds max chars. @@ -197,12 +165,10 @@ if (WIN32) endif() if(HIP_PLATFORM STREQUAL "amd") - add_compile_options(-Wall -Wextra -Wvla -Werror -Wno-deprecated -Wno-option-ignored) -endif() - -cmake_policy(PUSH) -if(POLICY CMP0037) - cmake_policy(SET CMP0037 OLD) + if(WIN32) + set(win_disable_warnings -Wno-ignored-attributes -Wno-microsoft-cast) + endif() + add_compile_options(${HIP_PATH_OPT} -std=c++17 -x hip -Wall -Wextra -Wvla -Wno-deprecated -Wno-option-ignored -Wno-unused-parameter ${win_disable_warnings}) # -Werror) endif() # Turn off CMAKE_HIP_ARCHITECTURES Feature if cmake version is 3.21+ @@ -220,8 +186,14 @@ message(STATUS "CMAKE HIP ARCHITECTURES: ${CMAKE_HIP_ARCHITECTURES}") # preference to pass arch - # OFFLOAD_ARCH_STR # rocm_agent_enumerator -if(NOT DEFINED OFFLOAD_ARCH_STR - AND EXISTS "${ROCM_PATH}/bin/rocm_agent_enumerator" +if(DEFINED OFFLOAD_ARCH_STR) + string(REPLACE "--offload-arch=" "" HIP_GPU_ARCH_LIST ${OFFLOAD_ARCH_STR}) +elseif(DEFINED GPU_TARGETS) + foreach(_hip_gpu_arch ${GPU_TARGETS}) + set(OFFLOAD_ARCH_STR "--offload-arch=${_hip_gpu_arch} ${OFFLOAD_ARCH_STR}") + endforeach() +elseif(NOT DEFINED OFFLOAD_ARCH_STR + AND EXISTS "${ROCM_AGENT_ENUMERATOR_EXEC}" AND HIP_PLATFORM STREQUAL "amd" AND UNIX) execute_process(COMMAND "${ROCM_PATH}/bin/rocm_agent_enumerator" OUTPUT_VARIABLE HIP_GPU_ARCH @@ -240,16 +212,16 @@ if(NOT DEFINED OFFLOAD_ARCH_STR else() message(STATUS "ROCm Agent Enumerator found no valid architectures") endif() -elseif(DEFINED OFFLOAD_ARCH_STR) - string(REPLACE "--offload-arch=" "" HIP_GPU_ARCH_LIST ${OFFLOAD_ARCH_STR}) endif() -if(DEFINED OFFLOAD_ARCH_STR) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OFFLOAD_ARCH_STR} ") -endif() +# Trim any trailing spaces, this trips up the cxx function call +string(STRIP "${OFFLOAD_ARCH_STR}" OFFLOAD_ARCH_STR) + message(STATUS "Using offload arch string: ${OFFLOAD_ARCH_STR}") +if(DEFINED OFFLOAD_ARCH_STR) + set(CMAKE_HIP_FLAGS "${CMAKE_HIP_FLAGS} ${OFFLOAD_ARCH_STR}") +endif() -find_package(Git) # get hip-tests commit short hash execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} @@ -276,9 +248,8 @@ if(WIN32) set(configToUse "config_amd_windows") set(config_file ${CMAKE_SOURCE_DIR}/hipTestMain/config/${configToUse}) set(json_file ${HIP_TEST_CONFIG_BINARY_DIR}/${configToUse}.json) - set(CLANG_CPP "${HIP_PATH}/../lc/bin/clang-cpp.exe") - set(cmd "${CLANG_CPP} -P -DGITHASH=\"${HIP_VERSION_GITHASH}\" ${config_file}>${json_file}") + set(cmd "${CLANG_CPP_EXEC} -P -DGITHASH=\"${HIP_VERSION_GITHASH}\" ${config_file}>${json_file}") message(${cmd}) execute_process(COMMAND cmd.exe /C ${cmd} RESULT_VARIABLE json_result) @@ -288,7 +259,7 @@ else() foreach(arch ${hip_gpu_arch_list}) set(config_file ${CMAKE_SOURCE_DIR}/hipTestMain/config/${configToUse}) set(json_file ${HIP_TEST_CONFIG_BINARY_DIR}/${configToUse}_${arch}.json) - set(cmd "${ROCM_PATH}/llvm/bin/clang-cpp -P -D${arch} -DGITHASH=\\\"${HIP_VERSION_GITHASH}\\\" ${config_file}>${json_file}") + set(cmd "${CLANG_CPP_EXEC} -P -D${arch} -DGITHASH=\\\"${HIP_VERSION_GITHASH}\\\" ${config_file}>${json_file}") message(${cmd}) execute_process(COMMAND bash -c ${cmd} RESULT_VARIABLE json_result) @@ -306,7 +277,13 @@ file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/catchInfo.txt ${_catch # allows user to run ctest from catch_tests level set(_subdirs ${_autogen} "subdirs(..)\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/CTestTestfile.cmake ${_subdirs}) -find_package(Python3 COMPONENTS Interpreter REQUIRED) + +set(CATCH_SCRIPT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/script) +file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/cmake/hip-tests.cmake + DESTINATION ${CATCH_SCRIPT_BINARY_DIR}) +file(COPY ${CATCH_ADD_TESTS_SCRIPT} + DESTINATION ${CATCH_SCRIPT_BINARY_DIR}) +set_property(GLOBAL APPEND PROPERTY G_INSTALL_SCRIPT_TARGETS ${CATCH_ADD_TESTS_SCRIPT}) # copy python script and headers to catch test package set(CATCH_INCLUDE_DIR include) @@ -318,7 +295,6 @@ file(COPY ./unit/compileAndCaptureOutput.py file(COPY ./include/hip_test_common.hh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/${CATCH_INCLUDE_DIR}) file(COPY ./include/hip_test_context.hh DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/${CATCH_INCLUDE_DIR}) -file(COPY ./external/Catch2/catch.hpp DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/${CATCH_INCLUDE_DIR}) # Enable device lambda on nvidia platforms if(HIP_PLATFORM STREQUAL "nvidia") @@ -329,43 +305,38 @@ endif() # Disable CXX extensions (gnu++11 etc) set(CMAKE_CXX_EXTENSIONS OFF) -add_custom_target(build_tests) +add_custom_target(build_tests ALL) # Tests folder -add_subdirectory(unit ${CATCH_BUILD_DIR}/unit) -add_subdirectory(ABM ${CATCH_BUILD_DIR}/ABM) -add_subdirectory(kernels ${CATCH_BUILD_DIR}/kernels) -add_subdirectory(hipTestMain ${CATCH_BUILD_DIR}/hipTestMain) -add_subdirectory(stress ${CATCH_BUILD_DIR}/stress) -add_subdirectory(TypeQualifiers ${CATCH_BUILD_DIR}/TypeQualifiers) -add_subdirectory(perftests ${CATCH_BUILD_DIR}/perftests) -add_subdirectory(multiproc ${CATCH_BUILD_DIR}/multiproc) -add_subdirectory(performance ${CATCH_BUILD_DIR}/performance) +if(BUILD_UNIT_TESTS) + add_subdirectory(unit ${CATCH_BUILD_DIR}/unit) + add_subdirectory(ABM ${CATCH_BUILD_DIR}/ABM) + add_subdirectory(kernels ${CATCH_BUILD_DIR}/kernels) + add_subdirectory(hipTestMain ${CATCH_BUILD_DIR}/hipTestMain) + add_subdirectory(TypeQualifiers ${CATCH_BUILD_DIR}/TypeQualifiers) + if(UNIX) + add_subdirectory(multiproc ${CATCH_BUILD_DIR}/multiproc) + endif() +endif() +if(BUILD_PERF_TESTS) + add_subdirectory(perftests ${CATCH_BUILD_DIR}/perftests) + add_subdirectory(performance ${CATCH_BUILD_DIR}/performance) +endif() +if(BUILD_STRESS_TESTS) + add_subdirectory(stress ${CATCH_BUILD_DIR}/stress) +endif() -add_custom_target(gen_coverage +if(GENERATE_COVERATE) + add_custom_target(gen_coverage COMMAND ${CMAKE_COMMAND} -B build/ COMMAND ${CMAKE_COMMAND} --build build/ COMMAND ./build/generateHipAPICoverage ${HIP_PATH}/include WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}/../utils/coverage COMMENT "Generating Test Coverage Report") - -cmake_policy(POP) +endif() # packaging the tests -# make package_test to generate packages for test -set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/packages/) add_subdirectory(packaging) -if(UNIX) -add_custom_target(package_test COMMAND ${CMAKE_COMMAND} . - COMMAND rm -rf *.deb *.rpm *.tar.gz - COMMAND make package - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -else() -file(TO_NATIVE_PATH ${PROJECT_BINARY_DIR} CATCH_BINARY_DIR) -add_custom_target(package_test COMMAND ${CMAKE_COMMAND} . - COMMAND cpack - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) -endif() # Doxygen documentation # check if doxygen is installed diff --git a/projects/hip-tests/catch/cmake/hip-tests.cmake b/projects/hip-tests/catch/cmake/hip-tests.cmake new file mode 100644 index 0000000000..23fd7528db --- /dev/null +++ b/projects/hip-tests/catch/cmake/hip-tests.cmake @@ -0,0 +1,87 @@ +include(Catch) + +############################################################################### +# current staging +# function to be called by all tests +function(hip_add_exe_to_target) + set(options) + set(args NAME TEST_TARGET_NAME PLATFORM COMPILE_OPTIONS) + set(list_args TEST_SRC LINKER_LIBS COMMON_SHARED_SRC PROPERTY) + cmake_parse_arguments( + PARSE_ARGV 0 + "" # variable prefix + "${options}" + "${args}" + "${list_args}" + ) + foreach(SRC_NAME ${TEST_SRC}) + + if(NOT STANDALONE_TESTS EQUAL "1") + set(_EXE_NAME ${_NAME}) + set(SRC_NAME ${TEST_SRC}) + else() + # strip extension of src and use exe name as src name + get_filename_component(_EXE_NAME ${SRC_NAME} NAME_WLE) + endif() + + # Create shared lib of all tests + set_source_files_properties(${SRC_NAME} PROPERTIES LANGUAGE HIP) + set_source_files_properties(${COMMON_SHARED_SRC} PROPERTIES LANGUAGE HIP) + if(NOT RTC_TESTING) + add_executable(${_EXE_NAME} EXCLUDE_FROM_ALL ${SRC_NAME} ${COMMON_SHARED_SRC} $ $) + else () + add_executable(${_EXE_NAME} EXCLUDE_FROM_ALL ${SRC_NAME} ${COMMON_SHARED_SRC} $) + if(HIP_PLATFORM STREQUAL "amd") + target_link_libraries(${_EXE_NAME} hiprtc::hiprtc) + else() + target_link_libraries(${_EXE_NAME} nvrtc) + endif() + endif() + set_target_properties(${_EXE_NAME} PROPERTIES LINKER_LANGUAGE HIP) + + if (DEFINED _PROPERTY) + set_property(TARGET ${_EXE_NAME} PROPERTY ${_PROPERTY}) + endif() + if(UNIX) + set(_LINKER_LIBS ${_LINKER_LIBS} stdc++fs) + set(_LINKER_LIBS ${_LINKER_LIBS} -ldl) + set(_LINKER_LIBS ${_LINKER_LIBS} pthread) + set(_LINKER_LIBS ${_LINKER_LIBS} rt) + else() + # res files are built resource files using rc files. + # use llvm-rc exe to build the res files + # Thes are used to populate the properties of the built executables + if(EXISTS "${PROP_RC}/catchProp.res") + set(_LINKER_LIBS ${_LINKER_LIBS} "${PROP_RC}/catchProp.res") + endif() + #set_property(TARGET ${_EXE_NAME} PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") + endif() + + if(DEFINED _LINKER_LIBS) + target_link_libraries(${_EXE_NAME} ${_LINKER_LIBS}) + endif() + + # Add dependency on build_tests to build it on this custom target + add_dependencies(${_TEST_TARGET_NAME} ${_EXE_NAME}) + + if (DEFINED _COMPILE_OPTIONS) + target_compile_options(${_EXE_NAME} PUBLIC ${_COMPILE_OPTIONS}) + endif() + target_link_libraries(${_EXE_NAME} Catch2::Catch2) + target_link_libraries(${_EXE_NAME} hip::host hip::device) + + foreach(arg IN LISTS _UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments: ${arg}") + endforeach() + # add binary to global list of binaries to install + set_property(GLOBAL APPEND PROPERTY G_INSTALL_EXE_TARGETS ${_EXE_NAME}) + catch_discover_tests("${_EXE_NAME}" DISCOVERY_MODE PRE_TEST PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") + file(GLOB CTEST_INC_FILES "${CMAKE_CURRENT_BINARY_DIR}/${_EXE_NAME}-*_include.cmake") + set_property(GLOBAL APPEND PROPERTY G_INSTALL_CTEST_INCLUDE_FILES ${CTEST_INC_FILES}) + + if(NOT STANDALONE_TESTS EQUAL "1") + break() + endif() + endforeach() +endfunction() + diff --git a/projects/hip-tests/catch/cmake/relative_paths.py b/projects/hip-tests/catch/cmake/relative_paths.py new file mode 100644 index 0000000000..b8330fda46 --- /dev/null +++ b/projects/hip-tests/catch/cmake/relative_paths.py @@ -0,0 +1,106 @@ +import glob +import sys +import os +import re + +if len(sys.argv) > 1: + build_folder = sys.argv[1] + install_folder = sys.argv[2] + #print(f"In relative_paths.py [1]: build folder: {build_folder}") + #print(f"In relative_paths.py [2]: install folder: {install_folder}") +else: + print(f"Args not provided. Please provide arg1-build folder-catch_tests, arg2-install folder") + exit(1) + +install_folder = os.path.abspath(install_folder) +install_catch_tests = os.path.join(install_folder, "catch_tests") +install_script = os.path.join(install_catch_tests, "script") + +modified_msg = """ +# File has been updated by hip-tests/catch folder for portability +""" +ctest_current_str = """ +get_filename_component(FULL_FILE_PATH ${CMAKE_CURRENT_LIST_FILE} REALPATH) +get_filename_component(CTEST_CURRENT_DIR ${FULL_FILE_PATH} DIRECTORY) +get_filename_component(EXE_PATH ${CTEST_CURRENT_DIR}/.. REALPATH) +""" +if os.name == 'posix': + library_path_str = """ +set(LIB_PATH ${EXE_PATH}/../../../lib) +file(GLOB HIP_LIBS "${LIB_PATH}/libamdhip64*") +if(HIP_LIBS) + set(LIB_PATH ${LIB_PATH} ${LIB_PATH}/rocm_sysdeps/lib) +else() + set(LIB_PATH "/opt/rocm/lib") +endif() +""" + ctest_current_str = ctest_current_str + library_path_str + +inc_cmake_pattern = "_include.cmake" +ctesttest_pattern = "CTestTestfile.cmake" + +def make_test_files_portable(filenames): + """ + changes the absolute paths with relative paths + filenames - list of files to perform the workaround + """ + for filename in filenames: + try: + filename = os.path.abspath(filename) + # Read the entire content of the file + with open(filename, 'r') as file: + file_content = file.read() + #print(f"**Done reading now parsing", filename) + # 1 replace abs path with filename. Make relative + old_text=os.path.dirname(os.path.abspath(filename)) + abs_dir_path = os.path.join(old_text, '') + old_text = abs_dir_path.replace("\\", "/") + if modified_msg not in file_content: + file_content = modified_msg + file_content + # Perform the replacement + modified_content = file_content.replace(old_text, '') + if inc_cmake_pattern in filename: + # 2 get folder path relative to the current *_include.cmake + if r"get_filename_component(FULL_FILE_PATH" not in modified_content: + modified_content = ctest_current_str + modified_content + # 3 CTEST_FILE to have parameterized relative file + test_cmake_pattern = r"\[==\[(\w+-[a-f0-9]+_tests.cmake)\]==\]" + replace_test_pattern = r"${CTEST_CURRENT_DIR}/\1" + modified_content = re.sub(test_cmake_pattern, replace_test_pattern, modified_content) + # 4 script to use CatchAddTests.cmake from build rather than src + add_test_pattern = r'include\(".*CatchAddTests\.cmake"\)' + replace_add_test_pattern = 'include("${CTEST_CURRENT_DIR}/CatchAddTests.cmake")' + modified_content = re.sub(add_test_pattern, replace_add_test_pattern, modified_content) + # 5 use exe from previous folder + exe_pattern = r"TEST_EXECUTABLE\s+\[==\[(.*?)\]==\]" + replace_exe_pattern = r'TEST_EXECUTABLE ${EXE_PATH}/\1' + modified_content = re.sub(exe_pattern, replace_exe_pattern, modified_content) + # 6 include _ctest.cmake file with path + ctest_test_pattern = r'include\("(.*?_tests\.cmake)"\)' + replace_ctest_pattern = r'include("${CTEST_CURRENT_DIR}/\1")' + modified_content = re.sub(ctest_test_pattern, replace_ctest_pattern, modified_content) + # 7 use script folder as cwd + cwd_pattern = r"TEST_WORKING_DIR\s+\[==\[(.*?)\]==\]" + replace_cwd_pattern = r'TEST_WORKING_DIR ${EXE_PATH}' + modified_content = re.sub(cwd_pattern, replace_cwd_pattern, modified_content) + # 8 modify ld_library_path + if os.name == 'posix': + lib_path_pattern = r"TEST_DL_PATHS\s+\[==\[(.*?)\]==\]" + replace_lib_path_pattern = r'TEST_DL_PATHS ${LIB_PATH}' + modified_content = re.sub(lib_path_pattern, replace_lib_path_pattern, modified_content) + + filename = os.path.basename(filename) + install_path = os.path.join(install_script, filename) + # Write the modified content back to the file + with open(install_path, 'w') as file: + file.write(modified_content) + #print(f"**Done parsing now writing into", install_path) + except IOError as e: + print(f"Error: '{e}'") + sys.exit({e}) + except Exception as e: + print(f"An error occurred: {e}") + sys.exit({e}) + +inccmake_files = glob.glob(build_folder + "/**/*"+inc_cmake_pattern, recursive=True) +make_test_files_portable(inccmake_files) diff --git a/projects/hip-tests/catch/external/Catch2/LICENSE.txt b/projects/hip-tests/catch/external/Catch2/LICENSE.txt deleted file mode 100644 index 36b7cd93cd..0000000000 --- a/projects/hip-tests/catch/external/Catch2/LICENSE.txt +++ /dev/null @@ -1,23 +0,0 @@ -Boost Software License - Version 1.0 - August 17th, 2003 - -Permission is hereby granted, free of charge, to any person or organization -obtaining a copy of the software and accompanying documentation covered by -this license (the "Software") to use, reproduce, display, distribute, -execute, and transmit the Software, and to prepare derivative works of the -Software, and to permit third-parties to whom the Software is furnished to -do so, all subject to the following: - -The copyright notices in the Software and this entire statement, including -the above license grant, this restriction and the following disclaimer, -must be included in all copies of the Software, in whole or in part, and -all derivative works of the Software, unless such copies or derivative -works are solely in the form of machine-executable object code generated by -a source language processor. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT -SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE -FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, -ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. diff --git a/projects/hip-tests/catch/external/Catch2/catch.hpp b/projects/hip-tests/catch/external/Catch2/catch.hpp deleted file mode 100644 index ab39621b9a..0000000000 --- a/projects/hip-tests/catch/external/Catch2/catch.hpp +++ /dev/null @@ -1,17358 +0,0 @@ -/* - * Catch v2.13.4 - * Generated: 2020-12-29 14:48:00.116107 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2020 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -// start catch.hpp - - -#define CATCH_VERSION_MAJOR 2 -#define CATCH_VERSION_MINOR 13 -#define CATCH_VERSION_PATCH 4 - -#ifdef __clang__ -#pragma clang system_header -#elif defined __GNUC__ -#pragma GCC system_header -#endif - -// start catch_suppress_warnings.h - -#ifdef __clang__ -#ifdef __ICC // icpc defines the __clang__ macro -#pragma warning(push) -#pragma warning(disable : 161 1682) -#else // __ICC -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#pragma clang diagnostic ignored "-Wswitch-enum" -#pragma clang diagnostic ignored "-Wcovered-switch-default" -#endif -#elif defined __GNUC__ -// Because REQUIREs trigger GCC's -Wparentheses, and because still -// supported version of g++ have only buggy support for _Pragmas, -// Wparentheses have to be suppressed globally. -#pragma GCC diagnostic ignored "-Wparentheses" // See #674 for details - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-variable" -#pragma GCC diagnostic ignored "-Wpadded" -#endif -// end catch_suppress_warnings.h -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -#define CATCH_IMPL -#define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -#define CATCH_CONFIG_EXTERNAL_INTERFACES -#if defined(CATCH_CONFIG_DISABLE_MATCHERS) -#undef CATCH_CONFIG_DISABLE_MATCHERS -#endif -#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -#endif -#endif - -#if !defined(CATCH_CONFIG_IMPL_ONLY) -// start catch_platform.h - -#ifdef __APPLE__ -#include -#if TARGET_OS_OSX == 1 -#define CATCH_PLATFORM_MAC -#elif TARGET_OS_IPHONE == 1 -#define CATCH_PLATFORM_IPHONE -#endif - -#elif defined(linux) || defined(__linux) || defined(__linux__) -#define CATCH_PLATFORM_LINUX - -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || \ - defined(__MINGW32__) -#define CATCH_PLATFORM_WINDOWS -#endif - -// end catch_platform.h - -#ifdef CATCH_IMPL -#ifndef CLARA_CONFIG_MAIN -#define CLARA_CONFIG_MAIN_NOT_DEFINED -#define CLARA_CONFIG_MAIN -#endif -#endif - -// start catch_user_interfaces.h - -namespace Catch { -unsigned int rngSeed(); -} - -// end catch_user_interfaces.h -// start catch_tag_alias_autoregistrar.h - -// start catch_common.h - -// start catch_compiler_capabilities.h - -// Detect a number of compiler features - by compiler -// The following features are defined: -// -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -#ifdef __cplusplus - -#if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L) -#define CATCH_CPP14_OR_GREATER -#endif - -#if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L) -#define CATCH_CPP17_OR_GREATER -#endif - -#endif - -// We have to avoid both ICC and Clang, because they try to mask themselves -// as gcc, and we want only GCC in this block -#if defined(__GNUC__) && !defined(__clang__) && !defined(__ICC) && !defined(__CUDACC__) -#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("GCC diagnostic push") -#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("GCC diagnostic pop") - -#define CATCH_INTERNAL_IGNORE_BUT_WARN(...) (void)__builtin_constant_p(__VA_ARGS__) - -#endif - -#if defined(__clang__) - -#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION _Pragma("clang diagnostic push") -#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION _Pragma("clang diagnostic pop") - -// As of this writing, IBM XL's implementation of __builtin_constant_p has a bug -// which results in calls to destructors being emitted for each temporary, -// without a matching initialization. In practice, this can result in something -// like `std::string::~string` being called on an uninitialized value. -// -// For example, this code will likely segfault under IBM XL: -// ``` -// REQUIRE(std::string("12") + "34" == "1234") -// ``` -// -// Therefore, `CATCH_INTERNAL_IGNORE_BUT_WARN` is not implemented. -#if !defined(__ibmxl__) && !defined(__CUDACC__) -#define CATCH_INTERNAL_IGNORE_BUT_WARN(...) \ - (void)__builtin_constant_p( \ - __VA_ARGS__) /* NOLINT(cppcoreguidelines-pro-type-vararg, hicpp-vararg) */ -#endif - -#define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wexit-time-destructors\"") \ - _Pragma("clang diagnostic ignored \"-Wglobal-constructors\"") - -#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wparentheses\"") - -#define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wunused-variable\"") - -#define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"") - -#define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS \ - _Pragma("clang diagnostic ignored \"-Wunused-template\"") - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// Assume that non-Windows platforms support posix signals by default -#if !defined(CATCH_PLATFORM_WINDOWS) -#define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS -#endif - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__) -#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#endif - -#ifdef __OS400__ -#define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -#define CATCH_CONFIG_COLOUR_NONE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Android somehow still does not support std::to_string -#if defined(__ANDROID__) -#define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING -#define CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Not all Windows environments support SEH properly -#if defined(__MINGW32__) -#define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#endif - -//////////////////////////////////////////////////////////////////////////////// -// PS4 -#if defined(__ORBIS__) -#define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -#define _BSD_SOURCE -// some versions of cygwin (most) do not support std::to_string. Use the libstd check. -// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813 -#if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) && \ - !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF)) - -#define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING - -#endif -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#if defined(_MSC_VER) - -#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION __pragma(warning(push)) -#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION __pragma(warning(pop)) - -// Universal Windows platform does not support SEH -// Or console colours (or console at all...) -#if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP) -#define CATCH_CONFIG_COLOUR_NONE -#else -#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH -#endif - -// MSVC traditional preprocessor needs some workaround for __VA_ARGS__ -// _MSVC_TRADITIONAL == 0 means new conformant preprocessor -// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor -#if !defined(__clang__) // Handle Clang masquerading for msvc -#if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL) -#define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif // MSVC_TRADITIONAL -#endif // __clang__ - -#endif // _MSC_VER - -#if defined(_REENTRANT) || defined(_MSC_VER) -// Enable async processing, as -pthread is specified or no additional linking is required -#define CATCH_INTERNAL_CONFIG_USE_ASYNC -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// Check if we are compiled with -fno-exceptions or equivalent -#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND) -#define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED -#endif - -//////////////////////////////////////////////////////////////////////////////// -// DJGPP -#ifdef __DJGPP__ -#define CATCH_INTERNAL_CONFIG_NO_WCHAR -#endif // __DJGPP__ - -//////////////////////////////////////////////////////////////////////////////// -// Embarcadero C++Build -#if defined(__BORLANDC__) -#define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// Use of __COUNTER__ is suppressed during code analysis in -// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly -// handled by it. -// Otherwise all supported compilers support COUNTER macro, -// but user still might want to turn it off -#if (!defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L) -#define CATCH_INTERNAL_CONFIG_COUNTER -#endif - -//////////////////////////////////////////////////////////////////////////////// - -// RTX is a special version of Windows that is real time. -// This means that it is detected as Windows, but does not provide -// the same set of capabilities as real Windows does. -#if defined(UNDER_RTSS) || defined(RTX64_BUILD) -#define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH -#define CATCH_INTERNAL_CONFIG_NO_ASYNC -#define CATCH_CONFIG_COLOUR_NONE -#endif - -#if !defined(_GLIBCXX_USE_C99_MATH_TR1) -#define CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Various stdlib support checks that require __has_include -#if defined(__has_include) -// Check if string_view is available and usable -#if __has_include() && defined(CATCH_CPP17_OR_GREATER) -#define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW -#endif - -// Check if optional is available and usable -#if __has_include() && defined(CATCH_CPP17_OR_GREATER) -#define CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL -#endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - -// Check if byte is available and usable -#if __has_include() && defined(CATCH_CPP17_OR_GREATER) -#include -#if __cpp_lib_byte > 0 -#define CATCH_INTERNAL_CONFIG_CPP17_BYTE -#endif -#endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) - -// Check if variant is available and usable -#if __has_include() && defined(CATCH_CPP17_OR_GREATER) -#if defined(__clang__) && (__clang_major__ < 8) -// work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852 -// fix should be in clang 8, workaround in libstdc++ 8.2 -#include -#if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) -#define CATCH_CONFIG_NO_CPP17_VARIANT -#else -#define CATCH_INTERNAL_CONFIG_CPP17_VARIANT -#endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9) -#else -#define CATCH_INTERNAL_CONFIG_CPP17_VARIANT -#endif // defined(__clang__) && (__clang_major__ < 8) -#endif // __has_include() && defined(CATCH_CPP17_OR_GREATER) -#endif // defined(__has_include) - -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && \ - !defined(CATCH_CONFIG_COUNTER) -#define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && \ - !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH) -#define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by -// default. -#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && \ - !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && \ - !defined(CATCH_CONFIG_POSIX_SIGNALS) -#define CATCH_CONFIG_POSIX_SIGNALS -#endif -// This is set by default, because we assume that compilers with no wchar_t support are just rare -// exceptions. -#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && \ - !defined(CATCH_CONFIG_WCHAR) -#define CATCH_CONFIG_WCHAR -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && \ - !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING) -#define CATCH_CONFIG_CPP11_TO_STRING -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_OPTIONAL) && !defined(CATCH_CONFIG_NO_CPP17_OPTIONAL) && \ - !defined(CATCH_CONFIG_CPP17_OPTIONAL) -#define CATCH_CONFIG_CPP17_OPTIONAL -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && \ - !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW) -#define CATCH_CONFIG_CPP17_STRING_VIEW -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && \ - !defined(CATCH_CONFIG_CPP17_VARIANT) -#define CATCH_CONFIG_CPP17_VARIANT -#endif - -#if defined(CATCH_INTERNAL_CONFIG_CPP17_BYTE) && !defined(CATCH_CONFIG_NO_CPP17_BYTE) && \ - !defined(CATCH_CONFIG_CPP17_BYTE) -#define CATCH_CONFIG_CPP17_BYTE -#endif - -#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT) -#define CATCH_INTERNAL_CONFIG_NEW_CAPTURE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && \ - !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && \ - !defined(CATCH_CONFIG_NEW_CAPTURE) -#define CATCH_CONFIG_NEW_CAPTURE -#endif - -#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_CONFIG_DISABLE_EXCEPTIONS -#endif - -#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && \ - !defined(CATCH_CONFIG_POLYFILL_ISNAN) -#define CATCH_CONFIG_POLYFILL_ISNAN -#endif - -#if defined(CATCH_INTERNAL_CONFIG_USE_ASYNC) && !defined(CATCH_INTERNAL_CONFIG_NO_ASYNC) && \ - !defined(CATCH_CONFIG_NO_USE_ASYNC) && !defined(CATCH_CONFIG_USE_ASYNC) -#define CATCH_CONFIG_USE_ASYNC -#endif - -#if defined(CATCH_INTERNAL_CONFIG_ANDROID_LOGWRITE) && \ - !defined(CATCH_CONFIG_NO_ANDROID_LOGWRITE) && !defined(CATCH_CONFIG_ANDROID_LOGWRITE) -#define CATCH_CONFIG_ANDROID_LOGWRITE -#endif - -#if defined(CATCH_INTERNAL_CONFIG_GLOBAL_NEXTAFTER) && \ - !defined(CATCH_CONFIG_NO_GLOBAL_NEXTAFTER) && !defined(CATCH_CONFIG_GLOBAL_NEXTAFTER) -#define CATCH_CONFIG_GLOBAL_NEXTAFTER -#endif - -// Even if we do not think the compiler has that warning, we still have -// to provide a macro that can be used by the code. -#if !defined(CATCH_INTERNAL_START_WARNINGS_SUPPRESSION) -#define CATCH_INTERNAL_START_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION) -#define CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -#define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS) -#define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS) -#define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS) -#define CATCH_INTERNAL_SUPPRESS_ZERO_VARIADIC_WARNINGS -#endif - -// The goal of this macro is to avoid evaluation of the arguments, but -// still have the compiler warn on problems inside... -#if !defined(CATCH_INTERNAL_IGNORE_BUT_WARN) -#define CATCH_INTERNAL_IGNORE_BUT_WARN(...) -#endif - -#if defined(__APPLE__) && defined(__apple_build_version__) && (__clang_major__ < 10) -#undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#elif defined(__clang__) && (__clang_major__ < 5) -#undef CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS) -#define CATCH_INTERNAL_SUPPRESS_UNUSED_TEMPLATE_WARNINGS -#endif - -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) -#define CATCH_TRY if ((true)) -#define CATCH_CATCH_ALL if ((false)) -#define CATCH_CATCH_ANON(type) if ((false)) -#else -#define CATCH_TRY try -#define CATCH_CATCH_ALL catch (...) -#define CATCH_CATCH_ANON(type) catch (type) -#endif - -#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && \ - !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && \ - !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) -#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#endif - -// end catch_compiler_capabilities.h -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE(name, line) INTERNAL_CATCH_UNIQUE_NAME_LINE2(name, line) -#ifdef CATCH_CONFIG_COUNTER -#define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __COUNTER__) -#else -#define INTERNAL_CATCH_UNIQUE_NAME(name) INTERNAL_CATCH_UNIQUE_NAME_LINE(name, __LINE__) -#endif - -#include -#include -#include - -// We need a dummy global operator<< so we can bring it into Catch namespace later -struct Catch_global_namespace_dummy {}; -std::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy); - -namespace Catch { - -struct CaseSensitive { - enum Choice { Yes, No }; -}; - -class NonCopyable { - NonCopyable(NonCopyable const&) = delete; - NonCopyable(NonCopyable&&) = delete; - NonCopyable& operator=(NonCopyable const&) = delete; - NonCopyable& operator=(NonCopyable&&) = delete; - - protected: - NonCopyable(); - virtual ~NonCopyable(); -}; - -struct SourceLineInfo { - SourceLineInfo() = delete; - SourceLineInfo(char const* _file, std::size_t _line) noexcept : file(_file), line(_line) {} - - SourceLineInfo(SourceLineInfo const& other) = default; - SourceLineInfo& operator=(SourceLineInfo const&) = default; - SourceLineInfo(SourceLineInfo&&) noexcept = default; - SourceLineInfo& operator=(SourceLineInfo&&) noexcept = default; - - bool empty() const noexcept { return file[0] == '\0'; } - bool operator==(SourceLineInfo const& other) const noexcept; - bool operator<(SourceLineInfo const& other) const noexcept; - - char const* file; - std::size_t line; -}; - -std::ostream& operator<<(std::ostream& os, SourceLineInfo const& info); - -// Bring in operator<< from global namespace into Catch namespace -// This is necessary because the overload of operator<< above makes -// lookup stop at namespace Catch -using ::operator<<; - -// Use this in variadic streaming macros to allow -// >> +StreamEndStop -// as well as -// >> stuff +StreamEndStop -struct StreamEndStop { - std::string operator+() const; -}; -template T const& operator+(T const& value, StreamEndStop) { return value; } -} // namespace Catch - -#define CATCH_INTERNAL_LINEINFO \ - ::Catch::SourceLineInfo(__FILE__, static_cast(__LINE__)) - -// end catch_common.h -namespace Catch { - -struct RegistrarForTagAliases { - RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo); -}; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS(alias, spec) \ - CATCH_INTERNAL_START_WARNINGS_SUPPRESSION \ - CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \ - namespace { \ - Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME(AutoRegisterTagAlias)( \ - alias, spec, CATCH_INTERNAL_LINEINFO); \ - } \ - CATCH_INTERNAL_STOP_WARNINGS_SUPPRESSION - -// end catch_tag_alias_autoregistrar.h -// start catch_test_registry.h - -// start catch_interfaces_testcase.h - -#include - -namespace Catch { - -class TestSpec; - -struct ITestInvoker { - virtual void invoke() const = 0; - virtual ~ITestInvoker(); -}; - -class TestCase; -struct IConfig; - -struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted(IConfig const& config) const = 0; -}; - -bool isThrowSafe(TestCase const& testCase, IConfig const& config); -bool matchTest(TestCase const& testCase, TestSpec const& testSpec, IConfig const& config); -std::vector filterTests(std::vector const& testCases, TestSpec const& testSpec, - IConfig const& config); -std::vector const& getAllTestCasesSorted(IConfig const& config); - -} // namespace Catch - -// end catch_interfaces_testcase.h -// start catch_stringref.h - -#include -#include -#include -#include - -namespace Catch { - -/// A non-owning string class (similar to the forthcoming std::string_view) -/// Note that, because a StringRef may be a substring of another string, -/// it may not be null terminated. -class StringRef { - public: - using size_type = std::size_t; - using const_iterator = const char*; - - private: - static constexpr char const* const s_empty = ""; - - char const* m_start = s_empty; - size_type m_size = 0; - - public: // construction - constexpr StringRef() noexcept = default; - - StringRef(char const* rawChars) noexcept; - - constexpr StringRef(char const* rawChars, size_type size) noexcept - : m_start(rawChars), m_size(size) {} - - StringRef(std::string const& stdString) noexcept - : m_start(stdString.c_str()), m_size(stdString.size()) {} - - explicit operator std::string() const { return std::string(m_start, m_size); } - - public: // operators - auto operator==(StringRef const& other) const noexcept -> bool; - auto operator!=(StringRef const& other) const noexcept -> bool { return !(*this == other); } - - auto operator[](size_type index) const noexcept -> char { - assert(index < m_size); - return m_start[index]; - } - - public: // named queries - constexpr auto empty() const noexcept -> bool { return m_size == 0; } - constexpr auto size() const noexcept -> size_type { return m_size; } - - // Returns the current start pointer. If the StringRef is not - // null-terminated, throws std::domain_exception - auto c_str() const -> char const*; - - public: // substrings and searches - // Returns a substring of [start, start + length). - // If start + length > size(), then the substring is [start, size()). - // If start > size(), then the substring is empty. - auto substr(size_type start, size_type length) const noexcept -> StringRef; - - // Returns the current start pointer. May not be null-terminated. - auto data() const noexcept -> char const*; - - constexpr auto isNullTerminated() const noexcept -> bool { return m_start[m_size] == '\0'; } - - public: // iterators - constexpr const_iterator begin() const { return m_start; } - constexpr const_iterator end() const { return m_start + m_size; } -}; - -auto operator+=(std::string& lhs, StringRef const& sr) -> std::string&; -auto operator<<(std::ostream& os, StringRef const& sr) -> std::ostream&; - -constexpr auto operator"" _sr(char const* rawChars, std::size_t size) noexcept -> StringRef { - return StringRef(rawChars, size); -} -} // namespace Catch - -constexpr auto operator"" _catch_sr(char const* rawChars, std::size_t size) noexcept - -> Catch::StringRef { - return Catch::StringRef(rawChars, size); -} - -// end catch_stringref.h -// start catch_preprocessor.hpp - - -#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__ -#define CATCH_RECURSION_LEVEL1(...) \ - CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL2(...) \ - CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL3(...) \ - CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL4(...) \ - CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__))) -#define CATCH_RECURSION_LEVEL5(...) \ - CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__))) - -#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__ -// MSVC needs more evaluations -#define CATCH_RECURSION_LEVEL6(...) \ - CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__))) -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__)) -#else -#define CATCH_RECURSE(...) CATCH_RECURSION_LEVEL5(__VA_ARGS__) -#endif - -#define CATCH_REC_END(...) -#define CATCH_REC_OUT - -#define CATCH_EMPTY() -#define CATCH_DEFER(id) id CATCH_EMPTY() - -#define CATCH_REC_GET_END2() 0, CATCH_REC_END -#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2 -#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1 -#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT -#define CATCH_REC_NEXT1(test, next) CATCH_DEFER(CATCH_REC_NEXT0)(test, next, 0) -#define CATCH_REC_NEXT(test, next) CATCH_REC_NEXT1(CATCH_REC_GET_END test, next) - -#define CATCH_REC_LIST0(f, x, peek, ...) \ - , f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1))(f, peek, __VA_ARGS__) -#define CATCH_REC_LIST1(f, x, peek, ...) \ - , f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST0))(f, peek, __VA_ARGS__) -#define CATCH_REC_LIST2(f, x, peek, ...) \ - f(x) CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1))(f, peek, __VA_ARGS__) - -#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) \ - , f(userdata, x) \ - CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD))(f, userdata, peek, __VA_ARGS__) -#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) \ - , f(userdata, x) \ - CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD))(f, userdata, peek, __VA_ARGS__) -#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...) \ - f(userdata, x) \ - CATCH_DEFER(CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD))(f, userdata, peek, __VA_ARGS__) - -// Applies the function macro `f` to each of the remaining parameters, inserts commas between the -// results, and passes userdata as the first parameter to each invocation, e.g. CATCH_REC_LIST_UD(f, -// x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c) -#define CATCH_REC_LIST_UD(f, userdata, ...) \ - CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define CATCH_REC_LIST(f, ...) \ - CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0)) - -#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param) -#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO##__VA_ARGS__ -#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__ -#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE(...) INTERNAL_CATCH_STRINGIZE2(__VA_ARGS__) -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_STRINGIZE2(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) \ - INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) -#else -// MSVC is adding extra space and needs another indirection to expand -// INTERNAL_CATCH_NOINTERNAL_CATCH_DEF -#define INTERNAL_CATCH_STRINGIZE2(...) INTERNAL_CATCH_STRINGIZE3(__VA_ARGS__) -#define INTERNAL_CATCH_STRINGIZE3(...) #__VA_ARGS__ -#define INTERNAL_CATCH_STRINGIZE_WITHOUT_PARENS(param) \ - (INTERNAL_CATCH_STRINGIZE(INTERNAL_CATCH_REMOVE_PARENS(param)) + 1) -#endif - -#define INTERNAL_CATCH_MAKE_NAMESPACE2(...) ns_##__VA_ARGS__ -#define INTERNAL_CATCH_MAKE_NAMESPACE(name) INTERNAL_CATCH_MAKE_NAMESPACE2(name) - -#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__) - -#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) \ - decltype(get_wrapper()) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) \ - INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)) -#else -#define INTERNAL_CATCH_MAKE_TYPE_LIST2(...) \ - INTERNAL_CATCH_EXPAND_VARGS( \ - decltype(get_wrapper())) -#define INTERNAL_CATCH_MAKE_TYPE_LIST(...) \ - INTERNAL_CATCH_EXPAND_VARGS( \ - INTERNAL_CATCH_MAKE_TYPE_LIST2(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))) -#endif - -#define INTERNAL_CATCH_MAKE_TYPE_LISTS_FROM_TYPES(...) \ - CATCH_REC_LIST(INTERNAL_CATCH_MAKE_TYPE_LIST, __VA_ARGS__) - -#define INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_0) INTERNAL_CATCH_REMOVE_PARENS(_0) -#define INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_0, _1) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_1_ARG(_1) -#define INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_0, _1, _2) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_2_ARG(_1, _2) -#define INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_0, _1, _2, _3) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_3_ARG(_1, _2, _3) -#define INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_0, _1, _2, _3, _4) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_4_ARG(_1, _2, _3, _4) -#define INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_0, _1, _2, _3, _4, _5) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_5_ARG(_1, _2, _3, _4, _5) -#define INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_0, _1, _2, _3, _4, _5, _6) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_6_ARG(_1, _2, _3, _4, _5, _6) -#define INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_0, _1, _2, _3, _4, _5, _6, _7) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), INTERNAL_CATCH_REMOVE_PARENS_7_ARG(_1, _2, _3, _4, _5, _6, _7) -#define INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), \ - INTERNAL_CATCH_REMOVE_PARENS_8_ARG(_1, _2, _3, _4, _5, _6, _7, _8) -#define INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), \ - INTERNAL_CATCH_REMOVE_PARENS_9_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9) -#define INTERNAL_CATCH_REMOVE_PARENS_11_ARG(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10) \ - INTERNAL_CATCH_REMOVE_PARENS(_0), \ - INTERNAL_CATCH_REMOVE_PARENS_10_ARG(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) - -#define INTERNAL_CATCH_VA_NARGS_IMPL(_0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N - -#define INTERNAL_CATCH_TYPE_GEN \ - template struct TypeList {}; \ - template constexpr auto get_wrapper() noexcept -> TypeList { \ - return {}; \ - } \ - template