Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions tests/catch/ABM/AddKernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ set(TEST_SRC
add.cc
)

hip_add_exe_to_target(NAME ABMAddKernels
TEST_SRC ${TEST_SRC}
foreach(exe_name ${TEST_SRC})
hip_add_exe_to_target(NAME ${exe_name}
TEST_SRC ${exe_name}
TEST_TARGET_NAME build_tests)
endforeach()
11 changes: 7 additions & 4 deletions tests/catch/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,10 @@ 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)
Expand Down Expand Up @@ -217,13 +220,13 @@ add_custom_target(build_tests)

# Tests folder
add_subdirectory(unit ${CATCH_BUILD_DIR}/unit)
add_subdirectory(ABM ${CATCH_BUILD_DIR}/ABM)
#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(stress ${CATCH_BUILD_DIR}/stress)
#add_subdirectory(TypeQualifiers ${CATCH_BUILD_DIR}/TypeQualifiers)
if(UNIX)
add_subdirectory(multiproc ${CATCH_BUILD_DIR}/multiproc)
# add_subdirectory(multiproc ${CATCH_BUILD_DIR}/multiproc)
endif()

cmake_policy(POP)
Expand Down
114 changes: 58 additions & 56 deletions tests/catch/external/Catch2/cmake/Catch2/Catch.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ same as the Catch name; see also ``TEST_PREFIX`` and ``TEST_SUFFIX``.
#]=======================================================================]

#------------------------------------------------------------------------------
function(catch_discover_tests TARGET)
function(catch_discover_tests TARGET TEST_SET)
cmake_parse_arguments(
""
""
Expand All @@ -134,14 +134,16 @@ function(catch_discover_tests TARGET)
if(NOT _TEST_LIST)
set(_TEST_LIST ${TARGET}_TESTS)
endif()
set(EXE_LIST ${EXE_LIST} ${TARGET})

## 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}/${TARGET}_include-${args_hash}.cmake")
set(ctest_tests_file "${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_tests-${args_hash}.cmake")
set(exec_list_file "${CMAKE_CURRENT_BINARY_DIR}/${TEST_SET}_exec_list.txt")
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 _workdir ${CMAKE_CURRENT_BINARY_DIR} ${_WORKING_DIRECTORY})
Expand All @@ -157,27 +159,23 @@ function(catch_discover_tests TARGET)
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")
# Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY
APPEND PROPERTY TEST_INCLUDE_FILES "${ctestincludepath}"
)
else()
# Add discovered tests as directory TEST_INCLUDE_FILE if possible
get_property(test_include_file_set DIRECTORY PROPERTY TEST_INCLUDE_FILE SET)
if (NOT ${test_include_file_set})
if(NOT ${CMAKE_VERSION} VERSION_LESS "3.10.0")
if(NOT EXISTS ${exec_list_file})
set(include_file_contents "file(READ '${TEST_SET}_exec_list.txt' exc_names)\n")
set(include_file_contents ${include_file_contents} "set(TARGET ${TEST_SET})\n")
set(include_file_contents ${include_file_contents} "set(_workdir ${CMAKE_CURRENT_BINARY_DIR})\n")
set(include_file_contents ${include_file_contents} "set(ctestfilepath ${ctestfilepath})\n")
set(include_file_contents ${include_file_contents} "set(_CATCH_ADD_TEST_SCRIPT ${_CATCH_ADD_TEST_SCRIPT})\n")
set(include_file_contents ${include_file_contents} "set(_PROPERTIES ${_PROPERTIES})\n")
set(include_file_contents ${include_file_contents} "include(${CATCH_INCLUDE_PATH})\n")
file(WRITE ${ctest_include_file} ${include_file_contents})
# Add discovered tests to directory TEST_INCLUDE_FILES
set_property(DIRECTORY
PROPERTY TEST_INCLUDE_FILE "${ctestincludepath}"
)
else()
message(FATAL_ERROR
"Cannot set more than one TEST_INCLUDE_FILE"
APPEND PROPERTY TEST_INCLUDE_FILES "${ctestincludepath}"
)

