SWDEV-1 - hip tests: Moving ctest file generation to execution phase (#2522)
Earlier ctest file creation was taking place during build time. Due to cmake framework issue the file creation had issues, which in turn failed the test build. This change moves this logic to the execution phase and gets rid of the unwanted dependency during build time Change-Id: Ifbf7e325f1b15a8be12e76560a6d339bc76705ee
Этот коммит содержится в:
@@ -69,6 +69,9 @@ find_package(Catch2 REQUIRED
|
||||
include(Catch)
|
||||
include(CTest)
|
||||
|
||||
# path used for generating the *_include.cmake file
|
||||
set(CATCH2_INCLUDE ${CATCH2_PATH}/cmake/Catch2/catch_include.cmake.in)
|
||||
|
||||
include_directories(
|
||||
${CATCH2_PATH}
|
||||
"./include"
|
||||
@@ -77,6 +80,9 @@ include_directories(
|
||||
)
|
||||
|
||||
file(COPY ./hipTestMain/config DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/hipTestMain)
|
||||
file(COPY ./external/Catch2/cmake/Catch2/CatchAddTests.cmake DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/script)
|
||||
set(ADD_SCRIPT_PATH ${CMAKE_CURRENT_BINARY_DIR}/script/CatchAddTests.cmake)
|
||||
|
||||
|
||||
if(HIP_PLATFORM MATCHES "amd" AND HIP_COMPILER MATCHES "clang")
|
||||
add_compile_options(-Wall -Wextra -pedantic -Werror)
|
||||
|
||||
поставляемый
+12
-31
@@ -142,43 +142,24 @@ function(catch_discover_tests TARGET)
|
||||
# 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")
|
||||
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
|
||||
)
|
||||
add_custom_command(
|
||||
TARGET ${TARGET} POST_BUILD
|
||||
BYPRODUCTS "${ctest_tests_file}"
|
||||
COMMAND "${CMAKE_COMMAND}"
|
||||
-D "TEST_TARGET=${TARGET}"
|
||||
-D "TEST_EXECUTABLE=$<TARGET_FILE:${TARGET}>"
|
||||
-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
|
||||
)
|
||||
|
||||
file(RELATIVE_PATH ctestincludepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_include_file})
|
||||
file(RELATIVE_PATH ctestfilepath ${CMAKE_CURRENT_BINARY_DIR} ${ctest_tests_file})
|
||||
set(EXEC_NAME ${TARGET})
|
||||
if(WIN32)
|
||||
set(EXEC_NAME ${EXEC_NAME}.exe)
|
||||
endif()
|
||||
|
||||
file(WRITE "${ctest_include_file}"
|
||||
"if(EXISTS \"${ctestfilepath}\")\n"
|
||||
" include(\"${ctestfilepath}\")\n"
|
||||
"else()\n"
|
||||
" message(WARNING \"Test ${TARGET} not built yet.\")\n"
|
||||
"endif()\n"
|
||||
)
|
||||
# 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
|
||||
|
||||
@@ -29,6 +29,8 @@ function(add_command NAME)
|
||||
set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
get_filename_component(TEST_EXECUTABLE ${TEST_EXECUTABLE} ABSOLUTE)
|
||||
|
||||
# Run test executable to get list of available tests
|
||||
if(NOT EXISTS "${TEST_EXECUTABLE}")
|
||||
message(FATAL_ERROR
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
# 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()
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
add_custom_target(stress_test COMMAND "${CMAKE_CTEST_COMMAND}" -R "Stress_")
|
||||
add_custom_target(stress_test COMMAND "${CMAKE_CTEST_COMMAND}" -R "Stress_"
|
||||
COMMENT "Build complete, now executing the stress test ...")
|
||||
|
||||
add_subdirectory(memory)
|
||||
if(HIP_PLATFORM MATCHES "amd")
|
||||
|
||||
@@ -18,7 +18,12 @@
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
# THE SOFTWARE.
|
||||
|
||||
add_subdirectory(memory)
|
||||
# Currently build fails for these two test sets
|
||||
if (UNIX)
|
||||
add_subdirectory(memory)
|
||||
add_subdirectory(graph)
|
||||
endif()
|
||||
|
||||
add_subdirectory(deviceLib)
|
||||
add_subdirectory(stream)
|
||||
add_subdirectory(event)
|
||||
@@ -29,4 +34,3 @@ add_subdirectory(printf)
|
||||
add_subdirectory(printfExe)
|
||||
add_subdirectory(texture)
|
||||
add_subdirectory(streamperthread)
|
||||
add_subdirectory(graph)
|
||||
|
||||
Ссылка в новой задаче
Block a user