From ca57f979a0f951dc362bd55881fee4287d2600d8 Mon Sep 17 00:00:00 2001 From: Rahul Garg Date: Thu, 19 Jan 2023 14:09:14 -0800 Subject: [PATCH] Catch2 standalone exe (#129) * SWDEV-359379 - catch2: Standalone single exe per file -workaround for rsp file issue. -Creates single exe per file -tests detection is still during execution time and NOT compile time Change-Id: Iddfb83d57b2d767212f3d9307a276b7d572da6cd * SWDEV-359379 - Update CMakeList * Update Catch.cmake * Temporarily disable failing tests [ROCm/hip-tests commit: 961245e9f4893d90d9a1b3d38ac2db93b50ea798] --- projects/hip-tests/.jenkins/jenkinsfile | 6 +- projects/hip-tests/catch/CMakeLists.txt | 8 + .../external/Catch2/cmake/Catch2/Catch.cmake | 270 ++++++++++++++---- .../Catch2/cmake/Catch2/CatchAddTests.cmake | 2 +- .../Catch2/cmake/Catch2/catch_include.cmake | 41 +++ .../cmake/Catch2/catch_include.cmake.in | 34 --- .../hip-tests/catch/multiproc/CMakeLists.txt | 12 +- ...hipMemGetInfo.cc => hipMemGetInfoMProc.cc} | 0 .../catch/stress/memory/CMakeLists.txt | 2 +- ...ipHostMalloc.cc => hipHostMallocStress.cc} | 0 .../catch/unit/device/CMakeLists.txt | 6 +- .../unit/device/hipDeviceGetP2PAttribute.cc | 22 +- .../hip-tests/catch/unit/graph/CMakeLists.txt | 1 - .../catch/unit/memory/CMakeLists.txt | 11 +- .../catch/unit/printf/CMakeLists.txt | 8 +- .../catch/unit/printf/printfFlags.cc | 2 +- .../catch/unit/printf/printfSpecifiers.cc | 2 +- .../catch/unit/stream/CMakeLists.txt | 7 +- .../catch/unit/texture/CMakeLists.txt | 3 - 19 files changed, 306 insertions(+), 131 deletions(-) create mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake delete mode 100644 projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake.in rename projects/hip-tests/catch/multiproc/{hipMemGetInfo.cc => hipMemGetInfoMProc.cc} (100%) rename projects/hip-tests/catch/stress/memory/{hipHostMalloc.cc => hipHostMallocStress.cc} (100%) diff --git a/projects/hip-tests/.jenkins/jenkinsfile b/projects/hip-tests/.jenkins/jenkinsfile index 4e3ed8504f..48b654429f 100644 --- a/projects/hip-tests/.jenkins/jenkinsfile +++ b/projects/hip-tests/.jenkins/jenkinsfile @@ -83,7 +83,11 @@ def hipBuildTest(String backendLabel) { sh """#!/usr/bin/env bash set -x cd build - ctest + if [[ $backendLabel =~ amd ]]; then + ctest + else + ctest -E 'Unit_hipMemcpyHtoD_Positive_Synchronization_Behavior|Unit_hipFreeNegativeHost' + fi """ } } diff --git a/projects/hip-tests/catch/CMakeLists.txt b/projects/hip-tests/catch/CMakeLists.txt index 3f6c992059..9d5477f098 100644 --- a/projects/hip-tests/catch/CMakeLists.txt +++ b/projects/hip-tests/catch/CMakeLists.txt @@ -6,6 +6,9 @@ set(CMAKE_CXX_COMPILER_WORKS 1) project(hiptests) +#forcing exe per file. +set(STANDALONE_TESTS 1) +message(STATUS "STANDALONE_TESTS : ${STANDALONE_TESTS}") # Check if platform and compiler are set if(HIP_PLATFORM STREQUAL "amd") @@ -125,7 +128,12 @@ set(CATCH_BUILD_DIR catch_tests) file(COPY ./hipTestMain/config DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/hipTestMain) file(COPY ./external/Catch2/cmake/Catch2/CatchAddTests.cmake DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/script) +file(COPY ./external/Catch2/cmake/Catch2/catch_include.cmake + DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/script) set(ADD_SCRIPT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/script/CatchAddTests.cmake) +set(CATCH_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/script/catch_include.cmake) + + if (WIN32) configure_file(catchProp_in_rc.in ${CMAKE_CURRENT_BINARY_DIR}/catchProp.rc @ONLY) diff --git a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch.cmake b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch.cmake index 868ccfa739..6960d0ee3a 100644 --- a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch.cmake +++ b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/Catch.cmake @@ -118,8 +118,10 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``. #]=======================================================================] + #------------------------------------------------------------------------------ -function(catch_discover_tests TARGET) +# TARGET_LIST TEST_SET +function(catch_discover_tests_compile_time_detection TARGET TEST_SET) cmake_parse_arguments( "" "" @@ -140,28 +142,46 @@ function(catch_discover_tests TARGET) string(SUBSTRING ${args_hash} 0 7 args_hash) # Define rule to generate test list for aforementioned test executable - set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_include-${args_hash}.cmake") - set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake") + set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SET}_include-${args_hash}.cmake") + set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SET}_tests-${args_hash}.cmake") + + foreach(EXE_NAME ${TARGET}) + + add_custom_command( + TARGET ${EXE_NAME} POST_BUILD + COMMAND "${CMAKE_COMMAND}" + -D "TEST_TARGET=${EXE_NAME}" + -D "TEST_EXECUTABLE=$" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_WORKING_DIRECTORY}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "TEST_REPORTER=${_REPORTER}" + -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" + -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" + -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" + -D "CTEST_FILE=${ctest_tests_file}" + -P "${_CATCH_DISCOVER_TESTS_SCRIPT}" + VERBATIM + ) + endforeach() + file(RELATIVE_PATH ctestincludepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_include_file}) file(RELATIVE_PATH ctestfilepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_tests_file}) - file(RELATIVE_PATH _workdir ${CMAKE_CURRENT_BINARY_DIR} ${_WORKING_DIRECTORY}) - file(RELATIVE_PATH _CATCH_ADD_TEST_SCRIPT ${CMAKE_CURRENT_BINARY_DIR} ${ADD_SCRIPT_PATH}) - get_property(crosscompiling_emulator - TARGET ${TARGET} - PROPERTY CROSSCOMPILING_EMULATOR + file(WRITE "${ctest_include_file}" + "if(EXISTS \"${ctestfilepath}\")\n" + " include(\"${ctestfilepath}\")\n" + "else()\n" + " message(WARNING \"Test ${TARGET} not built yet.\")\n" + "endif()\n" ) - set(EXEC_NAME ${TARGET}) - if(WIN32) - set(EXEC_NAME ${EXEC_NAME}.exe) - endif() - - # uses catch_include.cmake.in file to generate the *_include.cmake file - # *_include.cmake is used to generate the *_test.cmake during execution of ctest cmd - configure_file(${CATCH2_INCLUDE} ${TARGET}_include-${args_hash}.cmake @ONLY) - - if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") # Add discovered tests to directory TEST_INCLUDE_FILES set_property(DIRECTORY APPEND PROPERTY TEST_INCLUDE_FILES "${ctestincludepath}" @@ -184,17 +204,61 @@ endfunction() ############################################################################### + + + +#------------------------------------------------------------------------------ +# current staging +function(catch_discover_tests TARGET_LIST TEST_SET) + cmake_parse_arguments( + "" + "" + "TEST_PREFIX;TEST_SUFFIX;WORKING_DIRECTORY;TEST_LIST;REPORTER;OUTPUT_DIR;OUTPUT_PREFIX;OUTPUT_SUFFIX" + "TEST_SPEC;EXTRA_ARGS;PROPERTIES" + ${ARGN} + ) + ## Generate a unique name based on the extra arguments + string(SHA1 args_hash "${_TEST_SPEC} ${_EXTRA_ARGS} ${_REPORTER} ${_OUTPUT_DIR} ${_OUTPUT_PREFIX} ${_OUTPUT_SUFFIX}") + string(SUBSTRING ${args_hash} 0 7 args_hash) + # Define rule to generate test list for aforementioned test executable + set(ctest_include_file "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SET}_include-${args_hash}.cmake") + set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SET}_tests-${args_hash}.cmake") + file(RELATIVE_PATH ctestincludepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_include_file}) + file(RELATIVE_PATH ctestfilepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_tests_file}) + file(RELATIVE_PATH _CATCH_ADD_TEST_SCRIPT ${CMAKE_CURRENT_BINARY_DIR} ${ADD_SCRIPT_PATH}) + file(RELATIVE_PATH CATCH_INCLUDE_PATH ${CMAKE_CURRENT_BINARY_DIR} ${CATCH_INCLUDE_PATH}) + if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0") + file(WRITE ${ctest_include_file} "set(exc_names ${TARGET_LIST})\n") + file(APPEND ${ctest_include_file} "set(TARGET ${TEST_SET})\n") + file(APPEND ${ctest_include_file} "set(_TEST_LIST ${TEST_SET}_TESTS)\n") + file(APPEND ${ctest_include_file} "set(ctestfilepath ${ctestfilepath})\n") + file(APPEND ${ctest_include_file} "set(_CATCH_ADD_TEST_SCRIPT ${_CATCH_ADD_TEST_SCRIPT})\n") + file(APPEND ${ctest_include_file} "set(crosscompiling_emulator ${crosscompiling_emulator})\n") + file(APPEND ${ctest_include_file} "set(_PROPERTIES ${_PROPERTIES})\n") + file(APPEND ${ctest_include_file} "include(${CATCH_INCLUDE_PATH})\n") + # Add discovered tests to directory TEST_INCLUDE_FILES + set_property(DIRECTORY + APPEND PROPERTY TEST_INCLUDE_FILES "${ctestincludepath}" + ) + endif() + +endfunction() + +############################################################################### + set(_CATCH_DISCOVER_TESTS_SCRIPT ${CMAKE_CURRENT_LIST_DIR}/CatchAddTests.cmake CACHE INTERNAL "Catch2 full path to CatchAddTests.cmake helper file" ) + ############################################################################### # function to be called by all tests -function(hip_add_exe_to_target) +function(hip_add_exe_to_target_compile_time_detection) set(options) + # NAME EventTest, TEST_SRC src, TEST_TARGET_NAME build_tests set(args NAME TEST_TARGET_NAME PLATFORM COMPILE_OPTIONS) - set(list_args TEST_SRC LINKER_LIBS PROPERTY) + set(list_args TEST_SRC LINKER_LIBS COMMON_SHARED_SRC PROPERTY) cmake_parse_arguments( PARSE_ARGV 0 "" # variable prefix @@ -202,48 +266,148 @@ function(hip_add_exe_to_target) "${args}" "${list_args}" ) - # Create shared lib of all tests - if(NOT RTC_TESTING) - add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $ $) - else () - add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $) - if(HIP_PLATFORM STREQUAL "amd") - target_link_libraries(${_NAME} hiprtc) + + foreach(SRC_NAME ${TEST_SRC}) + if(NOT STANDALONE_TESTS EQUAL "1") + set(_EXE_NAME ${_NAME}) + # take the entire source set for building the executable + set(SRC_NAME ${TEST_SRC}) else() - target_link_libraries(${_NAME} nvrtc) + # strip extension of src and use exe name as src name + get_filename_component(_EXE_NAME ${SRC_NAME} NAME_WLE) endif() - endif() - catch_discover_tests(${_NAME} PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") - if(UNIX) - set(_LINKER_LIBS ${_LINKER_LIBS} stdc++fs) - set(_LINKER_LIBS ${_LINKER_LIBS} -ldl) - 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") + + 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) + else() + target_link_libraries(${_EXE_NAME} nvrtc) + endif() endif() - endif() - if(DEFINED _LINKER_LIBS) - target_link_libraries(${_NAME} ${_LINKER_LIBS}) - endif() - # Add dependency on build_tests to build it on this custom target - add_dependencies(${_TEST_TARGET_NAME} ${_NAME}) - if (DEFINED _PROPERTY) - set_property(TARGET ${_NAME} PROPERTY ${_PROPERTY}) - endif() + if(UNIX) + set(_LINKER_LIBS ${_LINKER_LIBS} stdc++fs) + set(_LINKER_LIBS ${_LINKER_LIBS} -ldl) + 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(_LINKER_LIBS ${_LINKER_LIBS} -noAutoResponse) + endif() - if (DEFINED _COMPILE_OPTIONS) - target_compile_options(${_NAME} PUBLIC ${_COMPILE_OPTIONS}) - endif() + if(DEFINED _LINKER_LIBS) + target_link_libraries(${_EXE_NAME} ${_LINKER_LIBS}) + endif() - foreach(arg IN LISTS _UNPARSED_ARGUMENTS) - message(WARNING "Unparsed arguments: ${arg}") + # Add dependency on build_tests to build it on this custom target + add_dependencies(${_TEST_TARGET_NAME} ${_EXE_NAME}) + # add_dependencies(${_TEST_TARGET_NAME} ${_EXE_NAME}) + + if (DEFINED _PROPERTY) + set_property(TARGET ${_EXE_NAME} PROPERTY ${_PROPERTY}) + endif() + + if (DEFINED _COMPILE_OPTIONS) + target_compile_options(${_EXE_NAME} PUBLIC ${_COMPILE_OPTIONS}) + endif() + foreach(arg IN LISTS _UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments: ${arg}") + endforeach() + get_property(crosscompiling_emulator + TARGET ${_EXE_NAME} + PROPERTY CROSSCOMPILING_EMULATOR + ) + set(_EXE_NAME_LIST ${_EXE_NAME_LIST} ${_EXE_NAME}) + if(NOT STANDALONE_TESTS EQUAL "1") + break() + endif() endforeach() + catch_discover_tests("${_EXE_NAME_LIST}" "${_NAME}" PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") endfunction() +############################################################################### +# 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 + 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) + else() + target_link_libraries(${_EXE_NAME} nvrtc) + endif() + endif() + 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) + 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() + 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() + + foreach(arg IN LISTS _UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments: ${arg}") + endforeach() + get_property(crosscompiling_emulator + TARGET ${_EXE_NAME} + PROPERTY CROSSCOMPILING_EMULATOR + ) + set(_EXE_NAME_LIST ${_EXE_NAME_LIST} ${_EXE_NAME}) + if(NOT STANDALONE_TESTS EQUAL "1") + break() + endif() + + endforeach() + + catch_discover_tests("${_EXE_NAME_LIST}" "${_NAME}" PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") +endfunction() diff --git a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/CatchAddTests.cmake b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/CatchAddTests.cmake index 97ccac4eff..2b13187a7d 100644 --- a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/CatchAddTests.cmake +++ b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/CatchAddTests.cmake @@ -135,4 +135,4 @@ endforeach() add_command(set ${TEST_LIST} ${tests}) # Write CTest script -file(WRITE "${CTEST_FILE}" "${script}") +file(APPEND "${CTEST_FILE}" "${script}") diff --git a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake new file mode 100644 index 0000000000..b698e8b96c --- /dev/null +++ b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake @@ -0,0 +1,41 @@ +# when ctest is ran, each submodule includes this file to generate the _tests.cmake file. +# _tests.cmake contains the add_test macro which runs the individual test. + +get_filename_component(_cmake_path cmake ABSOLUTE) + +foreach(EXEC_NAME ${exc_names}) + if(WIN32) + set(EXEC_NAME ${EXEC_NAME}.exe) + endif() + if(EXISTS "${EXEC_NAME}") + execute_process( + COMMAND "${_cmake_path}" + -D "TEST_TARGET=${TARGET}" + -D "TEST_EXECUTABLE=${EXEC_NAME}" + -D "TEST_EXECUTOR=${crosscompiling_emulator}" + -D "TEST_WORKING_DIR=${_workdir}" + -D "TEST_SPEC=${_TEST_SPEC}" + -D "TEST_EXTRA_ARGS=${_EXTRA_ARGS}" + -D "TEST_PROPERTIES=${_PROPERTIES}" + -D "TEST_PREFIX=${_TEST_PREFIX}" + -D "TEST_SUFFIX=${_TEST_SUFFIX}" + -D "TEST_LIST=${_TEST_LIST}" + -D "TEST_REPORTER=${_REPORTER}" + -D "TEST_OUTPUT_DIR=${_OUTPUT_DIR}" + -D "TEST_OUTPUT_PREFIX=${_OUTPUT_PREFIX}" + -D "TEST_OUTPUT_SUFFIX=${_OUTPUT_SUFFIX}" + -D "CTEST_FILE=${ctestfilepath}" + -P "${_CATCH_ADD_TEST_SCRIPT}" + OUTPUT_VARIABLE output + RESULT_VARIABLE result + WORKING_DIRECTORY "${TEST_WORKING_DIR}" + ) + else() + message("executable not found : ${EXEC_NAME}" ) + endif() +endforeach() + +if(EXISTS "${ctestfilepath}") +# include the generated ctest file for execution +include(${ctestfilepath}) +endif() diff --git a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake.in b/projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake.in deleted file mode 100644 index c318ebc5df..0000000000 --- a/projects/hip-tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake.in +++ /dev/null @@ -1,34 +0,0 @@ -# File @ctestincludepath@ is generated by cmake. -# For changes please modify hip/tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake.in - -get_filename_component(_cmake_path cmake ABSOLUTE) - -if(EXISTS "@EXEC_NAME@") - execute_process( - COMMAND "${_cmake_path}" - -D "TEST_TARGET=@TARGET@" - -D "TEST_EXECUTABLE=@EXEC_NAME@" - -D "TEST_EXECUTOR=@crosscompiling_emulator@" - -D "TEST_WORKING_DIR=@_workdir@" - -D "TEST_SPEC=@_TEST_SPEC@" - -D "TEST_EXTRA_ARGS=@_EXTRA_ARGS@" - -D "TEST_PROPERTIES=@_PROPERTIES@" - -D "TEST_PREFIX=@_TEST_PREFIX@" - -D "TEST_SUFFIX=@_TEST_SUFFIX@" - -D "TEST_LIST=@_TEST_LIST@" - -D "TEST_REPORTER=@_REPORTER@" - -D "TEST_OUTPUT_DIR=@_OUTPUT_DIR@" - -D "TEST_OUTPUT_PREFIX=@_OUTPUT_PREFIX@" - -D "TEST_OUTPUT_SUFFIX=@_OUTPUT_SUFFIX@" - -D "CTEST_FILE=@ctestfilepath@" - -P "@_CATCH_ADD_TEST_SCRIPT@" - OUTPUT_VARIABLE output - RESULT_VARIABLE result - WORKING_DIRECTORY "@TEST_WORKING_DIR@" - ) - # include the generated ctest file for execution - include(@ctestfilepath@) -else() - message(STATUS "executable not built : @EXEC_NAME@" ) -endif() - diff --git a/projects/hip-tests/catch/multiproc/CMakeLists.txt b/projects/hip-tests/catch/multiproc/CMakeLists.txt index 5485ee9ca5..7a83b7d058 100644 --- a/projects/hip-tests/catch/multiproc/CMakeLists.txt +++ b/projects/hip-tests/catch/multiproc/CMakeLists.txt @@ -1,5 +1,5 @@ # Common Tests -set(LINUX_TEST_SRC +set(TEST_SRC childMalloc.cc hipDeviceComputeCapabilityMproc.cc hipDeviceGetPCIBusIdMproc.cc @@ -12,10 +12,9 @@ set(LINUX_TEST_SRC hipMallocConcurrencyMproc.cc hipMemCoherencyTstMProc.cc hipIpcEventHandle.cc - hipIpcMemAccessTest.cc deviceAllocationMproc.cc hipNoGpuTsts.cc - hipMemGetInfo.cc + hipMemGetInfoMProc.cc ) add_custom_target(dummy_kernel.code COMMAND ${CMAKE_CXX_COMPILER} --genco ${CMAKE_CURRENT_SOURCE_DIR}/dummy_kernel.cpp -o ${CMAKE_CURRENT_BINARY_DIR}/../multiproc/dummy_kernel.code -I${CMAKE_CURRENT_SOURCE_DIR}/../../../../include/ -I${CMAKE_CURRENT_SOURCE_DIR}/../../include) @@ -23,14 +22,13 @@ add_custom_target(dummy_kernel.code COMMAND ${CMAKE_CXX_COMPILER} --genco ${CMAK # the last argument linker libraries is required for this test but optional to the function if(HIP_PLATFORM MATCHES "nvidia") hip_add_exe_to_target(NAME MultiProc - TEST_SRC ${LINUX_TEST_SRC} + TEST_SRC ${TEST_SRC} TEST_TARGET_NAME build_tests LINKER_LIBS nvrtc) elseif(HIP_PLATFORM MATCHES "amd") hip_add_exe_to_target(NAME MultiProc - TEST_SRC ${LINUX_TEST_SRC} - TEST_TARGET_NAME build_tests - LINKER_LIBS ${CMAKE_DL_LIBS}) + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) endif() add_dependencies(build_tests dummy_kernel.code) diff --git a/projects/hip-tests/catch/multiproc/hipMemGetInfo.cc b/projects/hip-tests/catch/multiproc/hipMemGetInfoMProc.cc similarity index 100% rename from projects/hip-tests/catch/multiproc/hipMemGetInfo.cc rename to projects/hip-tests/catch/multiproc/hipMemGetInfoMProc.cc diff --git a/projects/hip-tests/catch/stress/memory/CMakeLists.txt b/projects/hip-tests/catch/stress/memory/CMakeLists.txt index e55869f8e3..bf172bd642 100644 --- a/projects/hip-tests/catch/stress/memory/CMakeLists.txt +++ b/projects/hip-tests/catch/stress/memory/CMakeLists.txt @@ -4,7 +4,7 @@ set(TEST_SRC hipMemcpyMThreadMSize.cc hipMallocManagedStress.cc hipMemPrftchAsyncStressTst.cc - hipHostMalloc.cc + hipHostMallocStress.cc ) hip_add_exe_to_target(NAME memory diff --git a/projects/hip-tests/catch/stress/memory/hipHostMalloc.cc b/projects/hip-tests/catch/stress/memory/hipHostMallocStress.cc similarity index 100% rename from projects/hip-tests/catch/stress/memory/hipHostMalloc.cc rename to projects/hip-tests/catch/stress/memory/hipHostMallocStress.cc diff --git a/projects/hip-tests/catch/unit/device/CMakeLists.txt b/projects/hip-tests/catch/unit/device/CMakeLists.txt index 1e26944d0f..2cb03d0575 100644 --- a/projects/hip-tests/catch/unit/device/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/device/CMakeLists.txt @@ -41,12 +41,12 @@ set_source_files_properties(hipGetDeviceCount.cc PROPERTIES COMPILE_FLAGS -std=c set_source_files_properties(hipDeviceGetP2PAttribute.cc PROPERTIES COMPILE_FLAGS -std=c++17) add_executable(getDeviceCount EXCLUDE_FROM_ALL getDeviceCount_exe.cc) -add_executable(hipDeviceGetP2PAttribute EXCLUDE_FROM_ALL hipDeviceGetP2PAttribute_exe.cc) +add_executable(hipDeviceGetP2PAttribute_exe EXCLUDE_FROM_ALL hipDeviceGetP2PAttribute_exe.cc) hip_add_exe_to_target(NAME DeviceTest TEST_SRC ${TEST_SRC} TEST_TARGET_NAME build_tests COMPILE_OPTIONS -std=c++14) -add_dependencies(DeviceTest getDeviceCount) -add_dependencies(DeviceTest hipDeviceGetP2PAttribute) +add_dependencies(build_tests getDeviceCount) +add_dependencies(build_tests hipDeviceGetP2PAttribute_exe) diff --git a/projects/hip-tests/catch/unit/device/hipDeviceGetP2PAttribute.cc b/projects/hip-tests/catch/unit/device/hipDeviceGetP2PAttribute.cc index 584257e616..e126856d1d 100644 --- a/projects/hip-tests/catch/unit/device/hipDeviceGetP2PAttribute.cc +++ b/projects/hip-tests/catch/unit/device/hipDeviceGetP2PAttribute.cc @@ -122,20 +122,20 @@ TEST_CASE("Unit_hipDeviceGetP2PAttribute_Negative") { /* https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#env-vars */ SECTION("Hidden devices using environment variables") { - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("") == hipSuccess); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("0") == hipErrorInvalidDevice); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("1") == hipErrorInvalidDevice); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("0,1") == hipSuccess); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("-1,0") == hipErrorNoDevice); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("0,-1") == hipErrorInvalidDevice); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("0,1,-1") == hipSuccess); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("0,-1,1") == hipErrorInvalidDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("") == hipSuccess); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("0") == hipErrorInvalidDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("1") == hipErrorInvalidDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("0,1") == hipSuccess); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("-1,0") == hipErrorNoDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("0,-1") == hipErrorInvalidDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("0,1,-1") == hipSuccess); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("0,-1,1") == hipErrorInvalidDevice); if (deviceCount > 2) { - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("2,1") == hipSuccess); - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("2") == hipErrorInvalidDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("2,1") == hipSuccess); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("2") == hipErrorInvalidDevice); } else { - REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute").run("2,1") == hipErrorNoDevice); + REQUIRE(hip::SpawnProc("hipDeviceGetP2PAttribute_exe").run("2,1") == hipErrorNoDevice); } } #endif diff --git a/projects/hip-tests/catch/unit/graph/CMakeLists.txt b/projects/hip-tests/catch/unit/graph/CMakeLists.txt index c9d1bb34ea..dcb9b9ac5d 100644 --- a/projects/hip-tests/catch/unit/graph/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/graph/CMakeLists.txt @@ -59,7 +59,6 @@ set(TEST_SRC hipGraphEventWaitNodeGetEvent.cc hipGraphExecMemcpyNodeSetParams.cc hipStreamBeginCapture.cc - hipGraphAddMemcpyNode1D.cc hipStreamIsCapturing.cc hipStreamGetCaptureInfo.cc hipStreamEndCapture.cc diff --git a/projects/hip-tests/catch/unit/memory/CMakeLists.txt b/projects/hip-tests/catch/unit/memory/CMakeLists.txt index ecb2411180..876dae382b 100644 --- a/projects/hip-tests/catch/unit/memory/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/memory/CMakeLists.txt @@ -18,10 +18,11 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. +set(COMMON_SHARED_SRC DriverContext.cc) + # Common Tests - Test independent of all platforms if(HIP_PLATFORM MATCHES "amd") set(TEST_SRC - DriverContext.cc memset.cc malloc.cc hipMemcpy2DToArray.cc @@ -46,7 +47,6 @@ set(TEST_SRC hipMemcpy_MultiThread.cc hipHostRegister.cc hipHostUnregister.cc - hipMallocPitch.cc hipMemPtrGetInfo.cc hipPointerGetAttributes.cc hipHostGetFlags.cc @@ -79,7 +79,6 @@ set(TEST_SRC hipMemcpyWithStreamMultiThread.cc hipMemsetAsyncAndKernel.cc hipMemset2DAsyncMultiThreadAndKernel.cc - hipMallocManaged.cc hipMallocConcurrency.cc hipMemcpyDtoD.cc hipMemcpyDtoDAsync.cc @@ -117,7 +116,6 @@ set(TEST_SRC ) else() set(TEST_SRC - DriverContext.cc memset.cc malloc.cc hipMemcpy2DToArray.cc @@ -142,7 +140,6 @@ set(TEST_SRC hipMemcpy_MultiThread.cc hipHostRegister.cc hipHostUnregister.cc - hipMallocPitch.cc hipHostGetFlags.cc hipHostGetDevicePointer.cc hipMallocManaged_MultiScenario.cc @@ -172,7 +169,6 @@ set(TEST_SRC hipMemcpyWithStreamMultiThread.cc hipMemsetAsyncAndKernel.cc hipMemset2DAsyncMultiThreadAndKernel.cc - hipMallocManaged.cc hipMallocConcurrency.cc hipMemcpyDtoD.cc hipMemcpyDtoDAsync.cc @@ -217,4 +213,5 @@ endif() hip_add_exe_to_target(NAME MemoryTest TEST_SRC ${TEST_SRC} - TEST_TARGET_NAME build_tests) + TEST_TARGET_NAME build_tests + COMMON_SHARED_SRC ${COMMON_SHARED_SRC}) diff --git a/projects/hip-tests/catch/unit/printf/CMakeLists.txt b/projects/hip-tests/catch/unit/printf/CMakeLists.txt index d2a9d6eced..74d4421a77 100644 --- a/projects/hip-tests/catch/unit/printf/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/printf/CMakeLists.txt @@ -18,8 +18,8 @@ elseif (HIP_PLATFORM MATCHES "nvidia") endif() # Standalone exes -add_executable(printfFlags EXCLUDE_FROM_ALL printfFlags_exe.cc) -add_executable(printfSpecifiers EXCLUDE_FROM_ALL printfSpecifiers_exe.cc) +add_executable(printfFlags_exe EXCLUDE_FROM_ALL printfFlags_exe.cc) +add_executable(printfSpecifiers_exe EXCLUDE_FROM_ALL printfSpecifiers_exe.cc) -add_dependencies(printfTests printfFlags) -add_dependencies(printfTests printfSpecifiers) +add_dependencies(build_tests printfFlags_exe) +add_dependencies(build_tests printfSpecifiers_exe) diff --git a/projects/hip-tests/catch/unit/printf/printfFlags.cc b/projects/hip-tests/catch/unit/printf/printfFlags.cc index b9955b0b60..8fa5181ba2 100644 --- a/projects/hip-tests/catch/unit/printf/printfFlags.cc +++ b/projects/hip-tests/catch/unit/printf/printfFlags.cc @@ -37,7 +37,7 @@ xyzzy 00000042 )here"); - hip::SpawnProc proc("printfFlags", true); + hip::SpawnProc proc("printfFlags_exe", true); REQUIRE(proc.run() == 0); REQUIRE(proc.getOutput() == reference); } diff --git a/projects/hip-tests/catch/unit/printf/printfSpecifiers.cc b/projects/hip-tests/catch/unit/printf/printfSpecifiers.cc index 223a3c338b..0f366f8c58 100644 --- a/projects/hip-tests/catch/unit/printf/printfSpecifiers.cc +++ b/projects/hip-tests/catch/unit/printf/printfSpecifiers.cc @@ -89,7 +89,7 @@ x )here"); #endif - hip::SpawnProc proc("printfSpecifiers", true); + hip::SpawnProc proc("printfSpecifiers_exe", true); REQUIRE(0 == proc.run()); REQUIRE(proc.getOutput() == reference); } diff --git a/projects/hip-tests/catch/unit/stream/CMakeLists.txt b/projects/hip-tests/catch/unit/stream/CMakeLists.txt index 38e651e5b7..74024fce2a 100644 --- a/projects/hip-tests/catch/unit/stream/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/stream/CMakeLists.txt @@ -1,3 +1,5 @@ +set(COMMON_SHARED_SRC streamCommon.cc) + if(HIP_PLATFORM MATCHES "amd") set(TEST_SRC hipStreamCreate.cc @@ -10,7 +12,6 @@ set(TEST_SRC hipStreamDestroy.cc hipStreamGetCUMask.cc hipAPIStreamDisable.cc - streamCommon.cc hipStreamValue.cc hipStreamWithCUMask.cc hipStreamACb_MultiThread.cc @@ -34,7 +35,6 @@ set(TEST_SRC hipAPIStreamDisable.cc # hipStreamAttachMemAsync_old.cc # Disabling it on nvidia due to issue in function definition of hipStreamAttachMemAsync # Fixing would break ABI, to be re-enabled when the fix is made. - streamCommon.cc hipStreamValue.cc hipStreamSynchronize.cc hipStreamQuery.cc @@ -48,4 +48,5 @@ endif() hip_add_exe_to_target(NAME StreamTest TEST_SRC ${TEST_SRC} TEST_TARGET_NAME build_tests - COMPILE_OPTIONS -std=c++17) + COMPILE_OPTIONS -std=c++17 + COMMON_SHARED_SRC ${COMMON_SHARED_SRC}) diff --git a/projects/hip-tests/catch/unit/texture/CMakeLists.txt b/projects/hip-tests/catch/unit/texture/CMakeLists.txt index c05db818e6..93a188683c 100644 --- a/projects/hip-tests/catch/unit/texture/CMakeLists.txt +++ b/projects/hip-tests/catch/unit/texture/CMakeLists.txt @@ -37,9 +37,6 @@ set(TEST_SRC hipGetChanDesc.cc hipTexObjPitch.cc hipTextureObj1DFetch.cc - hipBindTex2DPitch.cc - hipBindTexRef1DFetch.cc - hipTex1DFetchCheckModes.cc hipTextureObj1DCheckModes.cc hipTextureObj2DCheckModes.cc hipTextureObj3DCheckModes.cc