SWDEV-273235 - Linux: catch2 shared lib to executable (#2421)
Change-Id: I17101e39fd05eb35c087ebdf3cb005d428d9f206
[ROCm/hip commit: 6c24531156]
Este cometimento está contido em:
cometido por
GitHub
ascendente
a4d0f06eb7
cometimento
6a5e1ea51e
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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} $<TARGET_OBJECTS:Main_Object>)
|
||||
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()
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -104,4 +104,5 @@ static inline unsigned setNumBlocks(unsigned blocksPerCU, unsigned threadsPerBlo
|
||||
|
||||
return blocks;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ THE SOFTWARE.
|
||||
#include "hip_test_common.hh"
|
||||
|
||||
#ifdef __linux__
|
||||
#include <sys/sysinfo.h>
|
||||
#include <sys/sysinfo.h>
|
||||
#endif
|
||||
|
||||
namespace HipTest {
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <hip_test_common.hh>
|
||||
|
||||
TEST_CASE("hipMalloc", "DifferentSizes") {
|
||||
TEST_CASE("Stress_hipMalloc", "DifferentSizes") {
|
||||
int* d_a = nullptr;
|
||||
SECTION("Size 10") {
|
||||
auto res = hipMalloc(&d_a, sizeof(10));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -38,5 +38,5 @@ __global__ void test_kernel() {
|
||||
|
||||
int main() {
|
||||
test_kernel<<<1, 1>>>();
|
||||
hipDeviceSynchronize();
|
||||
static_cast<void>(hipDeviceSynchronize());
|
||||
}
|
||||
@@ -60,6 +60,6 @@ __global__ void test_kernel() {
|
||||
|
||||
int main() {
|
||||
test_kernel<<<1, 1>>>();
|
||||
hipDeviceSynchronize();
|
||||
static_cast<void>(hipDeviceSynchronize());
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
hip_add_exe_to_target(NAME StreamTest
|
||||
TEST_SRC ${TEST_SRC}
|
||||
TEST_TARGET_NAME build_tests)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Criar uma nova questão referindo esta
Bloquear um utilizador