Files
TheRock/rocm-systems/projects/hip-tests/catch/cmake/hip-tests.cmake
T
derek.holloway 7502bf64a4
CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

141 lines
4.6 KiB
CMake

# Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
#
# SPDX-License-Identifier: MIT
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}"
)
hip_gen_exe_target(
NAME ${_NAME}
TEST_TARGET_NAME ${_TEST_TARGET_NAME}
TEST_SRC ${_TEST_SRC}
LINKER_LIBS ${_LINKER_LIBS}
COMMON_SHARED_SRC ${_COMMON_SHARED_SRC}
COMPILE_OPTIONS ${_COMPILE_OPTIONS}
PROPERTY ${_PROPERTY}
STANDALONE_FLAG 0
)
if(STANDALONE_TESTS)
# Generate per-file targets
hip_gen_exe_target(
NAME ${_NAME}
TEST_TARGET_NAME ${_TEST_TARGET_NAME}
TEST_SRC ${_TEST_SRC}
LINKER_LIBS ${_LINKER_LIBS}
COMMON_SHARED_SRC ${_COMMON_SHARED_SRC}
COMPILE_OPTIONS ${_COMPILE_OPTIONS}
PROPERTY ${_PROPERTY}
STANDALONE_FLAG 1
)
endif()
endfunction()
function(hip_gen_exe_target)
set(options)
set(args NAME TEST_TARGET_NAME PLATFORM COMPILE_OPTIONS STANDALONE_FLAG)
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_FLAG 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)
if(TARGET ${_EXE_NAME})
message(WARNING "Duplicate per-file target name detected: ${_EXE_NAME}. Skipping this target!")
continue()
endif()
endif()
# Create shared lib of all tests
set_source_files_properties(${SRC_NAME} PROPERTIES LANGUAGE ${GPGPU_LANGUAGE})
set_source_files_properties(${COMMON_SHARED_SRC} PROPERTIES LANGUAGE ${GPGPU_LANGUAGE})
if(NOT RTC_TESTING)
add_executable(${_EXE_NAME} EXCLUDE_FROM_ALL ${SRC_NAME} ${COMMON_SHARED_SRC} $<TARGET_OBJECTS:Main_Object> $<TARGET_OBJECTS:KERNELS>)
else ()
add_executable(${_EXE_NAME} EXCLUDE_FROM_ALL ${SRC_NAME} ${COMMON_SHARED_SRC} $<TARGET_OBJECTS:Main_Object>)
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 ${GPGPU_LANGUAGE})
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 ${GPGPU_LINKER_LIBRARIES})
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})
set(_DISCOVER_PROPERTIES "")
if (DEFINED HIP_TEST_LABELS)
list(APPEND _DISCOVER_PROPERTIES LABELS "${HIP_TEST_LABELS}")
endif()
catch_discover_tests("${_EXE_NAME}"
DISCOVERY_MODE PRE_TEST
ADD_TAGS_AS_LABELS
PROPERTIES ${_DISCOVER_PROPERTIES}
)
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})
add_dependencies(${_EXE_NAME} hip_tests_config)
if(NOT _STANDALONE_FLAG EQUAL "1")
break()
endif()
endforeach()
endfunction()