directed tests no longer run in an subdirectory

- target "make test" will no longer build and run tests. It will only run the tests.
- added new target "make check" which will build and run the tests.
- target "make check" will build tests serially. Use -j<N> to build tests in parallel.

Change-Id: I24c7932bf9798364a59f44631fbabcf9a5da5e17


[ROCm/clr commit: fe01dd74a2]
Этот коммит содержится в:
Maneesh Gupta
2017-02-27 13:14:08 +05:30
родитель f109c9e6da
Коммит 045c76a97d
2 изменённых файлов: 31 добавлений и 22 удалений
+16 -17
Просмотреть файл
@@ -367,22 +367,21 @@ endif()
# Testing steps
#############################
# Target: test
set(BUILD_DIR ${CMAKE_CURRENT_BINARY_DIR}/hip_tests)
configure_file(tests/hip_tests.txt ${BUILD_DIR}/CMakeLists.txt @ONLY)
if(POLICY CMP0037)
cmake_policy(PUSH)
cmake_policy(SET CMP0037 OLD)
endif()
add_custom_target(install_for_test COMMAND "${CMAKE_COMMAND}" --build . --target install
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
execute_process(COMMAND getconf _NPROCESSORS_ONLN OUTPUT_VARIABLE DASH_JAY OUTPUT_STRIP_TRAILING_WHITESPACE)
add_custom_target(test COMMAND ${CMAKE_COMMAND} -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} .
COMMAND make -j ${DASH_JAY}
COMMAND make test
WORKING_DIRECTORY ${BUILD_DIR}
DEPENDS install_for_test)
if(POLICY CMP0037)
cmake_policy(POP)
endif()
set(HIP_PATH ${CMAKE_INSTALL_PREFIX})
set(HIP_SRC_PATH ${CMAKE_CURRENT_SOURCE_DIR})
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/cmake" "${HIP_PATH}/cmake")
execute_process(COMMAND "${CMAKE_COMMAND}" -E copy_directory "${HIP_SRC_PATH}/bin" "${HIP_PATH}/bin")
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
include(${HIP_SRC_PATH}/tests/hit/HIT.cmake)
# Add tests
include_directories(${HIP_SRC_PATH}/tests/src)
hit_add_directory_recursive(${HIP_SRC_PATH}/tests/src "directed_tests")
# Add top-level tests to build_tests
add_custom_target(build_tests DEPENDS directed_tests)
# Add custom target: check
add_custom_target(check COMMAND "${CMAKE_COMMAND}" --build . --target test DEPENDS build_tests)
# vim: ts=4:sw=4:expandtab:smartindent
+15 -5
Просмотреть файл
@@ -131,7 +131,7 @@ endmacro()
# Macro: HIT_ADD_FILES used to scan+add multiple files for testing.
file(GLOB HIP_LIB_FILES ${HIP_PATH}/lib/*)
macro(HIT_ADD_FILES _dir _label)
macro(HIT_ADD_FILES _dir _label _parent)
foreach (file ${ARGN})
# Build tests
execute_process(COMMAND ${HIP_SRC_PATH}/tests/hit/parser --buildCMDs ${file}
@@ -148,8 +148,10 @@ macro(HIT_ADD_FILES _dir _label)
if(_exclude_platforms STREQUAL "all" OR _exclude_platforms STREQUAL ${HIP_PLATFORM})
else()
set_source_files_properties(${_sources} PROPERTIES HIP_SOURCE_PROPERTY_FORMAT 1)
hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options})
hip_reset_flags()
hip_add_executable(${target} ${_sources} HIPCC_OPTIONS ${_hipcc_options} HCC_OPTIONS ${_hcc_options} NVCC_OPTIONS ${_nvcc_options} EXCLUDE_FROM_ALL)
set_target_properties(${target} PROPERTIES OUTPUT_NAME ${_target} RUNTIME_OUTPUT_DIRECTORY ${_label} LINK_DEPENDS "${HIP_LIB_FILES}")
add_dependencies(${_parent} ${target})
endif()
endforeach()
@@ -196,24 +198,32 @@ endmacro()
# Macro: HIT_ADD_DIRECTORY to scan+add all files in a directory for testing
macro(HIT_ADD_DIRECTORY _dir _label)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
string(REGEX REPLACE "/" "." _parent ${_label})
add_custom_target(${_parent})
file(GLOB files "${_dir}/*.c*")
hit_add_files(${_dir} ${_label} ${files})
hit_add_files(${_dir} ${_label} ${parent} ${files})
endmacro()
# Macro: HIT_ADD_DIRECTORY_RECURSIVE to scan+add all files in a directory+subdirectories for testing
macro(HIT_ADD_DIRECTORY_RECURSIVE _dir _label)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory ${_label} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
string(REGEX REPLACE "/" "." _parent ${_label})
add_custom_target(${_parent})
if(${ARGC} EQUAL 3)
add_dependencies(${ARGV2} ${_parent})
endif()
file(GLOB children RELATIVE ${_dir} ${_dir}/*)
set(dirlist "")
foreach(child ${children})
if(IS_DIRECTORY ${_dir}/${child})
list(APPEND dirlist ${child})
else()
hit_add_files(${_dir} ${_label} ${child})
hit_add_files(${_dir} ${_label} ${_parent} ${child})
endif()
endforeach()
foreach(child ${dirlist})
hit_add_directory_recursive(${_dir}/${child} ${_label}/${child})
string(REGEX REPLACE "/" "." _parent ${_label})
hit_add_directory_recursive(${_dir}/${child} ${_label}/${child} ${_parent})
endforeach()
endmacro()