endif()
file(APPEND ${exec_list_file} "${TARGET};")
endif()

endfunction()
Expand All @@ -202,47 +200,51 @@ 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} $<TARGET_OBJECTS:Main_Object> $<TARGET_OBJECTS:KERNELS>)
else ()
add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $<TARGET_OBJECTS:Main_Object>)
if(HIP_PLATFORM STREQUAL "amd")
target_link_libraries(${_NAME} hiprtc)
else()
target_link_libraries(${_NAME} nvrtc)

foreach(SRC_NAME ${TEST_SRC})
# TODO strip of the extension of the source to get the executable name
set(_EXE_NAME ${SRC_NAME})
# Create shared lib of all tests
if(NOT RTC_TESTING)
add_executable(${_EXE_NAME} EXCLUDE_FROM_ALL ${SRC_NAME} $<TARGET_OBJECTS:Main_Object> $<TARGET_OBJECTS:KERNELS>)
else ()
add_executable(${_EXE_NAME} EXCLUDE_FROM_ALL ${SRC_NAME} $<TARGET_OBJECTS:Main_Object>)
if(HIP_PLATFORM STREQUAL "amd")
target_link_libraries(${_EXE_NAME} hiprtc)
else()
target_link_libraries(${_EXE_NAME} nvrtc)
endif()
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 (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()
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 _LINKER_LIBS)
target_link_libraries(${_EXE_NAME} ${_LINKER_LIBS})
endif()

if (DEFINED _PROPERTY)
set_property(TARGET ${_NAME} PROPERTY ${_PROPERTY})
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(${_NAME} PUBLIC ${_COMPILE_OPTIONS})
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}")
foreach(arg IN LISTS _UNPARSED_ARGUMENTS)
message(WARNING "Unparsed arguments: ${arg}")
endforeach()
catch_discover_tests(${_EXE_NAME} ${_NAME} PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST")
endforeach()
endfunction()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,4 +135,4 @@ endforeach()
add_command(set ${TEST_LIST} ${tests})

# Write CTest script
file(WRITE "${CTEST_FILE}" "${script}")
file(APPEND "${CTEST_FILE}" "${script}")
41 changes: 41 additions & 0 deletions tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# 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)
message("Working dir : ${_workdir}" )


foreach(EXEC_NAME ${exc_names})
set(EXEC_NAME ${_workdir}/${EXEC_NAME})
message("names : ${EXEC_NAME}" )
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()

# include the generated ctest file for execution
include(${ctestfilepath})

34 changes: 0 additions & 34 deletions tests/catch/external/Catch2/cmake/Catch2/catch_include.cmake.in

This file was deleted.

24 changes: 12 additions & 12 deletions tests/catch/unit/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

add_subdirectory(rtc)
add_subdirectory(deviceLib)
add_subdirectory(graph)
add_subdirectory(memory)
add_subdirectory(stream)
#add_subdirectory(rtc)
#add_subdirectory(deviceLib)
#add_subdirectory(graph)
#add_subdirectory(memory)
#add_subdirectory(stream)
add_subdirectory(event)
add_subdirectory(occupancy)
add_subdirectory(device)
add_subdirectory(printf)
add_subdirectory(texture)
add_subdirectory(streamperthread)
add_subdirectory(kernel)
add_subdirectory(multiThread)
#add_subdirectory(occupancy)
#add_subdirectory(device)
#add_subdirectory(printf)
#add_subdirectory(texture)
#add_subdirectory(streamperthread)
#add_subdirectory(kernel)
#add_subdirectory(multiThread)
2 changes: 1 addition & 1 deletion tests/catch/unit/event/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ endif()

hip_add_exe_to_target(NAME EventTest
TEST_SRC ${TEST_SRC}
TEST_TARGET_NAME build_tests)
TEST_TARGET_NAME build_tests)