From 6a5e1ea51e0df17ee620547ade1b39bfa3d15b62 Mon Sep 17 00:00:00 2001 From: agunashe <86270081+agunashe@users.noreply.github.com> Date: Thu, 25 Nov 2021 21:32:29 -0800 Subject: [PATCH] SWDEV-273235 - Linux: catch2 shared lib to executable (#2421) Change-Id: I17101e39fd05eb35c087ebdf3cb005d428d9f206 [ROCm/hip commit: 6c2453115658f17aaac41c09c77da743336e9391] --- .../tests/catch/ABM/AddKernels/CMakeLists.txt | 8 +- .../tests/catch/TypeQualifiers/CMakeLists.txt | 10 +-- .../external/Catch2/cmake/Catch2/Catch.cmake | 43 +++++++++- .../tests/catch/hipTestMain/CMakeLists.txt | 81 +------------------ .../tests/catch/include/hip_test_common.hh | 1 + .../tests/catch/include/hip_test_helper.hh | 2 +- .../hip/tests/catch/multiproc/CMakeLists.txt | 12 ++- .../hip/tests/catch/stress/CMakeLists.txt | 2 + .../tests/catch/stress/memory/CMakeLists.txt | 8 +- .../stress/memory/hipMemcpyMThreadMSize.cc | 2 +- .../hip/tests/catch/stress/memory/memcpy.cc | 2 +- .../tests/catch/stress/printf/CMakeLists.txt | 8 +- .../tests/catch/stress/stream/CMakeLists.txt | 8 +- .../tests/catch/unit/device/CMakeLists.txt | 9 +-- .../tests/catch/unit/deviceLib/CMakeLists.txt | 19 ++--- .../hip/tests/catch/unit/event/CMakeLists.txt | 8 +- .../tests/catch/unit/memory/CMakeLists.txt | 7 +- .../tests/catch/unit/occupancy/CMakeLists.txt | 8 +- .../tests/catch/unit/printf/CMakeLists.txt | 20 ++--- .../tests/catch/unit/printf/printfFlags.cc | 2 +- .../catch/unit/printf/printfSpecifiers.cc | 2 +- .../tests/catch/unit/printfExe/printfFlags.cc | 2 +- .../catch/unit/printfExe/printfSepcifiers.cc | 2 +- .../hip/tests/catch/unit/rtc/CMakeLists.txt | 22 +++-- .../tests/catch/unit/stream/CMakeLists.txt | 8 +- .../tests/catch/unit/texture/CMakeLists.txt | 8 +- 26 files changed, 121 insertions(+), 183 deletions(-) diff --git a/projects/hip/tests/catch/ABM/AddKernels/CMakeLists.txt b/projects/hip/tests/catch/ABM/AddKernels/CMakeLists.txt index 543f01d7a7..776f0fa5f1 100644 --- a/projects/hip/tests/catch/ABM/AddKernels/CMakeLists.txt +++ b/projects/hip/tests/catch/ABM/AddKernels/CMakeLists.txt @@ -3,8 +3,6 @@ set(TEST_SRC add.cc ) -# Create shared lib of all tests -add_library(ABMAddKernels SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests ABMAddKernels) +hip_add_exe_to_target(NAME ABMAddKernels + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/projects/hip/tests/catch/TypeQualifiers/CMakeLists.txt b/projects/hip/tests/catch/TypeQualifiers/CMakeLists.txt index 3c60bdf411..0219c0021b 100644 --- a/projects/hip/tests/catch/TypeQualifiers/CMakeLists.txt +++ b/projects/hip/tests/catch/TypeQualifiers/CMakeLists.txt @@ -3,10 +3,6 @@ set(TEST_SRC hipManagedKeyword.cc ) - -# Create shared lib of all tests -add_library(TypeQualifiers SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests TypeQualifiers) - +hip_add_exe_to_target(NAME TypeQualifiers + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) 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 a388516203..38da2b8097 100644 --- a/projects/hip/tests/catch/external/Catch2/cmake/Catch2/Catch.cmake +++ b/projects/hip/tests/catch/external/Catch2/cmake/Catch2/Catch.cmake @@ -173,7 +173,7 @@ function(catch_discover_tests TARGET) "if(EXISTS \"${ctest_tests_file}\")\n" " include(\"${ctest_tests_file}\")\n" "else()\n" - " add_test(${TARGET}_NOT_BUILT-${args_hash} ${TARGET}_NOT_BUILT-${args_hash})\n" + " message(WARNING \"Test ${TARGET} not built yet.\")\n" "endif()\n" ) @@ -204,3 +204,44 @@ 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) + set(options) + set(args NAME TEST_TARGET_NAME PLATFORM COMPILE_OPTIONS) + set(list_args TEST_SRC LINKER_LIBS PROPERTY) + cmake_parse_arguments( + PARSE_ARGV 0 + "" # variable prefix + "${options}" + "${args}" + "${list_args}" + ) + # Create shared lib of all tests + add_executable(${_NAME} EXCLUDE_FROM_ALL ${_TEST_SRC} $) + catch_discover_tests(${_NAME} PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") + if(UNIX) + set(_LINKER_LIBS ${_LINKER_LIBS} stdc++fs) + 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 (DEFINED _COMPILE_OPTIONS) + target_compile_options(${_NAME} PUBLIC ${_COMPILE_OPTIONS}) + endif() + + foreach(arg IN LISTS _UNPARSED_ARGUMENTS) + message(WARNING "Unparsed arguments: ${arg}") + endforeach() +endfunction() + + diff --git a/projects/hip/tests/catch/hipTestMain/CMakeLists.txt b/projects/hip/tests/catch/hipTestMain/CMakeLists.txt index 2ebb95d877..13407032a8 100644 --- a/projects/hip/tests/catch/hipTestMain/CMakeLists.txt +++ b/projects/hip/tests/catch/hipTestMain/CMakeLists.txt @@ -22,84 +22,9 @@ if(CMAKE_BUILD_TYPE MATCHES "^Debug$") add_definitions(-DHT_LOG_ENABLE) endif() -add_executable(UnitTests EXCLUDE_FROM_ALL main.cc hip_test_context.cc) +add_library(Main_Object EXCLUDE_FROM_ALL OBJECT main.cc hip_test_context.cc) if(HIP_PLATFORM MATCHES "amd") - set_property(TARGET UnitTests PROPERTY CXX_STANDARD 17) + set_property(TARGET Main_Object PROPERTY CXX_STANDARD 17) else() - target_compile_options(UnitTests PUBLIC -std=c++17) + target_compile_options(Main_Object PUBLIC -std=c++17) endif() - -target_link_libraries(UnitTests PRIVATE UnitDeviceTests - MemoryTest - StreamTest - EventTest - OccupancyTest - DeviceTest - RTC - printfTests - TextureTest - GraphsTest - stdc++fs) - -if(HIP_PLATFORM MATCHES "nvidia") - target_link_libraries(UnitTests PRIVATE nvrtc) -endif() - -catch_discover_tests(UnitTests PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") - -# ABM exe -add_executable(ABMTests EXCLUDE_FROM_ALL main.cc hip_test_context.cc) -if(HIP_PLATFORM MATCHES "amd") - set_property(TARGET ABMTests PROPERTY CXX_STANDARD 17) -else() - target_compile_options(ABMTests PUBLIC -std=c++17) -endif() - -target_link_libraries(ABMTests PRIVATE ABMAddKernels - stdc++fs) - -catch_discover_tests(ABMTests PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") - -add_dependencies(build_tests UnitTests ABMTests) - -# Add Multiproc tests as seperate binary -if(UNIX) - add_executable(MultiProcTests EXCLUDE_FROM_ALL main.cc hip_test_context.cc) - - if(HIP_PLATFORM MATCHES "amd") - set_property(TARGET MultiProcTests PROPERTY CXX_STANDARD 17) - else() - target_compile_options(MultiProcTests PUBLIC -std=c++17) - endif() - - target_link_libraries(MultiProcTests PRIVATE MultiProc - stdc++fs) - catch_discover_tests(MultiProcTests PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") - add_dependencies(build_tests MultiProcTests) -endif() - -add_executable(StressTest EXCLUDE_FROM_ALL main.cc hip_test_context.cc) -add_custom_target(build_stress_test) -if(HIP_PLATFORM MATCHES "amd") - set_property(TARGET StressTest PROPERTY CXX_STANDARD 17) -else() - target_compile_options(StressTest PUBLIC -std=c++17) -endif() -if(HIP_PLATFORM MATCHES "amd") -target_link_libraries(StressTest PRIVATE printf stream) -endif() -target_link_libraries(StressTest PRIVATE memory stdc++fs) -add_dependencies(build_stress_test StressTest) -add_custom_target(stress_test COMMAND StressTest) - -# Space Specifiers/Qualifiers exe -add_executable(TypeQualifierTests EXCLUDE_FROM_ALL main.cc hip_test_context.cc) -if(HIP_PLATFORM MATCHES "amd") - set_property(TARGET TypeQualifierTests PROPERTY CXX_STANDARD 17) -else() - target_compile_options(TypeQualifierTests PUBLIC -std=c++17) -endif() -target_link_libraries(TypeQualifierTests PRIVATE TypeQualifiers stdc++fs) - -catch_discover_tests(TypeQualifierTests PROPERTIES SKIP_REGULAR_EXPRESSION "HIP_SKIP_THIS_TEST") -add_dependencies(build_tests TypeQualifierTests) diff --git a/projects/hip/tests/catch/include/hip_test_common.hh b/projects/hip/tests/catch/include/hip_test_common.hh index 9107740333..a7e09a392b 100644 --- a/projects/hip/tests/catch/include/hip_test_common.hh +++ b/projects/hip/tests/catch/include/hip_test_common.hh @@ -104,4 +104,5 @@ static inline unsigned setNumBlocks(unsigned blocksPerCU, unsigned threadsPerBlo return blocks; } + } diff --git a/projects/hip/tests/catch/include/hip_test_helper.hh b/projects/hip/tests/catch/include/hip_test_helper.hh index 0ea01021e3..add9e40229 100644 --- a/projects/hip/tests/catch/include/hip_test_helper.hh +++ b/projects/hip/tests/catch/include/hip_test_helper.hh @@ -24,7 +24,7 @@ THE SOFTWARE. #include "hip_test_common.hh" #ifdef __linux__ -#include + #include #endif namespace HipTest { diff --git a/projects/hip/tests/catch/multiproc/CMakeLists.txt b/projects/hip/tests/catch/multiproc/CMakeLists.txt index 68b87336c1..78de21f674 100644 --- a/projects/hip/tests/catch/multiproc/CMakeLists.txt +++ b/projects/hip/tests/catch/multiproc/CMakeLists.txt @@ -15,11 +15,9 @@ set(LINUX_TEST_SRC ) if(UNIX) - # Create shared lib of all tests - add_library(MultiProc SHARED EXCLUDE_FROM_ALL ${LINUX_TEST_SRC}) - - target_link_libraries(MultiProc ${CMAKE_DL_LIBS}) - - # Add dependency on build_tests to build it on this custom target - add_dependencies(build_tests MultiProc) + # the last argument linker libraries is required for this test but optional to the function + hip_add_exe_to_target(NAME MultiProc + TEST_SRC ${LINUX_TEST_SRC} + TEST_TARGET_NAME build_tests + LINKER_LIBS ${CMAKE_DL_LIBS}) endif() diff --git a/projects/hip/tests/catch/stress/CMakeLists.txt b/projects/hip/tests/catch/stress/CMakeLists.txt index 00e12f2c2c..2b022bf481 100644 --- a/projects/hip/tests/catch/stress/CMakeLists.txt +++ b/projects/hip/tests/catch/stress/CMakeLists.txt @@ -1,3 +1,5 @@ +add_custom_target(stress_test COMMAND "${CMAKE_CTEST_COMMAND}" -R "Stress_") + add_subdirectory(memory) if(HIP_PLATFORM MATCHES "amd") add_subdirectory(printf) diff --git a/projects/hip/tests/catch/stress/memory/CMakeLists.txt b/projects/hip/tests/catch/stress/memory/CMakeLists.txt index a360839d7d..0c2d3fc6aa 100644 --- a/projects/hip/tests/catch/stress/memory/CMakeLists.txt +++ b/projects/hip/tests/catch/stress/memory/CMakeLists.txt @@ -5,8 +5,6 @@ set(TEST_SRC hipMallocManagedStress.cc ) -# Create shared lib of all tests -add_library(memory SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_stress_test memory) +hip_add_exe_to_target(NAME memory + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME stress_test) diff --git a/projects/hip/tests/catch/stress/memory/hipMemcpyMThreadMSize.cc b/projects/hip/tests/catch/stress/memory/hipMemcpyMThreadMSize.cc index 791f15154e..3b0e8b7ee1 100644 --- a/projects/hip/tests/catch/stress/memory/hipMemcpyMThreadMSize.cc +++ b/projects/hip/tests/catch/stress/memory/hipMemcpyMThreadMSize.cc @@ -261,7 +261,7 @@ void Memcpy_And_verify(int NUM_ELM) { } } -TEMPLATE_TEST_CASE("Unit_hipMemcpy_multiDevice-AllAPIs", "", +TEMPLATE_TEST_CASE("Stress_hipMemcpy_multiDevice-AllAPIs", "", char, int, size_t, long double) { auto diff_size = GENERATE(1, 5, 10, 100, 1024, 10*1024, 100*1024, 1024*1024, 10*1024*1024, 100*1024*1024, diff --git a/projects/hip/tests/catch/stress/memory/memcpy.cc b/projects/hip/tests/catch/stress/memory/memcpy.cc index 59b8baa233..21957e0fdb 100644 --- a/projects/hip/tests/catch/stress/memory/memcpy.cc +++ b/projects/hip/tests/catch/stress/memory/memcpy.cc @@ -1,6 +1,6 @@ #include -TEST_CASE("hipMalloc", "DifferentSizes") { +TEST_CASE("Stress_hipMalloc", "DifferentSizes") { int* d_a = nullptr; SECTION("Size 10") { auto res = hipMalloc(&d_a, sizeof(10)); diff --git a/projects/hip/tests/catch/stress/printf/CMakeLists.txt b/projects/hip/tests/catch/stress/printf/CMakeLists.txt index 4a7a915658..1977d293f2 100644 --- a/projects/hip/tests/catch/stress/printf/CMakeLists.txt +++ b/projects/hip/tests/catch/stress/printf/CMakeLists.txt @@ -4,8 +4,6 @@ set(TEST_SRC Stress_printf_SimpleKernels.cc ) -# Create shared lib of all tests -add_library(printf SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_stress_test printf) +hip_add_exe_to_target(NAME printf + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME stress_test) diff --git a/projects/hip/tests/catch/stress/stream/CMakeLists.txt b/projects/hip/tests/catch/stress/stream/CMakeLists.txt index e2b5ea0c5d..357c3e5e36 100644 --- a/projects/hip/tests/catch/stress/stream/CMakeLists.txt +++ b/projects/hip/tests/catch/stress/stream/CMakeLists.txt @@ -3,8 +3,6 @@ set(TEST_SRC Stress_hipStreamCreate.cc ) -# Create shared lib of all tests -add_library(stream SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_stress_test stream) +hip_add_exe_to_target(NAME stream + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME stress_test) diff --git a/projects/hip/tests/catch/unit/device/CMakeLists.txt b/projects/hip/tests/catch/unit/device/CMakeLists.txt index 0f0771994b..778cd199dc 100644 --- a/projects/hip/tests/catch/unit/device/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/device/CMakeLists.txt @@ -17,9 +17,6 @@ set(TEST_SRC hipSetGetDevice.cc ) - -# Create shared lib of all tests -add_library(DeviceTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests DeviceTest) +hip_add_exe_to_target(NAME DeviceTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/projects/hip/tests/catch/unit/deviceLib/CMakeLists.txt b/projects/hip/tests/catch/unit/deviceLib/CMakeLists.txt index 191553ca99..04c125c7a9 100644 --- a/projects/hip/tests/catch/unit/deviceLib/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/deviceLib/CMakeLists.txt @@ -28,15 +28,12 @@ set(AMD_TEST_SRC if(HIP_PLATFORM MATCHES "amd") set(TEST_SRC ${TEST_SRC} ${AMD_TEST_SRC}) set_source_files_properties(floatTM.cc PROPERTIES COMPILE_FLAGS -std=c++17) + hip_add_exe_to_target(NAME UnitDeviceTests + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) +elseif(HIP_PLATFORM MATCHES "nvidia") + hip_add_exe_to_target(NAME UnitDeviceTests + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests + COMPILE_OPTIONS --Wno-deprecated-declarations) endif() - - -# Create shared lib of all tests -add_library(UnitDeviceTests SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -if(HIP_PLATFORM MATCHES "nvidia") - target_compile_options(UnitDeviceTests PUBLIC --Wno-deprecated-declarations) -endif() - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests UnitDeviceTests) diff --git a/projects/hip/tests/catch/unit/event/CMakeLists.txt b/projects/hip/tests/catch/unit/event/CMakeLists.txt index a2fdc1cdd7..fae1b4264c 100644 --- a/projects/hip/tests/catch/unit/event/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/event/CMakeLists.txt @@ -7,8 +7,6 @@ set(TEST_SRC Unit_hipEventIpc.cc ) -# Create shared lib of all tests -add_library(EventTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests EventTest) +hip_add_exe_to_target(NAME EventTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/projects/hip/tests/catch/unit/memory/CMakeLists.txt b/projects/hip/tests/catch/unit/memory/CMakeLists.txt index 2f3a2c7d87..8e984c2300 100644 --- a/projects/hip/tests/catch/unit/memory/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/memory/CMakeLists.txt @@ -100,8 +100,7 @@ set(TEST_SRC hipMemCoherencyTst.cc ) endif() -# Create shared lib of all tests -add_library(MemoryTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests MemoryTest) +hip_add_exe_to_target(NAME MemoryTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/projects/hip/tests/catch/unit/occupancy/CMakeLists.txt b/projects/hip/tests/catch/unit/occupancy/CMakeLists.txt index a349698932..9f1f1873cc 100644 --- a/projects/hip/tests/catch/unit/occupancy/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/occupancy/CMakeLists.txt @@ -4,8 +4,6 @@ set(TEST_SRC hipOccupancyMaxPotentialBlockSize.cc ) -# Create shared lib of all tests -add_library(OccupancyTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests OccupancyTest) +hip_add_exe_to_target(NAME OccupancyTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/projects/hip/tests/catch/unit/printf/CMakeLists.txt b/projects/hip/tests/catch/unit/printf/CMakeLists.txt index 251a9bbbf2..b911796d66 100644 --- a/projects/hip/tests/catch/unit/printf/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/printf/CMakeLists.txt @@ -4,13 +4,15 @@ set(TEST_SRC printfSpecifiers.cc ) -# Create shared lib of all tests -add_library(printfTests SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) -if(HIP_PLATFORM MATCHES "amd") - set_property(TARGET printfTests PROPERTY CXX_STANDARD 17) -else() - target_compile_options(printfTests PUBLIC -std=c++17) -endif() -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests printfTests) +if(HIP_PLATFORM MATCHES "amd") + hip_add_exe_to_target(NAME printfTests + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests + PROPERTY CXX_STANDARD 17) +elseif (HIP_PLATFORM MATCHES "nvidia") + hip_add_exe_to_target(NAME printfTests + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests + COMPILE_OPTIONS -std=c++17) +endif() diff --git a/projects/hip/tests/catch/unit/printf/printfFlags.cc b/projects/hip/tests/catch/unit/printf/printfFlags.cc index fb64cb7791..8a9aa75a3f 100644 --- a/projects/hip/tests/catch/unit/printf/printfFlags.cc +++ b/projects/hip/tests/catch/unit/printf/printfFlags.cc @@ -51,7 +51,7 @@ xyzzy 00000042 )here"); - hip::SpawnProc proc("unit/printfExe/printfFlags", true); + hip::SpawnProc proc("printfExe/printfFlags", 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 fa39a751f8..37e8584943 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("unit/printfExe/printfSepcifiers", true); + hip::SpawnProc proc("printfExe/printfSepcifiers", true); REQUIRE(0 == proc.run()); REQUIRE(proc.getOutput() == reference); } diff --git a/projects/hip/tests/catch/unit/printfExe/printfFlags.cc b/projects/hip/tests/catch/unit/printfExe/printfFlags.cc index 515abdfba6..a96c099340 100644 --- a/projects/hip/tests/catch/unit/printfExe/printfFlags.cc +++ b/projects/hip/tests/catch/unit/printfExe/printfFlags.cc @@ -38,5 +38,5 @@ __global__ void test_kernel() { int main() { test_kernel<<<1, 1>>>(); - hipDeviceSynchronize(); + static_cast(hipDeviceSynchronize()); } \ No newline at end of file diff --git a/projects/hip/tests/catch/unit/printfExe/printfSepcifiers.cc b/projects/hip/tests/catch/unit/printfExe/printfSepcifiers.cc index bfa33cbb0e..364376fb0a 100644 --- a/projects/hip/tests/catch/unit/printfExe/printfSepcifiers.cc +++ b/projects/hip/tests/catch/unit/printfExe/printfSepcifiers.cc @@ -60,6 +60,6 @@ __global__ void test_kernel() { int main() { test_kernel<<<1, 1>>>(); - hipDeviceSynchronize(); + static_cast(hipDeviceSynchronize()); return 0; } diff --git a/projects/hip/tests/catch/unit/rtc/CMakeLists.txt b/projects/hip/tests/catch/unit/rtc/CMakeLists.txt index 8e2423bef4..3b9a3dbe41 100644 --- a/projects/hip/tests/catch/unit/rtc/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/rtc/CMakeLists.txt @@ -3,17 +3,13 @@ set(TEST_SRC saxpy.cc ) -# AMD only tests -set(AMD_TEST_SRC - customOptions.cc -) - -if(HIP_PLATFORM MATCHES "amd") - set(TEST_SRC ${TEST_SRC} ${AMD_TEST_SRC}) +if(HIP_PLATFORM MATCHES "nvidia") + hip_add_exe_to_target(NAME RTC + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests + LINKER_LIBS nvrtc) +elseif(HIP_PLATFORM MATCHES "amd") + hip_add_exe_to_target(NAME RTC + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) endif() - -# Create shared lib of all tests -add_library(RTC SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests RTC) diff --git a/projects/hip/tests/catch/unit/stream/CMakeLists.txt b/projects/hip/tests/catch/unit/stream/CMakeLists.txt index 31157f7da6..9b4daf549b 100644 --- a/projects/hip/tests/catch/unit/stream/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/stream/CMakeLists.txt @@ -26,8 +26,6 @@ set(TEST_SRC ) endif() -# Create shared lib of all tests -add_library(StreamTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests StreamTest) \ No newline at end of file +hip_add_exe_to_target(NAME StreamTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests) diff --git a/projects/hip/tests/catch/unit/texture/CMakeLists.txt b/projects/hip/tests/catch/unit/texture/CMakeLists.txt index f91ae84fd3..2472abf163 100644 --- a/projects/hip/tests/catch/unit/texture/CMakeLists.txt +++ b/projects/hip/tests/catch/unit/texture/CMakeLists.txt @@ -26,8 +26,6 @@ set(TEST_SRC hipCreateTextureObject_Array.cc ) -# Create shared lib of all tests -add_library(TextureTest SHARED EXCLUDE_FROM_ALL ${TEST_SRC}) - -# Add dependency on build_tests to build it on this custom target -add_dependencies(build_tests TextureTest) +hip_add_exe_to_target(NAME TextureTest + TEST_SRC ${TEST_SRC} + TEST_TARGET_NAME build_tests)