From 2a080641a16310acbf07e91ed04b9c746da0f405 Mon Sep 17 00:00:00 2001 From: Kian Cossettini Date: Mon, 3 Nov 2025 11:03:35 -0500 Subject: [PATCH] [rocprofiler-systems] Consolidate CTests to tests/ folder (#1461) * Consolidate CTests to tests/ folder * Remove comment * Consolidate CTests to tests/ folder * Remove comment * Separate source code and test code for thread-limit into appropriate folders * Remove sleeper.cpp and instead use linux sleep cmd * Merge python-console tests into python-tests --- .../examples/CMakeLists.txt | 1 + .../examples/thread-limit/CMakeLists.txt | 42 +++ .../thread-limit}/thread-limit.cpp | 0 .../source/bin/CMakeLists.txt | 5 - .../source/bin/tests/sleeper.cpp | 28 -- .../source/python/CMakeLists.txt | 8 - .../rocprofiler-systems/tests/CMakeLists.txt | 4 +- .../rocprof-sys-binary-tests.cmake} | 341 ++++++------------ .../tests/rocprof-sys-python-tests.cmake | 7 + .../tests/rocprof-sys-testing.cmake | 120 ++++++ ...t => rocprof-sys-thread-limit-tests.cmake} | 17 +- 11 files changed, 295 insertions(+), 278 deletions(-) create mode 100644 projects/rocprofiler-systems/examples/thread-limit/CMakeLists.txt rename projects/rocprofiler-systems/{tests/source => examples/thread-limit}/thread-limit.cpp (100%) delete mode 100644 projects/rocprofiler-systems/source/bin/tests/sleeper.cpp rename projects/rocprofiler-systems/{source/bin/tests/CMakeLists.txt => tests/rocprof-sys-binary-tests.cmake} (62%) rename projects/rocprofiler-systems/tests/{source/CMakeLists.txt => rocprof-sys-thread-limit-tests.cmake} (88%) diff --git a/projects/rocprofiler-systems/examples/CMakeLists.txt b/projects/rocprofiler-systems/examples/CMakeLists.txt index ef13a4e223..e3dcefeaa9 100644 --- a/projects/rocprofiler-systems/examples/CMakeLists.txt +++ b/projects/rocprofiler-systems/examples/CMakeLists.txt @@ -78,3 +78,4 @@ add_subdirectory(fork) add_subdirectory(videodecode) add_subdirectory(jpegdecode) add_subdirectory(roctx) +add_subdirectory(thread-limit) diff --git a/projects/rocprofiler-systems/examples/thread-limit/CMakeLists.txt b/projects/rocprofiler-systems/examples/thread-limit/CMakeLists.txt new file mode 100644 index 0000000000..5a486228d8 --- /dev/null +++ b/projects/rocprofiler-systems/examples/thread-limit/CMakeLists.txt @@ -0,0 +1,42 @@ +# MIT License +# +# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +if(ROCPROFSYS_DISABLE_EXAMPLES) + get_filename_component(_DIR ${CMAKE_CURRENT_LIST_DIR} NAME) + + if( + ${PROJECT_NAME} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES + OR ${_DIR} IN_LIST ROCPROFSYS_DISABLE_EXAMPLES + ) + return() + endif() +endif() + +set(CMAKE_BUILD_TYPE "Release") +find_package(Threads REQUIRED) + +add_library(tests-compile-options INTERFACE) +target_compile_options(tests-compile-options INTERFACE -g) + +add_executable(thread-limit thread-limit.cpp) +target_compile_definitions(thread-limit PRIVATE MAX_THREADS=${ROCPROFSYS_MAX_THREADS}) +target_link_libraries(thread-limit PRIVATE Threads::Threads tests-compile-options) diff --git a/projects/rocprofiler-systems/tests/source/thread-limit.cpp b/projects/rocprofiler-systems/examples/thread-limit/thread-limit.cpp similarity index 100% rename from projects/rocprofiler-systems/tests/source/thread-limit.cpp rename to projects/rocprofiler-systems/examples/thread-limit/thread-limit.cpp diff --git a/projects/rocprofiler-systems/source/bin/CMakeLists.txt b/projects/rocprofiler-systems/source/bin/CMakeLists.txt index a17d9fbbc2..573a899e45 100644 --- a/projects/rocprofiler-systems/source/bin/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/bin/CMakeLists.txt @@ -10,8 +10,3 @@ add_subdirectory(rocprof-sys-causal) add_subdirectory(rocprof-sys-sample) add_subdirectory(rocprof-sys-instrument) add_subdirectory(rocprof-sys-run) - -# tests -if(ROCPROFSYS_BUILD_TESTING OR "$ENV{ROCPROFSYS_CI}" MATCHES "[1-9]+|ON|on|y|yes") - add_subdirectory(tests) -endif() diff --git a/projects/rocprofiler-systems/source/bin/tests/sleeper.cpp b/projects/rocprofiler-systems/source/bin/tests/sleeper.cpp deleted file mode 100644 index 74fe0b094f..0000000000 --- a/projects/rocprofiler-systems/source/bin/tests/sleeper.cpp +++ /dev/null @@ -1,28 +0,0 @@ - -#include -#include -#include -#include - -using clock_type = std::chrono::steady_clock; - -int -main(int argc, char** argv) -{ - double _val = 0.0; - if(argc > 0) - { - auto _ss = std::stringstream{}; - _ss << argv[1]; - _ss >> _val; - } - - intmax_t _nsec = _val * std::nano::den; - auto _end = clock_type::now() + std::chrono::nanoseconds{ _nsec }; - while(clock_type::now() < _end) - { - std::this_thread::sleep_for(std::chrono::nanoseconds{ _nsec / 10 }); - } - - return 0; -} diff --git a/projects/rocprofiler-systems/source/python/CMakeLists.txt b/projects/rocprofiler-systems/source/python/CMakeLists.txt index 43a7128ba3..f01b836dc2 100644 --- a/projects/rocprofiler-systems/source/python/CMakeLists.txt +++ b/projects/rocprofiler-systems/source/python/CMakeLists.txt @@ -129,14 +129,6 @@ foreach(_VERSION ${ROCPROFSYS_PYTHON_VERSIONS}) rocprofiler_systems_configure_pytarget(libpyrocprofiler-systems-${_VERSION} ${_VERSION} ) - - if(ROCPROFSYS_USE_PYTHON) - rocprofiler_systems_python_console_script( - "${BINARY_NAME_PREFIX}-python" "rocprofsys" - VERSION ${_VERSION} - ROOT_DIR "${Python3_ROOT_DIR}" - ) - endif() math(EXPR _INDEX "${_INDEX} + 1") endforeach() diff --git a/projects/rocprofiler-systems/tests/CMakeLists.txt b/projects/rocprofiler-systems/tests/CMakeLists.txt index b2e46cee4c..928269a806 100644 --- a/projects/rocprofiler-systems/tests/CMakeLists.txt +++ b/projects/rocprofiler-systems/tests/CMakeLists.txt @@ -49,5 +49,5 @@ include(${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-decode-tests.cmake) include(${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-nic-perf.cmake) include(${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-roctx-tests.cmake) include(${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-rocm-hip-stream.cmake) - -add_subdirectory(source) +include(${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-binary-tests.cmake) +include(${CMAKE_CURRENT_LIST_DIR}/rocprof-sys-thread-limit-tests.cmake) diff --git a/projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt b/projects/rocprofiler-systems/tests/rocprof-sys-binary-tests.cmake similarity index 62% rename from projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt rename to projects/rocprofiler-systems/tests/rocprof-sys-binary-tests.cmake index e47850da30..4528e04063 100644 --- a/projects/rocprofiler-systems/source/bin/tests/CMakeLists.txt +++ b/projects/rocprofiler-systems/tests/rocprof-sys-binary-tests.cmake @@ -1,5 +1,6 @@ -################################################################################ -# Copyright (c) 2025 Advanced Micro Devices, Inc. +# MIT License +# +# Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -8,133 +9,22 @@ # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # -# The above copyright notice and this permission notice shall be included in all -# copies or substantial portions of the Software. +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -# SOFTWARE. +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. + +# -------------------------------------------------------------------------------------- # # -################################################################################ - -set(ROCPROFSYS_ABORT_FAIL_REGEX - "### ERROR ###|unknown-hash=|address of faulting memory reference|exiting with non-zero exit code|terminate called after throwing an instance|calling abort.. in |Exit code: [1-9]" - CACHE INTERNAL - "Regex to catch abnormal exits when a PASS_REGULAR_EXPRESSION is set" - FORCE -) - -# adds a ctest for executable -function(ROCPROFILER_SYSTEMS_ADD_BIN_TEST) - cmake_parse_arguments( - TEST - "" # options - "NAME;TARGET;TIMEOUT;WORKING_DIRECTORY" # single value args - "ARGS;ENVIRONMENT;LABELS;PROPERTIES;PASS_REGEX;FAIL_REGEX;SKIP_REGEX;DEPENDS;COMMAND" # multiple - # value args - ${ARGN} - ) - - if(NOT TEST_WORKING_DIRECTORY) - set(TEST_WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) - endif() - - if(NOT TEST_ENVIRONMENT) - set(TEST_ENVIRONMENT - "ROCPROFSYS_TRACE=ON" - "ROCPROFSYS_PROFILE=ON" - "ROCPROFSYS_USE_SAMPLING=ON" - "ROCPROFSYS_TIME_OUTPUT=OFF" - "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}:$ENV{LD_LIBRARY_PATH}" - ) - endif() - - # common - list( - APPEND - TEST_ENVIRONMENT - "ROCPROFSYS_CI=ON" - "ROCPROFSYS_CI_TIMEOUT=${TEST_TIMEOUT}" - "ROCPROFSYS_CONFIG_FILE=" - "ROCPROFSYS_OUTPUT_PATH=${PROJECT_BINARY_DIR}/rocprof-sys-tests-output" - "TWD=${TEST_WORKING_DIRECTORY}" - ) - # copy for inverse - set(TEST_ENVIRONMENT_INV "${TEST_ENVIRONMENT}") - - # different for regular test and inverse test - list(APPEND TEST_ENVIRONMENT "ROCPROFSYS_OUTPUT_PREFIX=${TEST_NAME}/") - list(APPEND TEST_ENVIRONMENT_INV "ROCPROFSYS_OUTPUT_PREFIX=${TEST_NAME}-inverse/") - - if( - NOT "${TEST_PASS_REGEX}" STREQUAL "" - AND NOT "${TEST_FAIL_REGEX}" STREQUAL "" - AND NOT "${TEST_FAIL_REGEX}" MATCHES "\\|ROCPROFSYS_ABORT_FAIL_REGEX" - ) - rocprofiler_systems_message( - FATAL_ERROR - "${TEST_NAME} has set pass and fail regexes but fail regex does not include '|ROCPROFSYS_ABORT_FAIL_REGEX'" - ) - endif() - - if("${TEST_FAIL_REGEX}" STREQUAL "") - set(TEST_FAIL_REGEX "(${ROCPROFSYS_ABORT_FAIL_REGEX})") - else() - string( - REPLACE - "|ROCPROFSYS_ABORT_FAIL_REGEX" - "|${ROCPROFSYS_ABORT_FAIL_REGEX}" - TEST_FAIL_REGEX - "${TEST_FAIL_REGEX}" - ) - endif() - - if(TEST_COMMAND) - add_test( - NAME ${TEST_NAME} - COMMAND ${TEST_COMMAND} ${TEST_ARGS} - WORKING_DIRECTORY ${TEST_WORKING_DIRECTORY} - ) - - set_tests_properties( - ${TEST_NAME} - PROPERTIES - ENVIRONMENT "${TEST_ENVIRONMENT}" - TIMEOUT ${TEST_TIMEOUT} - DEPENDS "${TEST_DEPENDS}" - LABELS "rocprofiler-systems-bin;${TEST_LABELS}" - PASS_REGULAR_EXPRESSION "${TEST_PASS_REGEX}" - FAIL_REGULAR_EXPRESSION "${TEST_FAIL_REGEX}" - SKIP_REGULAR_EXPRESSION "${TEST_SKIP_REGEX}" - ${TEST_PROPERTIES} - ) - elseif(TARGET ${TEST_TARGET}) - add_test( - NAME ${TEST_NAME} - COMMAND $ ${TEST_ARGS} - WORKING_DIRECTORY ${TEST_WORKING_DIRECTORY} - ) - - set_tests_properties( - ${TEST_NAME} - PROPERTIES - ENVIRONMENT "${TEST_ENVIRONMENT}" - TIMEOUT ${TEST_TIMEOUT} - DEPENDS "${TEST_DEPENDS}" - LABELS "rocprofiler-systems-bin;${TEST_LABELS}" - PASS_REGULAR_EXPRESSION "${TEST_PASS_REGEX}" - FAIL_REGULAR_EXPRESSION "${TEST_FAIL_REGEX}" - SKIP_REGULAR_EXPRESSION "${TEST_SKIP_REGEX}" - ${TEST_PROPERTIES} - ) - elseif(ROCPROFSYS_BUILD_TESTING) - message(FATAL_ERROR "Error! ${TEST_TARGET} does not exist") - endif() -endfunction() +# Contains tests for executables +# +# -------------------------------------------------------------------------------------- # rocprofiler_systems_add_bin_test( NAME rocprofiler-systems-instrument-help @@ -441,107 +331,104 @@ file( " ) -add_executable(sleeper ${CMAKE_CURRENT_SOURCE_DIR}/sleeper.cpp) -set_target_properties( - sleeper - PROPERTIES - BUILD_TYPE RelWithDebInfo - RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin/testing -) - -rocprofiler_systems_add_bin_test( - NAME rocprofiler-systems-run-args - TARGET rocprofiler-systems-run - ARGS --monochrome - --debug=false - -v - 1 - -c - %env{TWD}%/rocprof-sys-tests-config/empty.cfg - -o - rocprof-sys-tests-output - rocprofiler-systems-run-args-output/ - -TPHD - -S - cputime - realtime - --trace-wait=1.0e-12 - --trace-duration=5.0 - --wait=1.0 - --duration=3.0 - --trace-file=perfetto-run-args-trace.proto - --trace-buffer-size=100 - --trace-fill-policy=ring_buffer - --profile-format - console - json - text - --process-freq - 1000 - --process-wait - 0.0 - --process-duration - 10 - --cpus - 0-4 - --gpus - 0 - -f - 1000 - --sampling-wait - 1.0 - --sampling-duration - 10 - -t - 0-3 - --sample-cputime - 1000 - 1.0 - 0-3 - --sample-realtime - 10 - 0.5 - 0-3 - -I - all - -E - mutex-locks - rw-locks - spin-locks - -C - perf::INSTRUCTIONS - --inlines - --hsa-interrupt - 0 - --use-causal=false - --use-kokkosp - --num-threads-hint=4 - --sampling-allocator-size=32 - --ci - --dl-verbose=3 - --perfetto-annotations=off - --kokkosp-kernel-logger - --kokkosp-name-length-max=1024 - --kokkosp-prefix="[kokkos]" - --tmpdir - ${CMAKE_BINARY_DIR}/rocprof-sys-tests-config/tmpdir - --perfetto-backend - inprocess - --use-pid - false - --time-output - off - --thread-pool-size - 0 - --timemory-components - wall_clock - cpu_clock - peak_rss - page_rss - --fork - -- - $ - 5 - TIMEOUT 45 - LABELS "rocprofiler-systems-run" -) +find_program(SLEEP_CMD NAMES sleep) +if(SLEEP_CMD) + rocprofiler_systems_add_bin_test( + NAME rocprofiler-systems-run-args + TARGET rocprofiler-systems-run + ARGS --monochrome + --debug=false + -v + 1 + -c + %env{TWD}%/rocprof-sys-tests-config/empty.cfg + -o + rocprof-sys-tests-output + rocprofiler-systems-run-args-output/ + -TPHD + -S + cputime + realtime + --trace-wait=1.0e-12 + --trace-duration=5.0 + --wait=1.0 + --duration=3.0 + --trace-file=perfetto-run-args-trace.proto + --trace-buffer-size=100 + --trace-fill-policy=ring_buffer + --profile-format + console + json + text + --process-freq + 1000 + --process-wait + 0.0 + --process-duration + 10 + --cpus + 0-4 + --gpus + 0 + -f + 1000 + --sampling-wait + 1.0 + --sampling-duration + 10 + -t + 0-3 + --sample-cputime + 1000 + 1.0 + 0-3 + --sample-realtime + 10 + 0.5 + 0-3 + -I + all + -E + mutex-locks + rw-locks + spin-locks + -C + perf::INSTRUCTIONS + --inlines + --hsa-interrupt + 0 + --use-causal=false + --use-kokkosp + --num-threads-hint=4 + --sampling-allocator-size=32 + --ci + --dl-verbose=3 + --perfetto-annotations=off + --kokkosp-kernel-logger + --kokkosp-name-length-max=1024 + --kokkosp-prefix="[kokkos]" + --tmpdir + ${CMAKE_BINARY_DIR}/rocprof-sys-tests-config/tmpdir + --perfetto-backend + inprocess + --use-pid + false + --time-output + off + --thread-pool-size + 0 + --timemory-components + wall_clock + cpu_clock + peak_rss + page_rss + --fork + -- + ${SLEEP_CMD} + 5 + TIMEOUT 45 + LABELS "rocprofiler-systems-run" + ) +else() + rocprofiler_systems_message(WARNING "Sleep command not found. Disabling rocprofiler-systems-run-args ctest...") +endif() diff --git a/projects/rocprofiler-systems/tests/rocprof-sys-python-tests.cmake b/projects/rocprofiler-systems/tests/rocprof-sys-python-tests.cmake index ed0426dc01..88448afd94 100644 --- a/projects/rocprofiler-systems/tests/rocprof-sys-python-tests.cmake +++ b/projects/rocprofiler-systems/tests/rocprof-sys-python-tests.cmake @@ -319,5 +319,12 @@ foreach(_VERSION ${ROCPROFSYS_PYTHON_VERSIONS}) "${CMAKE_CURRENT_LIST_DIR}/rocpd-validation-rules/python/python-builtin-rules.json" ) + list(GET ROCPROFSYS_PYTHON_ROOT_DIRS ${_INDEX} Python3_ROOT_DIR) + rocprofiler_systems_python_console_script( + "${BINARY_NAME_PREFIX}-python" "rocprofsys" + VERSION ${_VERSION} + ROOT_DIR "${Python3_ROOT_DIR}" + ) + math(EXPR _INDEX "${_INDEX} + 1") endforeach() diff --git a/projects/rocprofiler-systems/tests/rocprof-sys-testing.cmake b/projects/rocprofiler-systems/tests/rocprof-sys-testing.cmake index d4c94bbae6..abc9c5165d 100644 --- a/projects/rocprofiler-systems/tests/rocprof-sys-testing.cmake +++ b/projects/rocprofiler-systems/tests/rocprof-sys-testing.cmake @@ -25,6 +25,13 @@ # include_guard(DIRECTORY) +set(ROCPROFSYS_ABORT_FAIL_REGEX + "### ERROR ###|unknown-hash=|address of faulting memory reference|exiting with non-zero exit code|terminate called after throwing an instance|calling abort.. in |Exit code: [1-9]" + CACHE INTERNAL + "Regex to catch abnormal exits when a PASS_REGULAR_EXPRESSION is set" + FORCE +) + if(EXISTS /etc/os-release AND NOT IS_DIRECTORY /etc/os-release) file(READ /etc/os-release _OS_RELEASE_RAW) @@ -1319,3 +1326,116 @@ function(ROCPROFILER_SYSTEMS_ADD_VALIDATION_TEST) ) endforeach() endfunction() + +# -------------------------------------------------------------------------------------- # +# +# Adds a ctest for executables +# +# -------------------------------------------------------------------------------------- # + +function(ROCPROFILER_SYSTEMS_ADD_BIN_TEST) + cmake_parse_arguments( + TEST + "" # options + "NAME;TARGET;TIMEOUT;WORKING_DIRECTORY" # single value args + "ARGS;ENVIRONMENT;LABELS;PROPERTIES;PASS_REGEX;FAIL_REGEX;SKIP_REGEX;DEPENDS;COMMAND" # multiple + # value args + ${ARGN} + ) + + if(NOT TEST_WORKING_DIRECTORY) + set(TEST_WORKING_DIRECTORY ${PROJECT_BINARY_DIR}) + endif() + + if(NOT TEST_ENVIRONMENT) + set(TEST_ENVIRONMENT + "ROCPROFSYS_TRACE=ON" + "ROCPROFSYS_PROFILE=ON" + "ROCPROFSYS_USE_SAMPLING=ON" + "ROCPROFSYS_TIME_OUTPUT=OFF" + "LD_LIBRARY_PATH=${PROJECT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}:$ENV{LD_LIBRARY_PATH}" + ) + endif() + + # common + list( + APPEND + TEST_ENVIRONMENT + "ROCPROFSYS_CI=ON" + "ROCPROFSYS_CI_TIMEOUT=${TEST_TIMEOUT}" + "ROCPROFSYS_CONFIG_FILE=" + "ROCPROFSYS_OUTPUT_PATH=${PROJECT_BINARY_DIR}/rocprof-sys-tests-output" + "TWD=${TEST_WORKING_DIRECTORY}" + ) + # copy for inverse + set(TEST_ENVIRONMENT_INV "${TEST_ENVIRONMENT}") + + # different for regular test and inverse test + list(APPEND TEST_ENVIRONMENT "ROCPROFSYS_OUTPUT_PREFIX=${TEST_NAME}/") + list(APPEND TEST_ENVIRONMENT_INV "ROCPROFSYS_OUTPUT_PREFIX=${TEST_NAME}-inverse/") + + if( + NOT "${TEST_PASS_REGEX}" STREQUAL "" + AND NOT "${TEST_FAIL_REGEX}" STREQUAL "" + AND NOT "${TEST_FAIL_REGEX}" MATCHES "\\|ROCPROFSYS_ABORT_FAIL_REGEX" + ) + rocprofiler_systems_message( + FATAL_ERROR + "${TEST_NAME} has set pass and fail regexes but fail regex does not include '|ROCPROFSYS_ABORT_FAIL_REGEX'" + ) + endif() + + if("${TEST_FAIL_REGEX}" STREQUAL "") + set(TEST_FAIL_REGEX "(${ROCPROFSYS_ABORT_FAIL_REGEX})") + else() + string( + REPLACE + "|ROCPROFSYS_ABORT_FAIL_REGEX" + "|${ROCPROFSYS_ABORT_FAIL_REGEX}" + TEST_FAIL_REGEX + "${TEST_FAIL_REGEX}" + ) + endif() + + if(TEST_COMMAND) + add_test( + NAME ${TEST_NAME} + COMMAND ${TEST_COMMAND} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_WORKING_DIRECTORY} + ) + + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + TIMEOUT ${TEST_TIMEOUT} + DEPENDS "${TEST_DEPENDS}" + LABELS "rocprofiler-systems-bin;${TEST_LABELS}" + PASS_REGULAR_EXPRESSION "${TEST_PASS_REGEX}" + FAIL_REGULAR_EXPRESSION "${TEST_FAIL_REGEX}" + SKIP_REGULAR_EXPRESSION "${TEST_SKIP_REGEX}" + ${TEST_PROPERTIES} + ) + elseif(TARGET ${TEST_TARGET}) + add_test( + NAME ${TEST_NAME} + COMMAND $ ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_WORKING_DIRECTORY} + ) + + set_tests_properties( + ${TEST_NAME} + PROPERTIES + ENVIRONMENT "${TEST_ENVIRONMENT}" + TIMEOUT ${TEST_TIMEOUT} + DEPENDS "${TEST_DEPENDS}" + LABELS "rocprofiler-systems-bin;${TEST_LABELS}" + PASS_REGULAR_EXPRESSION "${TEST_PASS_REGEX}" + FAIL_REGULAR_EXPRESSION "${TEST_FAIL_REGEX}" + SKIP_REGULAR_EXPRESSION "${TEST_SKIP_REGEX}" + ${TEST_PROPERTIES} + ) + elseif(ROCPROFSYS_BUILD_TESTING) + message(FATAL_ERROR "Error! ${TEST_TARGET} does not exist") + endif() +endfunction() diff --git a/projects/rocprofiler-systems/tests/source/CMakeLists.txt b/projects/rocprofiler-systems/tests/rocprof-sys-thread-limit-tests.cmake similarity index 88% rename from projects/rocprofiler-systems/tests/source/CMakeLists.txt rename to projects/rocprofiler-systems/tests/rocprof-sys-thread-limit-tests.cmake index 0746f43b35..3e4ab1fc71 100644 --- a/projects/rocprofiler-systems/tests/source/CMakeLists.txt +++ b/projects/rocprofiler-systems/tests/rocprof-sys-thread-limit-tests.cmake @@ -20,15 +20,15 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -set(CMAKE_BUILD_TYPE "Release") -find_package(Threads REQUIRED) +# -------------------------------------------------------------------------------------- # +# +# thread-limit tests +# +# -------------------------------------------------------------------------------------- # -add_library(tests-compile-options INTERFACE) -target_compile_options(tests-compile-options INTERFACE -g) - -add_executable(thread-limit thread-limit.cpp) -target_compile_definitions(thread-limit PRIVATE MAX_THREADS=${ROCPROFSYS_MAX_THREADS}) -target_link_libraries(thread-limit PRIVATE Threads::Threads tests-compile-options) +if(NOT TARGET thread-limit) + return() +endif() set(_thread_limit_environment "${_base_environment}" @@ -40,6 +40,7 @@ set(_thread_limit_environment "ROCPROFSYS_VERBOSE=2" "ROCPROFSYS_TIMEMORY_COMPONENTS=wall_clock,peak_rss,page_rss" ) + # Maximum allowed threads set(ALLOWED_MAX_THREADS 4096)