-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support installing tests + parallel test infra
- Loading branch information
1 parent
e4c64e5
commit aa41d6e
Showing
10 changed files
with
354 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
#============================================================================= | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
rapids_test_record_install | ||
-------------------------- | ||
.. versionadded:: v23.02.00 | ||
Record that the provided target should have install rules specified when | ||
:cmake:command:`rapids_test_install_relocatable` is called with the given component. | ||
.. code-block:: cmake | ||
rapids_test_record_install(TARGET <name> COMPONENT <set>) | ||
#]=======================================================================] | ||
function(rapids_test_record_install) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.record_install") | ||
|
||
set(options) | ||
set(one_value TARGET COMPONENT) | ||
set(multi_value ) | ||
cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) | ||
|
||
set(component ${_RAPIDS_TEST_COMPONENT}) | ||
set_property(TARGET rapids_test_install_${component} APPEND PROPERTY "TARGETS_TO_INSTALL" "${_RAPIDS_TEST_TARGET}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#============================================================================= | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
rapids_test_record_test_command | ||
------------------------------- | ||
.. versionadded:: v23.02.00 | ||
Record the test command that needs to run when executed via ctest after installation | ||
.. code-block:: cmake | ||
rapids_test_record_test_command(NAME <name> COMMAND command <args>...) | ||
#]=======================================================================] | ||
function(rapids_test_record_test_command) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.record_test_command") | ||
|
||
set(options) | ||
set(one_value NAME) | ||
set(multi_value COMMAND) | ||
cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) | ||
|
||
set_property(TEST ${_RAPIDS_TEST_NAME} PROPERTY INSTALL_COMMAND "${_RAPIDS_TEST_COMMAND}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#============================================================================= | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
rapids_test_record_test_component | ||
--------------------------------- | ||
.. versionadded:: v23.02.00 | ||
Record what component a test is part of | ||
.. code-block:: cmake | ||
rapids_test_record_test_component(NAME <name> COMPONENT <set>) | ||
#]=======================================================================] | ||
function(rapids_test_record_test_component) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.record_test_component") | ||
|
||
set(options) | ||
set(one_value NAME COMPONENT) | ||
set(multi_value ) | ||
cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) | ||
|
||
set(component ${_RAPIDS_TEST_COMPONENT}) | ||
set_property(TARGET rapids_test_install_${component} APPEND PROPERTY "TESTS_TO_RUN" "${_RAPIDS_TEST_NAME}") | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
#============================================================================= | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include_guard(GLOBAL) | ||
|
||
#[=======================================================================[.rst: | ||
rapids_test_install_relocatable | ||
------------------------------- | ||
.. versionadded:: v23.02.00 | ||
Install the needed `ctest` infrastructure to allow installed tests to be run | ||
by `ctest` in parallel with GPU awarness. | ||
.. code-block:: cmake | ||
rapids_test_install_relocatable(INSTALL_COMPONENT_SET <component> | ||
DESTINATION <relative_path> | ||
[EXCLUDE_FROM_ALL]) | ||
Add ... | ||
``INSTALL_COMPONENT_SET`` | ||
Record which test component infrastructure to be installed | ||
``DESTINATION`` | ||
Relative path from the `CMAKE_INSTALL_PREFIX` to install the infrastructure. | ||
This needs to be the same directory as the test exectuables | ||
``EXCLUDE_FROM_ALL`` | ||
State that these install rules shouldn't be part of the default install set, and | ||
instead must be explicitly installed. | ||
#]=======================================================================] | ||
function(rapids_test_install_relocatable) | ||
list(APPEND CMAKE_MESSAGE_CONTEXT "rapids.test.install_relocatable") | ||
|
||
set(options EXCLUDE_FROM_ALL) | ||
set(one_value INSTALL_COMPONENT_SET DESTINATION) | ||
set(multi_value) | ||
cmake_parse_arguments(_RAPIDS_TEST "${options}" "${one_value}" "${multi_value}" ${ARGN}) | ||
|
||
set(to_exclude ) | ||
if(_RAPIDS_TEST_EXCLUDE_FROM_ALL) | ||
set(to_exclude EXCLUDE_FROM_ALL) | ||
endif() | ||
|
||
set(component ${_RAPIDS_TEST_INSTALL_COMPONENT_SET}) | ||
if(NOT TARGET rapids_test_install_${component}) | ||
message(FATAL_ERROR "No install component set [${component}] can be found") | ||
endif() | ||
|
||
get_target_property(targets_to_install rapids_test_install_${component} TARGETS_TO_INSTALL) | ||
get_target_property(tests_to_run rapids_test_install_${component} TESTS_TO_RUN) | ||
|
||
# Write out the relocatable CTestFile that we can install! | ||
# Presumes a 1 to 1 mapping of test name to executable | ||
set(content [==[ | ||
set(CTEST_SCRIPT_DIRECTORY ".") | ||
set(CTEST_RESOURCE_SPEC_FILE "./resource_spec.json") | ||
execute_process(COMMAND ./generate_ctest_json OUTPUT_FILE "${CTEST_RESOURCE_SPEC_FILE}") | ||
]==]) | ||
|
||
foreach(test IN LISTS tests_to_run) | ||
get_test_property(${test} INSTALL_COMMAND command) | ||
get_test_property(${test} RESOURCE_GROUPS resources) | ||
string(APPEND content "add_test([=[${test}]=] ${command})\n") | ||
string(APPEND content "set_tests_properties([=[${test}]=] PROPERTIES RESOURCE_GROUPS ${resources})\n") | ||
endforeach() | ||
|
||
set(test_launcher_file "${CMAKE_CURRENT_BINARY_DIR}/rapids-cmake/${_RAPIDS_TEST_INSTALL_COMPONENT_SET}/CTestTestfile.cmake.to_install") | ||
file(WRITE "${test_launcher_file}" "${content}") | ||
install( | ||
FILES "${test_launcher_file}" | ||
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} | ||
DESTINATION ${_RAPIDS_TEST_DESTINATION} | ||
RENAME "CTestTestfile.cmake" | ||
${to_exclude}) | ||
|
||
# We need to install the rapids-test gpu detector, and the json script | ||
# we also need to write out / install the new CTestTestfile.cmake | ||
install( | ||
PROGRAMS "${PROJECT_BINARY_DIR}/rapids-cmake/generate_ctest_json" | ||
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} | ||
DESTINATION ${_RAPIDS_TEST_DESTINATION} | ||
${to_exclude}) | ||
install( | ||
FILES "${CMAKE_CURRENT_FUNCTION_LIST_DIR}/detail/run_gpu_test.cmake" | ||
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} | ||
DESTINATION ${_RAPIDS_TEST_DESTINATION} | ||
${to_exclude}) | ||
install( | ||
TARGETS ${targets_to_install} | ||
COMPONENT ${_RAPIDS_TEST_INSTALL_COMPONENT_SET} | ||
DESTINATION ${_RAPIDS_TEST_DESTINATION} | ||
${to_exclude}) | ||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#============================================================================= | ||
# Copyright (c) 2022, NVIDIA CORPORATION. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
#============================================================================= | ||
include(${rapids-cmake-dir}/test/init.cmake) | ||
include(${rapids-cmake-dir}/test/add.cmake) | ||
|
||
enable_language(CUDA) | ||
|
||
rapids_test_init() | ||
|
||
file(WRITE "${CMAKE_BINARY_DIR}/main.cu" "int main(){return 0;}") | ||
add_executable(verify_alloc "${CMAKE_BINARY_DIR}/main.cu") | ||
|
||
enable_testing() | ||
rapids_test_add(NAME simple_test COMMAND verify_alloc GPUS 1 INSTALL_COMPONENT_SET testing) | ||
|
||
# Verify that we have recorded `simple_test` as part of the `testing` component | ||
get_target_property(names rapids_test_install_testing TESTS_TO_RUN) | ||
if(NOT "simple_test" IN_LIST names) | ||
message(FATAL_ERROR "Failed to record `simple_test` as part of the testing component") | ||
endif() | ||
|
||
# Verify that `verify_alloc` is marked as to be installed | ||
get_target_property(names rapids_test_install_testing TARGETS_TO_INSTALL) | ||
if(NOT "verify_alloc" IN_LIST names) | ||
message(FATAL_ERROR "Failed to record `verify_alloc` as a target to be installed in the testing component") | ||
endif() | ||
|
||
# Verify we recorded some install command for `simple_test` | ||
get_test_property(simple_test INSTALL_COMMAND install_command) | ||
if(NOT install_command) | ||
message(FATAL_ERROR "Failed to record the command to run `simple_test` after installing it") | ||
endif() | ||
|
Oops, something went wrong.