From f7ad045f5e1a3c69a7340ad2fa390fdfdf3e6343 Mon Sep 17 00:00:00 2001 From: Ross Brunton Date: Fri, 7 Mar 2025 16:39:35 +0000 Subject: [PATCH] [UR] Move non-conformance/adapter tests to lit This adds support for lit to unified-runtime, in the form of a new target `check-unified-runtime`. This target is available when UR is built standalone and when built as part of dpcpp. In addition, there are targets like `check-unified-runtime-unit` which run a subset of the lit tests. When built standalone, `lit` and `filecheck` must be avilable in the path. A `requirements_testing.txt` file is available to install test dependencies. When built as part of dpcpp, a new cmake variable is available; `SYCL_UR_BUILD_TESTS` which is off by default. When enabled, `check-unified-runtime` will be available as a target and will also run as part of `check-all`. All tests have been ported with the exception of: * Adapter tests * Conformance tests The Python version for macos was also bumped to 3.10 to enable use of a newer filecheck version. --- .github/workflows/ur-build-hw.yml | 1 + .github/workflows/ur-precommit.yml | 6 +- sycl/cmake/modules/FetchUnifiedRuntime.cmake | 9 +- unified-runtime/README.md | 18 +- unified-runtime/cmake/FindLit.cmake | 29 ++ unified-runtime/cmake/match.cmake | 77 ---- unified-runtime/cmake/match.py | 254 ---------- .../source/adapters/CMakeLists.txt | 9 + unified-runtime/test/.clang-format | 1 + unified-runtime/test/CMakeLists.txt | 80 +++- unified-runtime/test/adapters/lit.cfg.py | 11 + .../test/conformance/CMakeLists.txt | 3 +- .../device/urDeviceGetSelected.cpp | 1 - unified-runtime/test/conformance/lit.cfg.py | 11 + unified-runtime/test/fuzz/CMakeLists.txt | 54 +-- .../test/fuzz/level_zero-long.test | 4 + .../test/fuzz/level_zero-short.test | 7 + unified-runtime/test/fuzz/lit.local.cfg.py | 21 + unified-runtime/test/fuzz/mock-long.test | 3 + unified-runtime/test/fuzz/mock-short.test | 6 + unified-runtime/test/layers/CMakeLists.txt | 5 + .../test/layers/sanitizer/CMakeLists.txt | 37 +- .../test/layers/sanitizer/asan.cpp | 3 + .../test/layers/sanitizer/lit.local.cfg.py | 10 + .../layers/sanitizer/sanitizer_options.cpp | 3 + .../test/layers/tracing/CMakeLists.txt | 59 +-- .../test/layers/tracing/codeloc.out.match | 2 - .../test/layers/tracing/codeloc.test | 6 + .../tracing/hello_world.out.logged.match | 23 - .../test/layers/tracing/hello_world.out.match | 23 - .../layers/tracing/hello_world_collected.test | 27 ++ .../layers/tracing/hello_world_logged.test | 27 ++ .../test/layers/tracing/lit.local.cfg.py | 15 + .../test/layers/validation/CMakeLists.txt | 53 +-- .../test/layers/validation/leaks.cpp | 109 +++++ .../test/layers/validation/leaks.out.match | 120 ----- .../test/layers/validation/leaks_mt.cpp | 99 ++++ .../test/layers/validation/leaks_mt.out.match | 103 ----- .../test/layers/validation/lifetime.cpp | 10 + .../test/layers/validation/lifetime.out.match | 12 - .../test/layers/validation/lit.local.cfg.py | 17 + .../test/layers/validation/parameters.cpp | 3 + unified-runtime/test/lit.cfg.py | 96 ++++ unified-runtime/test/lit.site.cfg.py.in | 30 ++ unified-runtime/test/loader/CMakeLists.txt | 5 +- .../loader/adapter_registry/CMakeLists.txt | 44 +- .../loader/adapter_registry/lit.local.cfg.py | 16 + .../loader/adapter_registry/prefilter.cpp | 2 + .../loader/adapter_registry/search_no_env.cpp | 2 + .../loader/adapter_registry/search_order.cpp | 2 + .../adapter_registry/search_with_env.cpp | 2 + .../test/loader/handles/CMakeLists.txt | 24 +- .../test/loader/handles/handles.test | 1 + unified-runtime/test/loader/hello_world.test | 1 + .../test/loader/loader_config/CMakeLists.txt | 16 +- .../loader/loader_config/loader_config.test | 1 + .../loader/loader_lifetime/CMakeLists.txt | 16 +- .../loader_lifetime/loader_lifetime.test | 1 + .../test/loader/platforms/CMakeLists.txt | 33 +- .../test/loader/platforms/no_platforms.match | 2 - .../test/loader/platforms/no_platforms.test | 6 + .../test/loader/platforms/null_platform.match | 3 - .../test/loader/platforms/null_platform.test | 5 + .../{unit/utils => logger}/CMakeLists.txt | 15 +- .../test/{unit => }/logger/env_var.cpp | 0 .../test/{unit => }/logger/fixtures.hpp | 0 unified-runtime/test/logger/level-debug.test | 16 + unified-runtime/test/logger/level-error.test | 16 + unified-runtime/test/logger/level-info.test | 16 + unified-runtime/test/logger/level-none.test | 16 + .../test/logger/level-warning.test | 16 + unified-runtime/test/logger/validation.test | 23 + unified-runtime/test/mock/CMakeLists.txt | 21 - .../test/tools/urtrace/CMakeLists.txt | 27 +- unified-runtime/test/tools/urtrace/begin.test | 27 ++ .../test/tools/urtrace/default.test | 17 + .../test/tools/urtrace/filter_device.test | 11 + unified-runtime/test/tools/urtrace/json.test | 22 + .../test/tools/urtrace/lit.local.cfg.py | 15 + .../test/tools/urtrace/mock_hello.match | 13 - .../test/tools/urtrace/mock_hello_begin.match | 23 - .../urtrace/mock_hello_filter_device.match | 7 - .../test/tools/urtrace/mock_hello_json.match | 18 - .../tools/urtrace/mock_hello_no_args.match | 13 - .../tools/urtrace/mock_hello_profiling.match | 13 - .../test/tools/urtrace/no_args.test | 17 + .../test/tools/urtrace/profiling.test | 17 + unified-runtime/test/unit/CMakeLists.txt | 36 +- .../test/unit/{utils => }/getenv.cpp | 0 .../test/unit/{utils => }/helpers.cpp | 0 unified-runtime/test/unit/lit.cfg.py | 16 + unified-runtime/test/unit/lit.site.cfg.py.in | 3 + .../test/unit/{logger => }/logger.cpp | 2 +- .../test/unit/logger/CMakeLists.txt | 433 ------------------ .../logger_all_levels_msg_exact.out.match | 4 - .../unit/logger/logger_debug_msg.out.match | 4 - .../logger/logger_debug_msg_exact.out.match | 1 - .../test/unit/logger/logger_empty.out.match | 0 .../unit/logger/logger_error_msg.out.match | 4 - .../logger/logger_error_msg_exact.out.match | 1 - .../logger/logger_info_msg_exact.out.match | 1 - .../unit/logger/logger_no_debug_msg.out.match | 3 - .../unit/logger/logger_no_error_msg.out.match | 3 - .../logger/logger_warning_msg_exact.out.match | 1 - .../test/unit/logger/no_logfile.cmake | 30 -- unified-runtime/test/{mock => unit}/mock.cpp | 0 .../test/unit/{utils => }/params.cpp | 0 .../test/unit/{utils => }/print.cpp | 0 unified-runtime/test/usm/CMakeLists.txt | 18 +- unified-runtime/test/usm/lit.local.cfg.py | 10 + unified-runtime/test/usm/usmPoolManager.cpp | 3 + .../third_party/requirements_testing.txt | 3 + 112 files changed, 1012 insertions(+), 1622 deletions(-) create mode 100644 unified-runtime/cmake/FindLit.cmake delete mode 100644 unified-runtime/cmake/match.cmake delete mode 100755 unified-runtime/cmake/match.py create mode 100644 unified-runtime/test/.clang-format create mode 100644 unified-runtime/test/adapters/lit.cfg.py create mode 100644 unified-runtime/test/conformance/lit.cfg.py create mode 100644 unified-runtime/test/fuzz/level_zero-long.test create mode 100644 unified-runtime/test/fuzz/level_zero-short.test create mode 100644 unified-runtime/test/fuzz/lit.local.cfg.py create mode 100644 unified-runtime/test/fuzz/mock-long.test create mode 100644 unified-runtime/test/fuzz/mock-short.test create mode 100644 unified-runtime/test/layers/sanitizer/lit.local.cfg.py delete mode 100644 unified-runtime/test/layers/tracing/codeloc.out.match create mode 100644 unified-runtime/test/layers/tracing/codeloc.test delete mode 100644 unified-runtime/test/layers/tracing/hello_world.out.logged.match delete mode 100644 unified-runtime/test/layers/tracing/hello_world.out.match create mode 100644 unified-runtime/test/layers/tracing/hello_world_collected.test create mode 100644 unified-runtime/test/layers/tracing/hello_world_logged.test create mode 100644 unified-runtime/test/layers/tracing/lit.local.cfg.py delete mode 100644 unified-runtime/test/layers/validation/leaks.out.match delete mode 100644 unified-runtime/test/layers/validation/leaks_mt.out.match delete mode 100644 unified-runtime/test/layers/validation/lifetime.out.match create mode 100644 unified-runtime/test/layers/validation/lit.local.cfg.py create mode 100644 unified-runtime/test/lit.cfg.py create mode 100644 unified-runtime/test/lit.site.cfg.py.in create mode 100644 unified-runtime/test/loader/adapter_registry/lit.local.cfg.py create mode 100644 unified-runtime/test/loader/handles/handles.test create mode 100644 unified-runtime/test/loader/hello_world.test create mode 100644 unified-runtime/test/loader/loader_config/loader_config.test create mode 100644 unified-runtime/test/loader/loader_lifetime/loader_lifetime.test delete mode 100644 unified-runtime/test/loader/platforms/no_platforms.match create mode 100644 unified-runtime/test/loader/platforms/no_platforms.test delete mode 100644 unified-runtime/test/loader/platforms/null_platform.match create mode 100644 unified-runtime/test/loader/platforms/null_platform.test rename unified-runtime/test/{unit/utils => logger}/CMakeLists.txt (57%) rename unified-runtime/test/{unit => }/logger/env_var.cpp (100%) rename unified-runtime/test/{unit => }/logger/fixtures.hpp (100%) create mode 100644 unified-runtime/test/logger/level-debug.test create mode 100644 unified-runtime/test/logger/level-error.test create mode 100644 unified-runtime/test/logger/level-info.test create mode 100644 unified-runtime/test/logger/level-none.test create mode 100644 unified-runtime/test/logger/level-warning.test create mode 100644 unified-runtime/test/logger/validation.test delete mode 100644 unified-runtime/test/mock/CMakeLists.txt create mode 100644 unified-runtime/test/tools/urtrace/begin.test create mode 100644 unified-runtime/test/tools/urtrace/default.test create mode 100644 unified-runtime/test/tools/urtrace/filter_device.test create mode 100644 unified-runtime/test/tools/urtrace/json.test create mode 100644 unified-runtime/test/tools/urtrace/lit.local.cfg.py delete mode 100644 unified-runtime/test/tools/urtrace/mock_hello.match delete mode 100644 unified-runtime/test/tools/urtrace/mock_hello_begin.match delete mode 100644 unified-runtime/test/tools/urtrace/mock_hello_filter_device.match delete mode 100644 unified-runtime/test/tools/urtrace/mock_hello_json.match delete mode 100644 unified-runtime/test/tools/urtrace/mock_hello_no_args.match delete mode 100644 unified-runtime/test/tools/urtrace/mock_hello_profiling.match create mode 100644 unified-runtime/test/tools/urtrace/no_args.test create mode 100644 unified-runtime/test/tools/urtrace/profiling.test rename unified-runtime/test/unit/{utils => }/getenv.cpp (100%) rename unified-runtime/test/unit/{utils => }/helpers.cpp (100%) create mode 100644 unified-runtime/test/unit/lit.cfg.py create mode 100644 unified-runtime/test/unit/lit.site.cfg.py.in rename unified-runtime/test/unit/{logger => }/logger.cpp (99%) delete mode 100644 unified-runtime/test/unit/logger/CMakeLists.txt delete mode 100644 unified-runtime/test/unit/logger/logger_all_levels_msg_exact.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_debug_msg.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_debug_msg_exact.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_empty.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_error_msg.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_error_msg_exact.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_info_msg_exact.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_no_debug_msg.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_no_error_msg.out.match delete mode 100644 unified-runtime/test/unit/logger/logger_warning_msg_exact.out.match delete mode 100644 unified-runtime/test/unit/logger/no_logfile.cmake rename unified-runtime/test/{mock => unit}/mock.cpp (100%) rename unified-runtime/test/unit/{utils => }/params.cpp (100%) rename unified-runtime/test/unit/{utils => }/print.cpp (100%) create mode 100644 unified-runtime/test/usm/lit.local.cfg.py create mode 100644 unified-runtime/third_party/requirements_testing.txt diff --git a/.github/workflows/ur-build-hw.yml b/.github/workflows/ur-build-hw.yml index a0f94ab10f53..19dfc9333ce2 100644 --- a/.github/workflows/ur-build-hw.yml +++ b/.github/workflows/ur-build-hw.yml @@ -102,6 +102,7 @@ jobs: . .venv/bin/activate echo "$PATH" >> $GITHUB_PATH pip install -r third_party/requirements.txt + pip install -r third_party/requirements_testing.txt - name: Download DPC++ run: | diff --git a/.github/workflows/ur-precommit.yml b/.github/workflows/ur-precommit.yml index 0f32c89a2ee9..b4cba7eb374a 100644 --- a/.github/workflows/ur-precommit.yml +++ b/.github/workflows/ur-precommit.yml @@ -89,11 +89,13 @@ jobs: - uses: actions/setup-python@8d9ed9ac5c53483de85588cdf95a591a75ab9f55 # v5.0.0 with: - python-version: 3.9 + python-version: "3.10" - name: Install prerequisites working-directory: ${{github.workspace}}/unified-runtime - run: python3 -m pip install -r third_party/requirements.txt + run: | + python3 -m pip install -r third_party/requirements.txt + python3 -m pip install -r third_party/requirements_testing.txt - name: Install hwloc run: brew install hwloc diff --git a/sycl/cmake/modules/FetchUnifiedRuntime.cmake b/sycl/cmake/modules/FetchUnifiedRuntime.cmake index c47f0b0d41ad..ebd6108035fc 100644 --- a/sycl/cmake/modules/FetchUnifiedRuntime.cmake +++ b/sycl/cmake/modules/FetchUnifiedRuntime.cmake @@ -23,9 +23,12 @@ option(SYCL_UR_USE_FETCH_CONTENT set(SYCL_UR_SOURCE_DIR "" CACHE PATH "Path to root of Unified Runtime repository") -# Here we override the defaults to disable building tests from unified-runtime -set(UR_BUILD_EXAMPLES OFF CACHE BOOL "Build example applications." FORCE) -set(UR_BUILD_TESTS OFF CACHE BOOL "Build unit tests." FORCE) +option(SYCL_UR_BUILD_TESTS "Build tests for UR" OFF) +set(UR_BUILD_TESTS "${SYCL_UR_BUILD_TESTS}" CACHE BOOL "" FORCE) +# UR tests require the examples to be built +set(UR_BUILD_EXAMPLES "${SYCL_UR_BUILD_TESTS}" CACHE BOOL "" FORCE) + +# Here we override the defaults to unified-runtime set(UR_BUILD_XPTI_LIBS OFF) set(UR_ENABLE_SYMBOLIZER ON CACHE BOOL "Enable symbolizer for sanitizer layer.") set(UR_ENABLE_TRACING ON) diff --git a/unified-runtime/README.md b/unified-runtime/README.md index 21dcf257f43c..0f0d5a00236b 100644 --- a/unified-runtime/README.md +++ b/unified-runtime/README.md @@ -149,15 +149,29 @@ List of options provided by CMake: | UR_HIP_HSA_INCLUDE_DIRS | Path of the ROCm HSA include directory | Directory path | `${UR_HIP_ROCM_DIR}/hsa/include;${UR_HIP_ROCM_DIR}/include` | | UR_HIP_LIB_DIR | Path of the ROCm HIP library directory | Directory path | `${UR_HIP_ROCM_DIR}/lib` | -### Additional make targets +### Testing -To run tests, do the following: +Unified Runtime uses `lit` and `FileCheck` as part of its test suite. When built as +part of an LLVM build, the binaries provided by LLVM will be used. When built standalone, +both `lit` and `FileCheck` (or `filecheck`) must be visible on `$PATH`. The easiest way +to do this is to install the Python packages for `lit` and `filecheck`. + +```bash +$ source .venv/bin/activate +$ pip install -r third_party/requirements_testing.txt +``` + +> Note: `filecheck` requires Python >= 3.10; if you get errors claiming that `filecheck` is not available, update your Python version or disable testing. + +Once installed, tests can be executed using: ```bash $ make $ make test ``` +### Additional make targets + To run automated code formatting, configure CMake with `UR_FORMAT_CPP_STYLE` option and then run a custom `cppformat` target: diff --git a/unified-runtime/cmake/FindLit.cmake b/unified-runtime/cmake/FindLit.cmake new file mode 100644 index 000000000000..94118e67ac65 --- /dev/null +++ b/unified-runtime/cmake/FindLit.cmake @@ -0,0 +1,29 @@ +# Copyright (C) 2025 Intel Corporation +# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +# See LICENSE.TXT +# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + + +# There are two modes to finding lit and filecheck +# If we are a standalone build, use the python packages +# If we are not a standalone build, use the one provided by LLVM +# Note that the python filecheck re-implementation isn't 100% compatible, but hopefully for simple tests it should be +# good enough + +if(UR_STANDALONE_BUILD) + # Standalone build + find_program(URLIT_LIT_BINARY "lit") + if(NOT URLIT_LIT_BINARY) + message(FATAL_ERROR "No `lit` binary was found in path. Consider installing the python Package `lit`") + endif() + + find_program(URLIT_FILECHECK_BINARY NAMES "filecheck" "FileCheck") + if(NOT URLIT_FILECHECK_BINARY) + message(FATAL_ERROR "No `filecheck` or `FileCheck` binary was found in path. Consider installing the python Package `filecheck`") + endif() +else() + # In source build + + # This will be in the $PATH + set(URLIT_FILECHECK_BINARY "FileCheck") +endif() diff --git a/unified-runtime/cmake/match.cmake b/unified-runtime/cmake/match.cmake deleted file mode 100644 index 0a0aa6a4dc85..000000000000 --- a/unified-runtime/cmake/match.cmake +++ /dev/null @@ -1,77 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# -# match.cmake -- script for creating ctests that compare the output of a binary -# with a known good match file. -# - -find_package(Python3 COMPONENTS Interpreter) - -# Process variables passed to the script -if(NOT DEFINED MODE) - message(FATAL_ERROR "MODE needs to be defined. Possible values: 'stdout', 'stderr', 'file'") -elseif(${MODE} STREQUAL "stdout" OR ${MODE} STREQUAL "stderr") - if(NOT DEFINED TEST_FILE) - message(FATAL_ERROR "TEST_FILE needs to be defined with a path to a binary to run") - else() - set(OUT_FILE "_matchtmpfile") - endif() -elseif(${MODE} STREQUAL "file") - if(NOT DEFINED OUT_FILE) - message(FATAL_ERROR "OUT_FILE needs to be defined with an output file to be verified") - endif() -else() - message(FATAL_ERROR "${MODE} mode not recognised. Possible values: 'stdout', 'stderr', 'file'") -endif() -if(NOT DEFINED MATCH_FILE) - message(FATAL_ERROR "MATCH_FILE needs to be defined") -endif() -if(NOT DEFINED TEST_ARGS) # easier than ifdefing the rest of the code - set(TEST_ARGS "") -endif() - -string(REPLACE "\"" "" TEST_ARGS "${TEST_ARGS}") -separate_arguments(TEST_ARGS) - -if(EXISTS ${OUT_FILE}) - file(REMOVE ${OUT_FILE}) -endif() - -# Run the test binary. Capture the output to the temporary file. -if(${MODE} STREQUAL "stdout") - execute_process( - COMMAND ${TEST_FILE} ${TEST_ARGS} - OUTPUT_FILE ${OUT_FILE} - RESULT_VARIABLE TEST_RESULT - ) -elseif(${MODE} STREQUAL "stderr") - execute_process( - COMMAND ${TEST_FILE} ${TEST_ARGS} - ERROR_FILE ${OUT_FILE} - RESULT_VARIABLE TEST_RESULT - ) -elseif(${MODE} STREQUAL "file") - execute_process( - COMMAND ${TEST_FILE} - RESULT_VARIABLE TEST_RESULT - ) -endif() - -if(TEST_RESULT) - message(FATAL_ERROR "Failed: Test command '${TEST_FILE} ${TEST_ARGS}' returned non-zero (${TEST_RESULT}).") -endif() - -# Compare the output file contents with a match file contents -execute_process( - COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_LIST_DIR}/match.py ${OUT_FILE} ${MATCH_FILE} - RESULT_VARIABLE TEST_RESULT -) - -if(TEST_RESULT) - message(FATAL_ERROR "Failed (${TEST_RESULT}): The output of test command '${TEST_FILE} ${TEST_ARGS}' (stored in ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE}) does not match '${MATCH_FILE}'") -else() - message("Passed: The output of test command '${TEST_FILE} ${TEST_ARGS}' (stored in ${CMAKE_CURRENT_BINARY_DIR}/${OUT_FILE}) matches '${MATCH_FILE}'") -endif() diff --git a/unified-runtime/cmake/match.py b/unified-runtime/cmake/match.py deleted file mode 100755 index 2448eaf78a72..000000000000 --- a/unified-runtime/cmake/match.py +++ /dev/null @@ -1,254 +0,0 @@ -#!/usr/bin/env python3 - -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# Check if all input file content matches match file content. -# Lines in a match file can contain regex inside of double curly braces {{}}. -# Regex patterns are limited to single line. -# -# List of available special tags: -# {{OPT}} - makes content in the same line as the tag optional -# {{IGNORE}} - ignores all content until the next successfully matched line or the end of the input -# {{NONDETERMINISTIC}} - order of match rules isn't important - each (non OPT) input line is paired with a match line -# in any order -# Special tags are mutually exclusive and are expected to be located at the start of a line. -# - -import os -import sys -import re -from enum import Enum - - -## @brief print a sequence of lines -def print_lines(lines, hint=None): - counter = 1 - for l in lines: - hint_char = " " - if hint == counter - 1: - hint_char = ">" - print("{}{:4d}| {}".format(hint_char, counter, l.strip())) - counter += 1 - - -## @brief print the whole content of input and match files -def print_content( - input_lines, match_lines, ignored_lines, hint_input=None, hint_match=None -): - print("------ Input Lines " + "-" * 61) - print_lines(input_lines, hint_input) - print("------ Match Lines " + "-" * 61) - print_lines(match_lines, hint_match) - print("------ Ignored Lines " + "-" * 59) - print_lines(ignored_lines) - print("-" * 80) - - -## @brief print the incorrect match line -def print_incorrect_match(match_line, present, expected): - print("Line " + str(match_line) + " does not match") - print("is: " + present) - print("expected: " + expected) - - -## @brief print missing match line -def print_input_not_found(input_line, input): - print("Input line " + str(input_line) + " has no match line") - print("is: " + input) - - -## @brief print missing input line -def print_match_not_found(match_line, input): - print("Match line " + str(match_line) + " has no input line") - print("is: " + input) - - -## @brief print general syntax error -def print_error(text, match_line): - print("Line " + str(match_line) + " encountered an error") - print(text) - - -## @brief pattern matching script status values -class Status(Enum): - INPUT_END = 1 - MATCH_END = 2 - INPUT_AND_MATCH_END = 3 - PROCESSING = 4 - - -## @brief check matching script status -def check_status(input_lines, match_lines): - if not input_lines and not match_lines: - return Status.INPUT_AND_MATCH_END - elif not input_lines: - return Status.INPUT_END - elif not match_lines: - return Status.MATCH_END - return Status.PROCESSING - - -## @brief pattern matching tags. -## Tags are expected to be at the start of the line. -class Tag(Enum): - OPT = "{{OPT}}" # makes the line optional - IGNORE = "{{IGNORE}}" # ignores all input until next match or end of input file - NONDETERMINISTIC = "{{NONDETERMINISTIC}}" # switches on "deterministic mode" - COMMENT = "#" # comment - line ignored - - -## @brief main function for the match file processing script -def main(): - if len(sys.argv) != 3: - print("Usage: python match.py ") - sys.exit(1) - - input_file = sys.argv[1] - match_file = sys.argv[2] - - with open(input_file, "r") as input, open(match_file, "r") as match: - input_lines = input.readlines() - # Filter out empty lines and comments (lines beginning with the comment - # character, ignoring leading whitespace) - match_lines = list( - filter( - lambda line: line.strip() - and not line.lstrip().startswith(Tag.COMMENT.value), - match.readlines(), - ) - ) - - ignored_lines = [] - matched_lines = set() - - input_idx = 0 - match_idx = 0 - tags_in_effect = [] - deterministic_mode = False - while True: - # check file status - status = check_status(input_lines[input_idx:], match_lines[match_idx:]) - if deterministic_mode: - if status == Status.INPUT_END: - # Convert the list of seen matches to the list of unseen matches - remaining_matches = set(range(len(match_lines))) - matched_lines - for m in remaining_matches: - line = match_lines[m] - if line.startswith(Tag.OPT.value) or line.startswith( - Tag.NONDETERMINISTIC.value - ): - continue - print_match_not_found(m + 1, match_lines[m]) - print_content(input_lines, match_lines, ignored_lines, hint_match=m) - sys.exit(1) - - sys.exit(0) - elif status == Status.MATCH_END: - print_input_not_found(input_idx + 1, input_lines[input_idx]) - print_content( - input_lines, match_lines, ignored_lines, hint_input=input_idx - ) - sys.exit(1) - else: - if (status == Status.INPUT_AND_MATCH_END) or ( - status == Status.MATCH_END and Tag.IGNORE in tags_in_effect - ): - # all lines matched or the last line in match file is an ignore tag - sys.exit(0) - elif status == Status.MATCH_END: - print_incorrect_match(input_idx + 1, input_lines[input_idx].strip(), "") - print_content( - input_lines, match_lines, ignored_lines, hint_input=input_idx - ) - sys.exit(1) - elif status == Status.INPUT_END: - # If we get to the end of the input, but still have pending matches, - # then that's a failure unless all pending matches are optional - - # otherwise we're done - while match_idx < len(match_lines): - if not ( - match_lines[match_idx].startswith(Tag.OPT.value) - or match_lines[match_idx].startswith(Tag.IGNORE.value) - or match_lines[match_idx].startswith(Tag.NONDETERMINISTIC.value) - ): - print_incorrect_match(match_idx + 1, "", match_lines[match_idx]) - print_content( - input_lines, - match_lines, - ignored_lines, - hint_match=match_idx, - ) - sys.exit(1) - match_idx += 1 - sys.exit(0) - - input_line = ( - input_lines[input_idx].strip() if input_idx < len(input_lines) else "" - ) - match_line = match_lines[match_idx] - - # check for tags - if match_line.startswith(Tag.OPT.value): - tags_in_effect.append(Tag.OPT) - match_line = match_line[len(Tag.OPT.value) :] - elif ( - match_line.startswith(Tag.NONDETERMINISTIC.value) and not deterministic_mode - ): - deterministic_mode = True - match_idx = 0 - input_idx = 0 - continue - elif match_line.startswith(Tag.IGNORE.value): - if deterministic_mode: - print_error(r"Can't use \{{IGNORE\}} in deterministic mode") - sys.exit(2) - tags_in_effect.append(Tag.IGNORE) - match_idx += 1 - continue # line with ignore tag should be skipped - - # split into parts at {{ }} - match_parts = re.split(r"\{{(.*?)\}}", match_line.strip()) - pattern = "" - for j, part in enumerate(match_parts): - if j % 2 == 0: - pattern += re.escape(part) - else: - pattern += part - - # match or process tags - if deterministic_mode: - if re.fullmatch(pattern, input_line) and match_idx not in matched_lines: - input_idx += 1 - matched_lines.add(match_idx) - match_idx = 0 - tags_in_effect = [] - else: - match_idx += 1 - else: - if re.fullmatch(pattern, input_line): - input_idx += 1 - match_idx += 1 - tags_in_effect = [] - elif Tag.OPT in tags_in_effect: - match_idx += 1 - tags_in_effect.remove(Tag.OPT) - elif Tag.IGNORE in tags_in_effect: - ignored_lines.append(input_line + os.linesep) - input_idx += 1 - else: - print_incorrect_match(match_idx + 1, input_line, match_line.strip()) - print_content( - input_lines, - match_lines, - ignored_lines, - hint_match=match_idx, - hint_input=input_idx, - ) - sys.exit(1) - - -if __name__ == "__main__": - main() diff --git a/unified-runtime/source/adapters/CMakeLists.txt b/unified-runtime/source/adapters/CMakeLists.txt index 6b382791a9fd..56e053d29bc3 100644 --- a/unified-runtime/source/adapters/CMakeLists.txt +++ b/unified-runtime/source/adapters/CMakeLists.txt @@ -47,21 +47,30 @@ function(add_ur_adapter_subdirectory name) endif() endfunction() +list(APPEND TEMP_LIST "mock") + if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_L0_V2 OR UR_BUILD_ADAPTER_ALL) add_ur_adapter_subdirectory(level_zero) + list(APPEND TEMP_LIST "level_zero") endif() if(UR_BUILD_ADAPTER_CUDA OR UR_BUILD_ADAPTER_ALL) add_ur_adapter_subdirectory(cuda) + list(APPEND TEMP_LIST "cuda") endif() if(UR_BUILD_ADAPTER_HIP OR UR_BUILD_ADAPTER_ALL) add_ur_adapter_subdirectory(hip) + list(APPEND TEMP_LIST "hip") endif() if(UR_BUILD_ADAPTER_OPENCL OR UR_BUILD_ADAPTER_ALL) add_ur_adapter_subdirectory(opencl) + list(APPEND TEMP_LIST "opencl") endif() if(UR_BUILD_ADAPTER_NATIVE_CPU OR UR_BUILD_ADAPTER_ALL) add_ur_adapter_subdirectory(native_cpu) + list(APPEND TEMP_LIST "native_cpu") endif() + +set(UR_ADAPTERS_LIST "${TEMP_LIST}" CACHE STRING "" FORCE) diff --git a/unified-runtime/test/.clang-format b/unified-runtime/test/.clang-format new file mode 100644 index 000000000000..f03a1189ad46 --- /dev/null +++ b/unified-runtime/test/.clang-format @@ -0,0 +1 @@ +ReflowComments: false diff --git a/unified-runtime/test/CMakeLists.txt b/unified-runtime/test/CMakeLists.txt index cee05330d1a7..099a51d24f33 100644 --- a/unified-runtime/test/CMakeLists.txt +++ b/unified-runtime/test/CMakeLists.txt @@ -10,15 +10,91 @@ FetchContent_Declare( GIT_TAG v1.13.0 ) +include(FindLit) + set(UR_TEST_DEVICES_COUNT 1 CACHE STRING "Count of devices on which conformance and adapters tests will be run") set(UR_TEST_PLATFORMS_COUNT 1 CACHE STRING "Count of platforms on which conformance and adapters tests will be run") set(UR_TEST_FUZZTESTS ON CACHE BOOL "Run fuzz tests if using clang and UR_DPCXX is specified") # For Windows: Prevent overriding the parent project's compiler/linker settings set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UR_DPCXX AND UR_TEST_FUZZTESTS) + set(UR_FUZZTESTING_ENABLED ON) +endif() + set(INSTALL_GTEST OFF) FetchContent_MakeAvailable(googletest) enable_testing() +# Set up the root `check-unified-runtime` target +configure_file(lit.site.cfg.py.in lit.site.cfg.py) +add_custom_target(deps_check-unified-runtime) +if(UR_STANDALONE_BUILD) + add_custom_target(check-unified-runtime + COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -v + DEPENDS deps_check-unified-runtime + ) +else() + # Use the LLVM method to add the test suite - this also registers it under `check-all` + add_lit_testsuite(check-unified-runtime "Running Unified Runtime ${suite} tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS FileCheck deps_check-unified-runtime + ) +endif() +if(UR_STANDALONE_BUILD) + add_test(NAME lit COMMAND ${URLIT_LIT_BINARY} "${CMAKE_CURRENT_BINARY_DIR}") +endif() + +# Create a new test suite that can be ran with `check-unified-runtime-${suite}` +# Lit will execute tests in `${CMAKE_CURRENT_BINARY_DIR}`, and any `add_gtest_test`s will be added as dependencies of +# this test suite +function(add_ur_lit_testsuite suite) + cmake_parse_arguments(PARSE_ARGV 0 arg + "" "" "DEPENDS" + ) + set(TARGET "check-unified-runtime-${suite}") + + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in) + configure_file(lit.site.cfg.py.in lit.site.cfg.py) + endif() + + if(UR_STANDALONE_BUILD) + add_custom_target(${TARGET} + COMMAND "${URLIT_LIT_BINARY}" "${CMAKE_CURRENT_BINARY_DIR}" -v + ) + else() + add_lit_testsuite(${TARGET} "Running Unified Runtime ${suite} tests" + ${CMAKE_CURRENT_BINARY_DIR} + DEPENDS FileCheck + ) + endif() + + add_custom_target(deps_${TARGET} DEPENDS "${arg_DEPENDS}") + add_dependencies(${TARGET} deps_${TARGET}) + add_dependencies(deps_check-unified-runtime deps_${TARGET}) + set(TEST_CURRENT_SUITE "${TARGET}" PARENT_SCOPE) +endfunction() + +# Add a new gtest test; it will be added to the dependency list of the current `add_ur_lit_testsuite` +function(add_gtest_test name) + set(TEST_TARGET_NAME ${name}-test) + add_ur_executable(${TEST_TARGET_NAME} ${ARGN}) + target_link_libraries(${TEST_TARGET_NAME} + PRIVATE + ${PROJECT_NAME}::loader + ${PROJECT_NAME}::headers + ${PROJECT_NAME}::testing + ${PROJECT_NAME}::mock + ${PROJECT_NAME}::common + gmock + GTest::gtest_main) + set_target_properties(${TEST_TARGET_NAME} + PROPERTIES + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}" + ) + add_dependencies(deps_${TEST_CURRENT_SUITE} ${TEST_TARGET_NAME}) +endfunction() + # Conformance defines the generate_device_binaries target which should be # imported first add_subdirectory(conformance) @@ -27,11 +103,11 @@ add_subdirectory(loader) add_subdirectory(adapters) add_subdirectory(usm) add_subdirectory(layers) +add_subdirectory(logger) add_subdirectory(unit) -add_subdirectory(mock) if(UR_BUILD_TOOLS) add_subdirectory(tools) endif() -if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND UR_DPCXX AND UR_TEST_FUZZTESTS) +if(UR_FUZZTESTING_ENABLED) add_subdirectory(fuzz) endif() diff --git a/unified-runtime/test/adapters/lit.cfg.py b/unified-runtime/test/adapters/lit.cfg.py new file mode 100644 index 000000000000..24e6c2e5c138 --- /dev/null +++ b/unified-runtime/test/adapters/lit.cfg.py @@ -0,0 +1,11 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +# Disable lit testing (for now) +config.suffixes = [] diff --git a/unified-runtime/test/conformance/CMakeLists.txt b/unified-runtime/test/conformance/CMakeLists.txt index 0ae75ad66710..9ac92dc251e9 100644 --- a/unified-runtime/test/conformance/CMakeLists.txt +++ b/unified-runtime/test/conformance/CMakeLists.txt @@ -47,8 +47,7 @@ function(add_conformance_test name) ${PROJECT_NAME}::headers ${PROJECT_NAME}::testing ${PROJECT_NAME}::common - GTest::gtest_main - unit_tests_helpers) + GTest::gtest_main) if(UR_USE_CFI) target_compile_definitions(${TEST_TARGET_NAME} PRIVATE UR_USE_CFI) diff --git a/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp b/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp index de81d2511eb3..628967fe11ac 100644 --- a/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp +++ b/unified-runtime/test/conformance/device/urDeviceGetSelected.cpp @@ -4,7 +4,6 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -#include "helpers.h" #include using urDeviceGetSelectedTest = uur::urPlatformTest; diff --git a/unified-runtime/test/conformance/lit.cfg.py b/unified-runtime/test/conformance/lit.cfg.py new file mode 100644 index 000000000000..24e6c2e5c138 --- /dev/null +++ b/unified-runtime/test/conformance/lit.cfg.py @@ -0,0 +1,11 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +# Disable lit testing (for now) +config.suffixes = [] diff --git a/unified-runtime/test/fuzz/CMakeLists.txt b/unified-runtime/test/fuzz/CMakeLists.txt index e2a62a216de0..e6caf50a38eb 100644 --- a/unified-runtime/test/fuzz/CMakeLists.txt +++ b/unified-runtime/test/fuzz/CMakeLists.txt @@ -3,44 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -function(add_fuzz_test name label) - set(TEST_TARGET_NAME fuzztest-${name}) - - set(ENV_VARS "") - if(UR_USE_UBSAN) - list(APPEND ENV_VARS - UBSAN_OPTIONS=print_stacktrace=1) - endif() - - # The XPTI collector is leaking memory, likely unrelated to UR. - #if(UR_ENABLE_TRACING) - # list(APPEND ENV_VARS - # XPTI_TRACE_ENABLE=1 - # XPTI_FRAMEWORK_DISPATCHER=$ - # XPTI_SUBSCRIBERS=$ - # UR_ENABLE_LAYERS=UR_LAYER_TRACING) - #endif() - - if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL) - list(APPEND ENV_VARS - UR_ADAPTERS_FORCE_LOAD=\"$\") - if(UR_USE_ASAN) - list(APPEND ENV_VARS - NEOReadDebugKeys=1 - DisableDeepBind=1) - endif() - else() - list(APPEND ENV_VARS UR_ADAPTERS_FORCE_LOAD=\"$\") - endif() - - add_test(NAME ${TEST_TARGET_NAME} - COMMAND fuzztest-base ${ARGN} -verbosity=1 -detect_leaks=0 - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - set_tests_properties(${TEST_TARGET_NAME} PROPERTIES - LABELS ${label} - ENVIRONMENT "${ENV_VARS}") -endfunction() +add_ur_lit_testsuite(fuzz) # Create a single binary add_ur_executable(fuzztest-base @@ -58,14 +21,7 @@ target_compile_definitions(fuzztest-base PRIVATE -DKERNEL_IL_PATH="${UR_CONFORMA target_include_directories(fuzztest-base PRIVATE ${UR_CONFORMANCE_DEVICE_BINARIES_DIR}) add_dependencies(fuzztest-base generate_device_binaries) -# Add long test -add_fuzz_test(base fuzz-long -max_total_time=600 -seed=1) - -# Add short tests -set(CORPUS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/corpus) -file(GLOB files "${CORPUS_DIR}/*") - -foreach(file ${files}) - get_filename_component(filename ${file} NAME) - add_fuzz_test(${filename} fuzz-short ${file}) -endforeach() +add_dependencies(deps_check-unified-runtime-fuzz fuzztest-base ur_adapter_mock) +if(UR_BUILD_ADAPTER_L0 OR UR_BUILD_ADAPTER_ALL) + add_dependencies(deps_check-unified-runtime-fuzz ur_adapter_level_zero) +endif() diff --git a/unified-runtime/test/fuzz/level_zero-long.test b/unified-runtime/test/fuzz/level_zero-long.test new file mode 100644 index 000000000000..f062d8e2cfe8 --- /dev/null +++ b/unified-runtime/test/fuzz/level_zero-long.test @@ -0,0 +1,4 @@ +RUN: %fuzz-options %use-level_zero fuzztest-base -max_total_time=600 -seed=1 -verbosity=1 -detect_leaks=0 + +REQUIRES: adapter-level_zero +REQUIRES: fuzztesting diff --git a/unified-runtime/test/fuzz/level_zero-short.test b/unified-runtime/test/fuzz/level_zero-short.test new file mode 100644 index 000000000000..534512c49389 --- /dev/null +++ b/unified-runtime/test/fuzz/level_zero-short.test @@ -0,0 +1,7 @@ +RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/alloc -verbosity=1 -detect_leaks=0 +RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/create-release -verbosity=1 -detect_leaks=0 +RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/kernel-launch -verbosity=1 -detect_leaks=0 +RUN: %fuzz-options %use-level_zero fuzztest-base %p/corpus/pool-alloc -verbosity=1 -detect_leaks=0 + +REQUIRES: adapter-level_zero +REQUIRES: fuzztesting diff --git a/unified-runtime/test/fuzz/lit.local.cfg.py b/unified-runtime/test/fuzz/lit.local.cfg.py new file mode 100644 index 000000000000..7f7320e852d6 --- /dev/null +++ b/unified-runtime/test/fuzz/lit.local.cfg.py @@ -0,0 +1,21 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +config.substitutions.append( + ( + r"%fuzz-options", + " ".join( + [ + "NEOReadDebugKeys=1" + "DisableDeepBind=1" + "UBSAN_OPTIONS=print_stacktrace=1" + ] + ), + ) +) diff --git a/unified-runtime/test/fuzz/mock-long.test b/unified-runtime/test/fuzz/mock-long.test new file mode 100644 index 000000000000..83acc5fe6878 --- /dev/null +++ b/unified-runtime/test/fuzz/mock-long.test @@ -0,0 +1,3 @@ +RUN: %fuzz-options %use-mock fuzztest-base -max_total_time=600 -seed=1 -verbosity=1 -detect_leaks=0 + +REQUIRES: fuzztesting diff --git a/unified-runtime/test/fuzz/mock-short.test b/unified-runtime/test/fuzz/mock-short.test new file mode 100644 index 000000000000..8be8a8df20f6 --- /dev/null +++ b/unified-runtime/test/fuzz/mock-short.test @@ -0,0 +1,6 @@ +RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/alloc -verbosity=1 -detect_leaks=0 +RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/create-release -verbosity=1 -detect_leaks=0 +RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/kernel-launch -verbosity=1 -detect_leaks=0 +RUN: %fuzz-options %use-mock fuzztest-base %p/corpus/pool-alloc -verbosity=1 -detect_leaks=0 + +REQUIRES: fuzztesting diff --git a/unified-runtime/test/layers/CMakeLists.txt b/unified-runtime/test/layers/CMakeLists.txt index fbf532c27484..2c8130f88340 100644 --- a/unified-runtime/test/layers/CMakeLists.txt +++ b/unified-runtime/test/layers/CMakeLists.txt @@ -3,10 +3,15 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +add_ur_lit_testsuite(layers DEPENDS + ur_adapter_mock + hello_world) + add_subdirectory(validation) if(UR_ENABLE_TRACING) add_subdirectory(tracing) + add_dependencies(deps_check-unified-runtime-layers ur_collector test_collector collector xptifw) endif() if(UR_ENABLE_SANITIZER) diff --git a/unified-runtime/test/layers/sanitizer/CMakeLists.txt b/unified-runtime/test/layers/sanitizer/CMakeLists.txt index 747255a9c7ad..60f14eb4a781 100644 --- a/unified-runtime/test/layers/sanitizer/CMakeLists.txt +++ b/unified-runtime/test/layers/sanitizer/CMakeLists.txt @@ -3,49 +3,22 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(UR_SANITIZER_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(SAN_TEST_PREFIX sanitizer_test) - -function(add_sanitizer_test_executable name) - add_ur_executable(${SAN_TEST_PREFIX}-${name} - ${ARGN}) - target_link_libraries(${SAN_TEST_PREFIX}-${name} - PRIVATE - ${PROJECT_NAME}::loader - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::testing - ${PROJECT_NAME}::mock - GTest::gtest_main) -endfunction() - -function(set_sanitizer_test_properties name) - set_tests_properties(${name} PROPERTIES LABELS "sanitizer") - set_property(TEST ${name} PROPERTY ENVIRONMENT - "UR_LOG_SANITIZER=level:debug\;flush:debug\;output:stdout") - target_include_directories(${SAN_TEST_PREFIX}-${name} PRIVATE +function(add_sanitizer_test name) + add_gtest_test(${name} ${ARGN}) + target_include_directories(${name}-test PRIVATE ${PROJECT_SOURCE_DIR}/source ${PROJECT_SOURCE_DIR}/source/common ${PROJECT_SOURCE_DIR}/source/loader/layers/sanitizer/sanitizer_common ) endfunction() -function(add_sanitizer_test name) - add_sanitizer_test_executable(${name} ${ARGN}) - - add_test(NAME ${name} - COMMAND ${SAN_TEST_PREFIX}-${name} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - set_sanitizer_test_properties(${name}) -endfunction() - function(add_test_source name source) - target_sources(${SAN_TEST_PREFIX}-${name} PRIVATE ${source}) + target_sources(${name}-test PRIVATE ${source}) endfunction() add_sanitizer_test(asan asan.cpp) - add_sanitizer_test(sanitizer_options sanitizer_options.cpp) + # add the source here in order to test for unexported functions add_test_source(sanitizer_options ${PROJECT_SOURCE_DIR}/source/loader/layers/sanitizer/sanitizer_common/sanitizer_options.cpp diff --git a/unified-runtime/test/layers/sanitizer/asan.cpp b/unified-runtime/test/layers/sanitizer/asan.cpp index b0d6cf027ba1..7de37224aa26 100644 --- a/unified-runtime/test/layers/sanitizer/asan.cpp +++ b/unified-runtime/test/layers/sanitizer/asan.cpp @@ -11,6 +11,9 @@ * */ +// RUN: UR_LOG_SANITIZER="level:debug;flush:debug;output:stdout" asan-test +// REQUIRES: sanitizer + #include #include diff --git a/unified-runtime/test/layers/sanitizer/lit.local.cfg.py b/unified-runtime/test/layers/sanitizer/lit.local.cfg.py new file mode 100644 index 000000000000..ce6081b9e906 --- /dev/null +++ b/unified-runtime/test/layers/sanitizer/lit.local.cfg.py @@ -0,0 +1,10 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +config.suffixes = [".cpp"] diff --git a/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp b/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp index 67d7b0e49503..f08dd56f5001 100644 --- a/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp +++ b/unified-runtime/test/layers/sanitizer/sanitizer_options.cpp @@ -11,6 +11,9 @@ * */ +// RUN: UR_LOG_SANITIZER="level:debug;flush:debug;output:stdout" sanitizer_options-test +// REQUIRES: sanitizer + #include "sanitizer_options.hpp" #include "sanitizer_options_impl.hpp" diff --git a/unified-runtime/test/layers/tracing/CMakeLists.txt b/unified-runtime/test/layers/tracing/CMakeLists.txt index 36861da113a0..557c5e18acbf 100644 --- a/unified-runtime/test/layers/tracing/CMakeLists.txt +++ b/unified-runtime/test/layers/tracing/CMakeLists.txt @@ -19,61 +19,4 @@ if(MSVC) endif() target_compile_definitions(test_collector PRIVATE XPTI_CALLBACK_API_EXPORTS) -function(set_tracing_test_props target_name collector_name) - set_tests_properties(${target_name} PROPERTIES - LABELS "tracing" - ) - - set_property(TEST ${target_name} PROPERTY ENVIRONMENT - "XPTI_TRACE_ENABLE=1" - "XPTI_FRAMEWORK_DISPATCHER=$" - "XPTI_SUBSCRIBERS=$" - "UR_ADAPTERS_FORCE_LOAD=\"$\"" - "UR_ENABLE_LAYERS=UR_LAYER_TRACING") -endfunction() - -add_test(NAME example-collected-hello-world - COMMAND ${CMAKE_COMMAND} - -D MODE=stdout - -D TEST_FILE=$ - -D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/hello_world.out.match - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake -) - -set_tracing_test_props(example-collected-hello-world collector) - -add_test(NAME example-logged-hello-world - COMMAND ${CMAKE_COMMAND} - -D MODE=stdout - -D TEST_FILE=$ - -D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/hello_world.out.logged.match - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake -) -set_tests_properties(example-logged-hello-world PROPERTIES LABELS "tracing") -set_property(TEST example-logged-hello-world PROPERTY ENVIRONMENT - "UR_LOG_TRACING=level:info\;output:stdout" - "UR_ADAPTERS_FORCE_LOAD=\"$\"" - "UR_ENABLE_LAYERS=UR_LAYER_TRACING") - -function(add_tracing_test name) - set(TEST_TARGET_NAME tracing-test-${name}) - add_ur_executable(${TEST_TARGET_NAME} - ${ARGN}) - target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::loader - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::testing - GTest::gtest_main) - add_test(NAME ${name} - COMMAND ${CMAKE_COMMAND} - -D MODE=stderr - -D TEST_FILE=$ - -D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}.out.match - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - set_tracing_test_props(${name} test_collector) -endfunction() - -add_tracing_test(codeloc codeloc.cpp) +add_gtest_test(codeloc codeloc.cpp) diff --git a/unified-runtime/test/layers/tracing/codeloc.out.match b/unified-runtime/test/layers/tracing/codeloc.out.match deleted file mode 100644 index dc0c2e133579..000000000000 --- a/unified-runtime/test/layers/tracing/codeloc.out.match +++ /dev/null @@ -1,2 +0,0 @@ -begin urAdapterGet 178 fname sfile 2 1 -end urAdapterGet 178 fname sfile 2 1 diff --git a/unified-runtime/test/layers/tracing/codeloc.test b/unified-runtime/test/layers/tracing/codeloc.test new file mode 100644 index 000000000000..bd33e4f03693 --- /dev/null +++ b/unified-runtime/test/layers/tracing/codeloc.test @@ -0,0 +1,6 @@ +RUN: %use-mock %xptienable XPTI_SUBSCRIBERS=%{shlibpre}test_collector%{shlibext} codeloc-test 2>&1 | FileCheck %s + +REQUIRES: tracing + +CHECK: begin urAdapterGet 178 fname sfile 2 1 +CHECK: end urAdapterGet 178 fname sfile 2 1 diff --git a/unified-runtime/test/layers/tracing/hello_world.out.logged.match b/unified-runtime/test/layers/tracing/hello_world.out.logged.match deleted file mode 100644 index 24d900e56383..000000000000 --- a/unified-runtime/test/layers/tracing/hello_world.out.logged.match +++ /dev/null @@ -1,23 +0,0 @@ -Platform initialized. - ---> urAdapterGet - <--- urAdapterGet(.NumEntries = 0, .phAdapters = {{.*}}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; - ---> urAdapterGet - <--- urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; - ---> urPlatformGet - <--- urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; - ---> urPlatformGet - <--- urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; - ---> urPlatformGetApiVersion - <--- urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{0\.[0-9]+}})) -> UR_RESULT_SUCCESS; -API version: {{0\.[0-9]+}} - ---> urDeviceGet - <--- urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; - ---> urDeviceGet - <--- urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; - ---> urDeviceGetInfo - <--- urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}} (UR_DEVICE_TYPE_GPU), .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; - ---> urDeviceGetInfo - <--- urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}} (Mock Device), .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -Found a Mock Device gpu. - ---> urAdapterRelease - <--- urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/layers/tracing/hello_world.out.match b/unified-runtime/test/layers/tracing/hello_world.out.match deleted file mode 100644 index cd25b5b9bad9..000000000000 --- a/unified-runtime/test/layers/tracing/hello_world.out.match +++ /dev/null @@ -1,23 +0,0 @@ -Platform initialized. -function_with_args_begin(1) - urAdapterGet(.NumEntries = 0, .phAdapters = {{.*}}, .pNumAdapters = {{.*}}); -function_with_args_end(1) - urAdapterGet(...) -> ur_result_t(0); -function_with_args_begin(2) - urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}}, .pNumAdapters = {{.*}}); -function_with_args_end(2) - urAdapterGet(...) -> ur_result_t(0); -function_with_args_begin(3) - urPlatformGet(unimplemented); -function_with_args_end(3) - urPlatformGet(...) -> ur_result_t(0); -function_with_args_begin(4) - urPlatformGet(unimplemented); -function_with_args_end(4) - urPlatformGet(...) -> ur_result_t(0); -function_with_args_begin(5) - urPlatformGetApiVersion(unimplemented); -function_with_args_end(5) - urPlatformGetApiVersion(...) -> ur_result_t(0); -API version: {{0\.[0-9]+}} -function_with_args_begin(6) - urDeviceGet(unimplemented); -function_with_args_end(6) - urDeviceGet(...) -> ur_result_t(0); -function_with_args_begin(7) - urDeviceGet(unimplemented); -function_with_args_end(7) - urDeviceGet(...) -> ur_result_t(0); -function_with_args_begin(8) - urDeviceGetInfo(unimplemented); -function_with_args_end(8) - urDeviceGetInfo(...) -> ur_result_t(0); -function_with_args_begin(9) - urDeviceGetInfo(unimplemented); -function_with_args_end(9) - urDeviceGetInfo(...) -> ur_result_t(0); -Found a Mock Device gpu. -function_with_args_begin(10) - urAdapterRelease(unimplemented); -function_with_args_end(10) - urAdapterRelease(...) -> ur_result_t(0); diff --git a/unified-runtime/test/layers/tracing/hello_world_collected.test b/unified-runtime/test/layers/tracing/hello_world_collected.test new file mode 100644 index 000000000000..d97ee4d9eb48 --- /dev/null +++ b/unified-runtime/test/layers/tracing/hello_world_collected.test @@ -0,0 +1,27 @@ +RUN: %use-mock %xptienable XPTI_SUBSCRIBERS=%{shlibpre}collector%{shlibext} hello_world 2>&1 | FileCheck %s + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK: function_with_args_begin(1) - urAdapterGet(.NumEntries = 0, .phAdapters = {{.*}}, .pNumAdapters = {{.*}}); +CHECK: function_with_args_end(1) - urAdapterGet(...) -> ur_result_t(0); +CHECK: function_with_args_begin(2) - urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}}, .pNumAdapters = {{.*}}); +CHECK: function_with_args_end(2) - urAdapterGet(...) -> ur_result_t(0); +CHECK: function_with_args_begin(3) - urPlatformGet(unimplemented); +CHECK: function_with_args_end(3) - urPlatformGet(...) -> ur_result_t(0); +CHECK: function_with_args_begin(4) - urPlatformGet(unimplemented); +CHECK: function_with_args_end(4) - urPlatformGet(...) -> ur_result_t(0); +CHECK: function_with_args_begin(5) - urPlatformGetApiVersion(unimplemented); +CHECK: function_with_args_end(5) - urPlatformGetApiVersion(...) -> ur_result_t(0); +CHECK: API version: {{0\.[0-9]+}} +CHECK: function_with_args_begin(6) - urDeviceGet(unimplemented); +CHECK: function_with_args_end(6) - urDeviceGet(...) -> ur_result_t(0); +CHECK: function_with_args_begin(7) - urDeviceGet(unimplemented); +CHECK: function_with_args_end(7) - urDeviceGet(...) -> ur_result_t(0); +CHECK: function_with_args_begin(8) - urDeviceGetInfo(unimplemented); +CHECK: function_with_args_end(8) - urDeviceGetInfo(...) -> ur_result_t(0); +CHECK: function_with_args_begin(9) - urDeviceGetInfo(unimplemented); +CHECK: function_with_args_end(9) - urDeviceGetInfo(...) -> ur_result_t(0); +CHECK: Found a Mock Device gpu. +CHECK: function_with_args_begin(10) - urAdapterRelease(unimplemented); +CHECK: function_with_args_end(10) - urAdapterRelease(...) -> ur_result_t(0); diff --git a/unified-runtime/test/layers/tracing/hello_world_logged.test b/unified-runtime/test/layers/tracing/hello_world_logged.test new file mode 100644 index 000000000000..53ba38973488 --- /dev/null +++ b/unified-runtime/test/layers/tracing/hello_world_logged.test @@ -0,0 +1,27 @@ +RUN: %use-mock UR_LOG_TRACING="level:info;output:stdout" %xptienable hello_world 2>&1 | FileCheck %s + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK: ---> urAdapterGet +CHECK: <--- urAdapterGet(.NumEntries = 0, .phAdapters = {{.*}}, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK: ---> urAdapterGet +CHECK: <--- urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +CHECK: ---> urPlatformGet +CHECK: <--- urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 0, .phPlatforms = {{.*}}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK: ---> urPlatformGet +CHECK: <--- urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}}, .pNumPlatforms = {{.*}}) -> UR_RESULT_SUCCESS; +CHECK: ---> urPlatformGetApiVersion +CHECK: <--- urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{0\.[0-9]+}})) -> UR_RESULT_SUCCESS; +CHECK: API version: {{0\.[0-9]+}} +CHECK: ---> urDeviceGet +CHECK: <--- urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK: ---> urDeviceGet +CHECK: <--- urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; +CHECK: ---> urDeviceGetInfo +CHECK: <--- urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}} (UR_DEVICE_TYPE_GPU), .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK: ---> urDeviceGetInfo +CHECK: <--- urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}} (Mock Device), .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK: Found a Mock Device gpu. +CHECK: ---> urAdapterRelease +CHECK: <--- urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/layers/tracing/lit.local.cfg.py b/unified-runtime/test/layers/tracing/lit.local.cfg.py new file mode 100644 index 000000000000..635064b0fa11 --- /dev/null +++ b/unified-runtime/test/layers/tracing/lit.local.cfg.py @@ -0,0 +1,15 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +config.substitutions.append( + ( + r"%xptienable", + f"UR_ENABLE_LAYERS=UR_LAYER_TRACING XPTI_TRACE_ENABLE=1 XPTI_FRAMEWORK_DISPATCHER={config.shlibpre}xptifw{config.shlibext}", + ) +) diff --git a/unified-runtime/test/layers/validation/CMakeLists.txt b/unified-runtime/test/layers/validation/CMakeLists.txt index 063c5ffc89d6..8aea369ace29 100644 --- a/unified-runtime/test/layers/validation/CMakeLists.txt +++ b/unified-runtime/test/layers/validation/CMakeLists.txt @@ -4,53 +4,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception set(UR_VALIDATION_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) -set(VAL_TEST_PREFIX validation_test) -function(add_validation_test_executable name) - add_ur_executable(${VAL_TEST_PREFIX}-${name} - ${ARGN}) - target_link_libraries(${VAL_TEST_PREFIX}-${name} - PRIVATE - ${PROJECT_NAME}::loader - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::testing - ${PROJECT_NAME}::mock - GTest::gtest_main) -endfunction() - -function(set_validation_test_properties name) - set_tests_properties(${name} PROPERTIES LABELS "validation") - set_property(TEST ${name} PROPERTY ENVIRONMENT - "UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION" - "UR_ADAPTERS_FORCE_LOAD=\"$\"" - "UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout") -endfunction() - -function(add_validation_test name) - add_validation_test_executable(${name} ${ARGN}) - - add_test(NAME ${name} - COMMAND ${VAL_TEST_PREFIX}-${name} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - set_validation_test_properties(${name}) -endfunction() - -function(add_validation_match_test name) - add_validation_test_executable(${name} ${ARGN}) - - add_test(NAME ${name} - COMMAND ${CMAKE_COMMAND} - -D MODE=stdout - -D TEST_FILE=$ - -D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}.out.match - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - - set_validation_test_properties(${name}) -endfunction() - -add_validation_test(parameters parameters.cpp) -add_validation_match_test(leaks leaks.out.match leaks.cpp) -add_validation_match_test(leaks_mt leaks_mt.out.match leaks_mt.cpp) -add_validation_match_test(lifetime lifetime.out.match lifetime.cpp) +add_gtest_test(parameters parameters.cpp) +add_gtest_test(leaks leaks.cpp) +add_gtest_test(leaks_mt leaks_mt.cpp) +add_gtest_test(lifetime lifetime.cpp) diff --git a/unified-runtime/test/layers/validation/leaks.cpp b/unified-runtime/test/layers/validation/leaks.cpp index eeadb5f99dfa..1f44e7257c7f 100644 --- a/unified-runtime/test/layers/validation/leaks.cpp +++ b/unified-runtime/test/layers/validation/leaks.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: %use-mock %validate leaks-test | FileCheck %s + #include "fixtures.hpp" #include @@ -76,12 +78,21 @@ struct queueLeakTest : public valDeviceTest { ur_queue_handle_t queue; }; +// CHECK: [ RUN ] adapterLeakTest.testUrAdapterGetLeak +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(adapterLeakTest, testUrAdapterGetLeak) { ur_adapter_handle_t adapter = nullptr; ASSERT_EQ(urAdapterGet(1, &adapter, nullptr), UR_RESULT_SUCCESS); ASSERT_NE(nullptr, adapter); } +// CHECK: [ RUN ] adapterLeakTest.testUrAdapterRetainLeak +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 +// CHECK-NEXT: [ERROR]: Retained 2 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(adapterLeakTest, testUrAdapterRetainLeak) { ur_adapter_handle_t adapter = nullptr; ASSERT_EQ(urAdapterGet(1, &adapter, nullptr), UR_RESULT_SUCCESS); @@ -89,18 +100,37 @@ TEST_F(adapterLeakTest, testUrAdapterRetainLeak) { ASSERT_EQ(urAdapterRetain(adapter), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] adapterLeakTest.testUrAdapterRetainNonexistent +// CHECK-NEXT: [ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}} TEST_F(adapterLeakTest, testUrAdapterRetainNonexistent) { ur_adapter_handle_t adapter = (ur_adapter_handle_t)0xBEEF; ASSERT_EQ(urAdapterRetain(adapter), UR_RESULT_SUCCESS); ASSERT_NE(nullptr, adapter); } +// CHECK: [ RUN ] valDeviceTest.testUrContextCreateLeak +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(valDeviceTest, testUrContextCreateLeak) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); ASSERT_NE(nullptr, context); } +// CHECK: [ RUN ] valDeviceTest.testUrContextRetainLeak +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 2 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(valDeviceTest, testUrContextRetainLeak) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); @@ -108,11 +138,24 @@ TEST_F(valDeviceTest, testUrContextRetainLeak) { ASSERT_EQ(urContextRetain(context), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] valDeviceTest.testUrContextRetainNonexistent +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 TEST_F(valDeviceTest, testUrContextRetainNonexistent) { ur_context_handle_t context = (ur_context_handle_t)0xC0FFEE; ASSERT_EQ(urContextRetain(context), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] valDeviceTest.testUrContextCreateSuccess +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 TEST_F(valDeviceTest, testUrContextCreateSuccess) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); @@ -120,6 +163,15 @@ TEST_F(valDeviceTest, testUrContextCreateSuccess) { ASSERT_EQ(urContextRelease(context), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] valDeviceTest.testUrContextRetainSuccess +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 TEST_F(valDeviceTest, testUrContextRetainSuccess) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); @@ -129,6 +181,17 @@ TEST_F(valDeviceTest, testUrContextRetainSuccess) { ASSERT_EQ(urContextRelease(context), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] valDeviceTest.testUrContextReleaseLeak +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(valDeviceTest, testUrContextReleaseLeak) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); @@ -137,22 +200,68 @@ TEST_F(valDeviceTest, testUrContextReleaseLeak) { ASSERT_EQ(urContextRelease(context), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] valDeviceTest.testUrContextReleaseNonexistent +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(valDeviceTest, testUrContextReleaseNonexistent) { ur_context_handle_t context = (ur_context_handle_t)0xC0FFEE; ASSERT_EQ(urContextRelease(context), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] queueLeakTest.testUrEnqueueSuccess +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 + TEST_F(queueLeakTest, testUrEnqueueSuccess) { ur_event_handle_t event = nullptr; ASSERT_EQ(urEnqueueEventsWait(queue, 0, nullptr, &event), UR_RESULT_SUCCESS); ASSERT_EQ(urEventRelease(event), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] queueLeakTest.testUrEnqueueLeak +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(queueLeakTest, testUrEnqueueLeak) { ur_event_handle_t event = nullptr; ASSERT_EQ(urEnqueueEventsWait(queue, 0, nullptr, &event), UR_RESULT_SUCCESS); } +// CHECK: [ RUN ] queueLeakTest.testUrEventReleaseNonexistent +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_F(queueLeakTest, testUrEventReleaseNonexistent) { ur_event_handle_t event = (ur_event_handle_t)0xBEEF; ASSERT_EQ(urEventRelease(event), UR_RESULT_SUCCESS); diff --git a/unified-runtime/test/layers/validation/leaks.out.match b/unified-runtime/test/layers/validation/leaks.out.match deleted file mode 100644 index 07c97bed102c..000000000000 --- a/unified-runtime/test/layers/validation/leaks.out.match +++ /dev/null @@ -1,120 +0,0 @@ -{{IGNORE}} -[ RUN ] adapterLeakTest.testUrAdapterGetLeak -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] adapterLeakTest.testUrAdapterRetainLeak -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 -[ERROR]: Retained 2 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] adapterLeakTest.testUrAdapterRetainNonexistent -[ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}} -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextCreateLeak -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextRetainLeak -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 2 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextRetainNonexistent -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[ERROR]: Attempting to retain nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextCreateSuccess -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextRetainSuccess -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextReleaseLeak -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] valDeviceTest.testUrContextReleaseNonexistent -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] queueLeakTest.testUrEnqueueSuccess -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -{{IGNORE}} -[ RUN ] queueLeakTest.testUrEnqueueLeak -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] queueLeakTest.testUrEventReleaseNonexistent -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} diff --git a/unified-runtime/test/layers/validation/leaks_mt.cpp b/unified-runtime/test/layers/validation/leaks_mt.cpp index 54945c6654e4..70342d2aff6f 100644 --- a/unified-runtime/test/layers/validation/leaks_mt.cpp +++ b/unified-runtime/test/layers/validation/leaks_mt.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: %use-mock %validate leaks_mt-test | FileCheck %s + #include "fixtures.hpp" #include @@ -14,6 +16,33 @@ INSTANTIATE_TEST_SUITE_P( threadCountForValDeviceTest, valDeviceTestMultithreaded, ::testing::Values(2, 8, std::thread::hardware_concurrency())); +// CHECK: [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainLeakMt/0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 3 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 3 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: +// CHECK: [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainLeakMt/1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 3 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 4 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 5 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 6 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 7 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 8 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 9 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 9 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: + TEST_P(valDeviceTestMultithreaded, testUrContextRetainLeakMt) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); @@ -31,6 +60,40 @@ TEST_P(valDeviceTestMultithreaded, testUrContextRetainLeakMt) { } } +// CHECK: [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextReleaseLeakMt/0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: +// CHECK: [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextReleaseLeakMt/1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -2 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -3 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -4 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -5 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -6 +// CHECK-NEXT: [ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -7 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained -7 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_P(valDeviceTestMultithreaded, testUrContextReleaseLeakMt) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); @@ -47,6 +110,42 @@ TEST_P(valDeviceTestMultithreaded, testUrContextReleaseLeakMt) { } } +// CHECK: [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainReleaseLeakMt/0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: +// CHECK: [ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainReleaseLeakMt/1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 +// CHECK-NEXT: [ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} +// CHECK-NEXT: [ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: TEST_P(valDeviceTestMultithreaded, testUrContextRetainReleaseLeakMt) { ur_context_handle_t context = nullptr; ASSERT_EQ(urContextCreate(1, &device, nullptr, &context), UR_RESULT_SUCCESS); diff --git a/unified-runtime/test/layers/validation/leaks_mt.out.match b/unified-runtime/test/layers/validation/leaks_mt.out.match deleted file mode 100644 index f0b318249db3..000000000000 --- a/unified-runtime/test/layers/validation/leaks_mt.out.match +++ /dev/null @@ -1,103 +0,0 @@ -{{IGNORE}} -[ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainLeakMt/0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 3 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 3 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainLeakMt/1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 2 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 3 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 4 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 5 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 6 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 7 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 8 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 9 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 9 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextReleaseLeakMt/0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained -1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextReleaseLeakMt/1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -1 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -2 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -3 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -4 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -5 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -6 -[ERROR]: Attempting to release nonexistent handle {{[0-9xa-fA-F]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to -7 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained -7 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainReleaseLeakMt/0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} -[ RUN ] threadCountForValDeviceTest/valDeviceTestMultithreaded.testUrContextRetainReleaseLeakMt/1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to {{[1-9]+}} -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 0 -[ERROR]: Retained 1 reference(s) to handle {{[0-9xa-fA-F]+}} -[ERROR]: Handle {{[0-9xa-fA-F]+}} was recorded for first time here: -{{IGNORE}} diff --git a/unified-runtime/test/layers/validation/lifetime.cpp b/unified-runtime/test/layers/validation/lifetime.cpp index 767452e18216..785d31afddee 100644 --- a/unified-runtime/test/layers/validation/lifetime.cpp +++ b/unified-runtime/test/layers/validation/lifetime.cpp @@ -4,8 +4,12 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: %use-mock %validate lifetime-test | FileCheck %s + #include "fixtures.hpp" +// CHECK: [ RUN ] urTest.testUrAdapterHandleLifetimeExpectFail +// CHECK-NEXT: [ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} TEST_F(urTest, testUrAdapterHandleLifetimeExpectFail) { size_t size = 0; ur_adapter_handle_t adapter = (ur_adapter_handle_t)0xC0FFEE; @@ -13,12 +17,18 @@ TEST_F(urTest, testUrAdapterHandleLifetimeExpectFail) { urAdapterGetInfo(adapter, info_type, 0, nullptr, &size); } +// CHECK: [ RUN ] valAdapterTest.testUrAdapterHandleLifetimeExpectSuccess +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: {{^(?!.*There are no valid references to handle).*$}} TEST_F(valAdapterTest, testUrAdapterHandleLifetimeExpectSuccess) { size_t size = 0; ur_adapter_info_t info_type = UR_ADAPTER_INFO_BACKEND; urAdapterGetInfo(adapter, info_type, 0, nullptr, &size); } +// CHECK: [ RUN ] valAdapterTest.testUrAdapterHandleTypeMismatchExpectFail +// CHECK-NEXT: [DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 +// CHECK-NEXT: [ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} TEST_F(valAdapterTest, testUrAdapterHandleTypeMismatchExpectFail) { size_t size = 0; // Use valid adapter handle with incorrect cast. diff --git a/unified-runtime/test/layers/validation/lifetime.out.match b/unified-runtime/test/layers/validation/lifetime.out.match deleted file mode 100644 index f73bd71ba407..000000000000 --- a/unified-runtime/test/layers/validation/lifetime.out.match +++ /dev/null @@ -1,12 +0,0 @@ -{{IGNORE}} -[ RUN ] urTest.testUrAdapterHandleLifetimeExpectFail - [ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} -{{IGNORE}} -[ RUN ] valAdapterTest.testUrAdapterHandleLifetimeExpectSuccess -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -{{^(?!.*There are no valid references to handle).*$}} -{{IGNORE}} -[ RUN ] valAdapterTest.testUrAdapterHandleTypeMismatchExpectFail -[DEBUG]: Reference count for handle {{[0-9xa-fA-F]+}} changed to 1 -[ERROR]: There are no valid references to handle {{[0-9xa-fA-F]+}} -{{IGNORE}} diff --git a/unified-runtime/test/layers/validation/lit.local.cfg.py b/unified-runtime/test/layers/validation/lit.local.cfg.py new file mode 100644 index 000000000000..432878f1dd79 --- /dev/null +++ b/unified-runtime/test/layers/validation/lit.local.cfg.py @@ -0,0 +1,17 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +config.suffixes = [".cpp"] + +config.substitutions.append( + ( + r"%validate", + r"UR_ENABLE_LAYERS=UR_LAYER_FULL_VALIDATION UR_LOG_VALIDATION=level:debug\;flush:debug\;output:stdout", + ) +) diff --git a/unified-runtime/test/layers/validation/parameters.cpp b/unified-runtime/test/layers/validation/parameters.cpp index 19e024fca7a3..67324ad7b41d 100644 --- a/unified-runtime/test/layers/validation/parameters.cpp +++ b/unified-runtime/test/layers/validation/parameters.cpp @@ -4,6 +4,9 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// COM: This test doesn't have any filecheck rules +// RUN: %use-mock %validate parameters-test + #include "fixtures.hpp" TEST_F(valPlatformsTest, testUrPlatformGetApiVersion) { diff --git a/unified-runtime/test/lit.cfg.py b/unified-runtime/test/lit.cfg.py new file mode 100644 index 000000000000..43e4a469c022 --- /dev/null +++ b/unified-runtime/test/lit.cfg.py @@ -0,0 +1,96 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +import lit.formats +import re +import sys +from os import path + +# UR can be built as either a part of intel/llvm or standalone +# The ur_* configs will always refer to directories containing for UR +# The main_* configs will refer to the main cmake directories. If this is built as part of intel/llvm, these will be the +# intel/llvm directories. If built standalone, this will be equal to the ur_* directories. + +config.name = "Unified Runtime" +config.test_source_root = path.dirname(__file__) +config.test_exec_root = path.join(config.ur_obj_root, "test") + +# Default test configuration - unit tests (that use formats.GoogleTest) use a different test suite specified by +# lit.cfg.py (which does not inherit from this one) +config.test_format = lit.formats.ShTest(True) +config.suffixes = [".test"] + + +# This is similar to ToolSubst in LLVM, but much simpler +def word_match(key, subst): + regex = re.compile(rf"\b{key}\b") + return (regex, subst) + + +config.substitutions.append((r"%lib", config.main_lib_dir)) +config.substitutions.append((r"%binary-dir", config.ur_obj_root)) + +if sys.platform == "win32": + config.substitutions.append((r"%null", "NUL")) +else: + config.substitutions.append((r"%null", "/dev/null")) + +if sys.platform == "win32": + config.shlibext = ".dll" + config.shlibpre = "" + config.available_features.add("windows") +if sys.platform == "linux": + config.shlibext = ".so" + config.shlibpre = "lib" + config.available_features.add("linux") +if sys.platform == "darwin": + config.shlibext = ".dylib" + config.shlibpre = "lib" + +config.substitutions.append((r"%{shlibpre}", config.shlibpre)) +config.substitutions.append((r"%{shlibext}", config.shlibext)) + +# Each adapter provides a substitution like `%use-opencl` which expands to the appropriate "FORCE_LOAD" var +config.adapters = dict() +for a in config.adapters_built: + config.adapters[a] = path.join( + config.main_lib_dir, f"{config.shlibpre}ur_adapter_{a}{config.shlibext}" + ) + config.substitutions.append((f"%adapter-{a}".format(a), config.adapters[a])) + config.substitutions.append( + (f"%use-{a}".format(a), f"UR_ADAPTERS_FORCE_LOAD={config.adapters[a]}") + ) + config.available_features.add(f"adapter-{a}") + +config.substitutions.append(word_match("FileCheck", config.filecheck_path)) + + +# Ensure built binaries/libs are available on the path +def path_prepend(envvar, value): + oldvar = config.environment.get(envvar, "") + config.environment[envvar] = f"{value}{path.pathsep}{oldvar}" + + +path_prepend("PATH", ".") +path_prepend("PATH", path.join(config.ur_obj_root, "bin")) +if config.main_obj_root != config.ur_obj_root: + path_prepend("PATH", path.join(config.main_obj_root, "bin")) + +if sys.platform == "win32": + path_prepend("PATH", config.main_lib_dir) +else: + path_prepend("LD_LIBRARY_PATH", config.main_lib_dir) + +config.substitutions.append((r"%ur-version", config.ur_version)) +if config.fuzztesting_enabled: + config.available_features.add("fuzztesting") +if config.tracing_enabled: + config.available_features.add("tracing") +if config.sanitizer_enabled: + config.available_features.add("sanitizer") diff --git a/unified-runtime/test/lit.site.cfg.py.in b/unified-runtime/test/lit.site.cfg.py.in new file mode 100644 index 000000000000..114fbbddaf6e --- /dev/null +++ b/unified-runtime/test/lit.site.cfg.py.in @@ -0,0 +1,30 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +import lit.formats + +config.main_src_root = r"@CMAKE_SOURCE_DIR@" +config.main_obj_root = r"@CMAKE_BINARY_DIR@" +config.main_lib_dir = r"@CMAKE_LIBRARY_OUTPUT_DIRECTORY@" + +config.ur_src_root = r"@PROJECT_SOURCE_DIR@" +config.ur_obj_root = r"@PROJECT_BINARY_DIR@" + +config.filecheck_path = r"@URLIT_FILECHECK_BINARY@" + +config.ur_version = r"@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@" +config.fuzztesting_enabled = r"@UR_FUZZTESTING_ENABLED@" == "ON" +config.tracing_enabled = r"@UR_ENABLE_TRACING@" == "ON" +config.sanitizer_enabled = r"@UR_ENABLE_SANITIZER@" == "ON" + +config.adapters_built = [] +if r"@UR_ADAPTERS_LIST@": + config.adapters_built = r"@UR_ADAPTERS_LIST@".split(";") + +lit_config.load_config(config, os.path.join(config.ur_src_root, "test/lit.cfg.py")) diff --git a/unified-runtime/test/loader/CMakeLists.txt b/unified-runtime/test/loader/CMakeLists.txt index 3f1a06448b1a..20de8ae0b8ae 100644 --- a/unified-runtime/test/loader/CMakeLists.txt +++ b/unified-runtime/test/loader/CMakeLists.txt @@ -3,10 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_test(NAME example-hello-world COMMAND hello_world) -set_tests_properties(example-hello-world PROPERTIES LABELS "loader" - ENVIRONMENT "UR_ADAPTERS_FORCE_LOAD=\"$\"" -) +add_ur_lit_testsuite(loader DEPENDS ur_loader hello_world) add_subdirectory(adapter_registry) add_subdirectory(loader_config) diff --git a/unified-runtime/test/loader/adapter_registry/CMakeLists.txt b/unified-runtime/test/loader/adapter_registry/CMakeLists.txt index 6d80430e6cbf..8203b08c1d50 100644 --- a/unified-runtime/test/loader/adapter_registry/CMakeLists.txt +++ b/unified-runtime/test/loader/adapter_registry/CMakeLists.txt @@ -4,11 +4,8 @@ # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception function(add_adapter_reg_search_test name) - cmake_parse_arguments(TEST "" "" "SEARCH_PATH;ENVS;SOURCES" ${ARGN}) - - set(TEST_TARGET_NAME adapter-reg-test-${name}) - add_ur_executable(${TEST_TARGET_NAME} - ${TEST_SOURCES}) + set(TEST_TARGET_NAME ${name}-test) + add_gtest_test(${name} ${TEST_SOURCES}) if(WIN32) target_sources(${TEST_TARGET_NAME} PRIVATE @@ -18,40 +15,11 @@ function(add_adapter_reg_search_test name) ${PROJECT_SOURCE_DIR}/source/loader/linux/adapter_search.cpp) endif() - target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::common - GTest::gtest_main) - target_include_directories(${TEST_TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/source/loader) - - add_test(NAME adapter-reg-${name} - COMMAND ${TEST_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - set_tests_properties(adapter-reg-${name} PROPERTIES LABELS "adapter-reg") - set_property(TEST adapter-reg-${name} PROPERTY - ENVIRONMENT "UR_ADAPTERS_SEARCH_PATH=\"${TEST_SEARCH_PATH}\"" ${TEST_ENVS}) endfunction() -set(TEST_SEARCH_PATH ${PROJECT_SOURCE_DIR}) -set(TEST_BIN_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) -add_adapter_reg_search_test(search-with-env - SEARCH_PATH ${TEST_SEARCH_PATH} - ENVS "TEST_ADAPTER_SEARCH_PATH=\"${TEST_SEARCH_PATH}\"" "TEST_CUR_SEARCH_PATH=\"${TEST_BIN_PATH}\"" - SOURCES search_with_env.cpp) - -add_adapter_reg_search_test(search-no-env - SEARCH_PATH "" - ENVS "TEST_ADAPTER_SEARCH_PATH=\"\"" "TEST_CUR_SEARCH_PATH=\"${TEST_BIN_PATH}\"" - SOURCES search_no_env.cpp) - -add_adapter_reg_search_test(search-order - SEARCH_PATH ${TEST_SEARCH_PATH} - ENVS "TEST_ADAPTER_SEARCH_PATH=\"${TEST_SEARCH_PATH}\"" "TEST_CUR_SEARCH_PATH=\"${TEST_BIN_PATH}\"" - SOURCES search_order.cpp) - -add_adapter_reg_search_test(prefilter - SEARCH_PATH "" - SOURCES prefilter.cpp) +add_adapter_reg_search_test(search-with-env) +add_adapter_reg_search_test(search-no-env) +add_adapter_reg_search_test(search-order) +add_adapter_reg_search_test(prefilter) diff --git a/unified-runtime/test/loader/adapter_registry/lit.local.cfg.py b/unified-runtime/test/loader/adapter_registry/lit.local.cfg.py new file mode 100644 index 000000000000..44f02ecdd6b8 --- /dev/null +++ b/unified-runtime/test/loader/adapter_registry/lit.local.cfg.py @@ -0,0 +1,16 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +from os import path + +config.suffixes = [".cpp"] + +config.substitutions.append( + (r"%cwd", path.join(config.test_exec_root, "loader", "adapter_registry")) +) diff --git a/unified-runtime/test/loader/adapter_registry/prefilter.cpp b/unified-runtime/test/loader/adapter_registry/prefilter.cpp index 5b8ebd4740e1..3d50647c0a49 100644 --- a/unified-runtime/test/loader/adapter_registry/prefilter.cpp +++ b/unified-runtime/test/loader/adapter_registry/prefilter.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: UR_ADAPTERS_SEARCH_PATH="" prefilter-test + #include "fixtures.hpp" #ifndef _WIN32 diff --git a/unified-runtime/test/loader/adapter_registry/search_no_env.cpp b/unified-runtime/test/loader/adapter_registry/search_no_env.cpp index 8a1501f1c6b0..413351697128 100644 --- a/unified-runtime/test/loader/adapter_registry/search_no_env.cpp +++ b/unified-runtime/test/loader/adapter_registry/search_no_env.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: UR_ADAPTERS_SEARCH_PATH="" TEST_ADAPTER_SEARCH_PATH="" TEST_CUR_SEARCH_PATH="%cwd" search-no-env-test + #include "fixtures.hpp" TEST_F(adapterRegSearchTest, testSearchNoEnv) { diff --git a/unified-runtime/test/loader/adapter_registry/search_order.cpp b/unified-runtime/test/loader/adapter_registry/search_order.cpp index cad9391de5e6..b334955d333e 100644 --- a/unified-runtime/test/loader/adapter_registry/search_order.cpp +++ b/unified-runtime/test/loader/adapter_registry/search_order.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: UR_ADAPTERS_SEARCH_PATH="%binary-dir" TEST_ADAPTER_SEARCH_PATH="%binary-dir" TEST_CUR_SEARCH_PATH="%cwd" search-order-test + #include "fixtures.hpp" template diff --git a/unified-runtime/test/loader/adapter_registry/search_with_env.cpp b/unified-runtime/test/loader/adapter_registry/search_with_env.cpp index ec40440eaf9f..db72d9e8f3ef 100644 --- a/unified-runtime/test/loader/adapter_registry/search_with_env.cpp +++ b/unified-runtime/test/loader/adapter_registry/search_with_env.cpp @@ -4,6 +4,8 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: UR_ADAPTERS_SEARCH_PATH="%binary-dir" TEST_ADAPTER_SEARCH_PATH="%binary-dir" TEST_CUR_SEARCH_PATH="%cwd" search-with-env-test + #include "fixtures.hpp" TEST_F(adapterRegSearchTest, testSearchWithEnv) { diff --git a/unified-runtime/test/loader/handles/CMakeLists.txt b/unified-runtime/test/loader/handles/CMakeLists.txt index 2504c92baef5..feb9f86141ca 100644 --- a/unified-runtime/test/loader/handles/CMakeLists.txt +++ b/unified-runtime/test/loader/handles/CMakeLists.txt @@ -3,26 +3,4 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_executable(test-loader-handles - urLoaderHandles.cpp -) - -target_link_libraries(test-loader-handles - PRIVATE - ${PROJECT_NAME}::common - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::loader - ${PROJECT_NAME}::mock - gmock - GTest::gtest_main -) - -add_test(NAME loader-handles - COMMAND test-loader-handles - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) - -set_tests_properties(loader-handles PROPERTIES - LABELS "loader" - ENVIRONMENT "UR_ENABLE_LOADER_INTERCEPT=1;UR_ADAPTERS_FORCE_LOAD=\"$\"" -) +add_gtest_test(loader-handles urLoaderHandles.cpp) diff --git a/unified-runtime/test/loader/handles/handles.test b/unified-runtime/test/loader/handles/handles.test new file mode 100644 index 000000000000..1d67898f6104 --- /dev/null +++ b/unified-runtime/test/loader/handles/handles.test @@ -0,0 +1 @@ +RUN: UR_ENABLE_LOADER_INTERCEPT=1 %use-mock loader-handles-test diff --git a/unified-runtime/test/loader/hello_world.test b/unified-runtime/test/loader/hello_world.test new file mode 100644 index 000000000000..233e26ec8573 --- /dev/null +++ b/unified-runtime/test/loader/hello_world.test @@ -0,0 +1 @@ +RUN: %use-mock hello_world diff --git a/unified-runtime/test/loader/loader_config/CMakeLists.txt b/unified-runtime/test/loader/loader_config/CMakeLists.txt index 9a1c306a5817..9920a8a3c0f4 100644 --- a/unified-runtime/test/loader/loader_config/CMakeLists.txt +++ b/unified-runtime/test/loader/loader_config/CMakeLists.txt @@ -3,7 +3,7 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_ur_executable(test-loader-config +add_gtest_test(loader-config urLoaderConfigCreate.cpp urLoaderConfigGetInfo.cpp urLoaderConfigEnableLayer.cpp @@ -11,17 +11,3 @@ add_ur_executable(test-loader-config urLoaderConfigRetain.cpp urLoaderConfigSetCodeLocationCallback.cpp ) - -target_link_libraries(test-loader-config - PRIVATE - ${PROJECT_NAME}::common - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::loader - gmock - GTest::gtest_main -) - -add_test(NAME loader-config - COMMAND test-loader-config - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) diff --git a/unified-runtime/test/loader/loader_config/loader_config.test b/unified-runtime/test/loader/loader_config/loader_config.test new file mode 100644 index 000000000000..3eec7f03c178 --- /dev/null +++ b/unified-runtime/test/loader/loader_config/loader_config.test @@ -0,0 +1 @@ +RUN: loader-config-test diff --git a/unified-runtime/test/loader/loader_lifetime/CMakeLists.txt b/unified-runtime/test/loader/loader_lifetime/CMakeLists.txt index 3f8c7f9519a8..815b5cf6f43d 100644 --- a/unified-runtime/test/loader/loader_lifetime/CMakeLists.txt +++ b/unified-runtime/test/loader/loader_lifetime/CMakeLists.txt @@ -3,22 +3,8 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_executable(test-loader-lifetime +add_gtest_test(loader-lifetime urLoaderInit.cpp urLoaderTearDown.cpp mixed.cpp ) - -target_link_libraries(test-loader-lifetime - PRIVATE - ${PROJECT_NAME}::common - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::loader - gmock - GTest::gtest_main -) - -add_test(NAME loader-lifetime - COMMAND test-loader-lifetime - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} -) diff --git a/unified-runtime/test/loader/loader_lifetime/loader_lifetime.test b/unified-runtime/test/loader/loader_lifetime/loader_lifetime.test new file mode 100644 index 000000000000..dbe0e79b484b --- /dev/null +++ b/unified-runtime/test/loader/loader_lifetime/loader_lifetime.test @@ -0,0 +1 @@ +RUN: loader-lifetime-test diff --git a/unified-runtime/test/loader/platforms/CMakeLists.txt b/unified-runtime/test/loader/platforms/CMakeLists.txt index 752231be99b0..6aae274b4d00 100644 --- a/unified-runtime/test/loader/platforms/CMakeLists.txt +++ b/unified-runtime/test/loader/platforms/CMakeLists.txt @@ -3,35 +3,4 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_ur_executable(test-loader-platforms - platforms.cpp -) - -target_link_libraries(test-loader-platforms - PRIVATE - ${PROJECT_NAME}::common - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::loader - gmock - GTest::gtest_main - unit_tests_helpers -) - -function(add_loader_platform_test name ENV) - set(TEST_NAME loader_platform_test_${name}) - add_test(NAME ${TEST_NAME} - COMMAND ${CMAKE_COMMAND} - -D TEST_FILE=$ - -D MODE=stdout - -D MATCH_FILE=${CMAKE_CURRENT_SOURCE_DIR}/${name}.match - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake - ) - set_tests_properties(${TEST_NAME} PROPERTIES - LABELS "loader" - ENVIRONMENT "${ENV};UR_LOG_TEST=level:info\;output:stdout\;flush:debug" - ) -endfunction() - -# Disabling the force load due to issues with the test on windows. -#add_loader_platform_test(no_platforms "UR_ADAPTERS_FORCE_LOAD=\"\"") -add_loader_platform_test(null_platform "UR_ADAPTERS_FORCE_LOAD=\"$\"") +add_gtest_test(platforms platforms.cpp) diff --git a/unified-runtime/test/loader/platforms/no_platforms.match b/unified-runtime/test/loader/platforms/no_platforms.match deleted file mode 100644 index b695672e4d39..000000000000 --- a/unified-runtime/test/loader/platforms/no_platforms.match +++ /dev/null @@ -1,2 +0,0 @@ -[INFO]: urLoaderInit succeeded. -[INFO]: urPlatformGet found 0 platforms diff --git a/unified-runtime/test/loader/platforms/no_platforms.test b/unified-runtime/test/loader/platforms/no_platforms.test new file mode 100644 index 000000000000..a169805bfaae --- /dev/null +++ b/unified-runtime/test/loader/platforms/no_platforms.test @@ -0,0 +1,6 @@ +RUN: UR_ADAPTERS_FORCE_LOAD="" UR_LOG_TEST="level:info;output:stdout;flush:debug" platforms-test + +REQUIRES: linux + +CHECK: [INFO]: urLoaderInit succeeded. +CHECK: [INFO]: urPlatformGet found 0 platforms diff --git a/unified-runtime/test/loader/platforms/null_platform.match b/unified-runtime/test/loader/platforms/null_platform.match deleted file mode 100644 index 95174348aced..000000000000 --- a/unified-runtime/test/loader/platforms/null_platform.match +++ /dev/null @@ -1,3 +0,0 @@ -[INFO]: urLoaderInit succeeded. -[INFO]: urPlatformGet found 1 platforms -[INFO]: Found Mock Platform diff --git a/unified-runtime/test/loader/platforms/null_platform.test b/unified-runtime/test/loader/platforms/null_platform.test new file mode 100644 index 000000000000..5f3830c365e7 --- /dev/null +++ b/unified-runtime/test/loader/platforms/null_platform.test @@ -0,0 +1,5 @@ +RUN: UR_LOG_TEST="level:info;output:stdout;flush:debug" %use-mock platforms-test + +CHECK: [INFO]: urLoaderInit succeeded. +CHECK: [INFO]: urPlatformGet found 1 platforms +CHECK: [INFO]: Found Mock Platform diff --git a/unified-runtime/test/unit/utils/CMakeLists.txt b/unified-runtime/test/logger/CMakeLists.txt similarity index 57% rename from unified-runtime/test/unit/utils/CMakeLists.txt rename to unified-runtime/test/logger/CMakeLists.txt index 62681b1032e7..d9f650c3a500 100644 --- a/unified-runtime/test/unit/utils/CMakeLists.txt +++ b/unified-runtime/test/logger/CMakeLists.txt @@ -3,16 +3,5 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_unit_test(getenv - getenv.cpp -) - -add_unit_test(params - params.cpp -) - -add_unit_test(print - print.cpp) - -add_unit_test(helpers - helpers.cpp) +add_ur_lit_testsuite(logger) +add_gtest_test(logger env_var.cpp) diff --git a/unified-runtime/test/unit/logger/env_var.cpp b/unified-runtime/test/logger/env_var.cpp similarity index 100% rename from unified-runtime/test/unit/logger/env_var.cpp rename to unified-runtime/test/logger/env_var.cpp diff --git a/unified-runtime/test/unit/logger/fixtures.hpp b/unified-runtime/test/logger/fixtures.hpp similarity index 100% rename from unified-runtime/test/unit/logger/fixtures.hpp rename to unified-runtime/test/logger/fixtures.hpp diff --git a/unified-runtime/test/logger/level-debug.test b/unified-runtime/test/logger/level-debug.test new file mode 100644 index 000000000000..69618ac9a912 --- /dev/null +++ b/unified-runtime/test/logger/level-debug.test @@ -0,0 +1,16 @@ +RUN: UR_LOG_ADAPTER_TEST="level:debug" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:debug;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:debug;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:debug;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:debug;level:debug;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +CHECK: [DEBUG]: Test message: success +CHECK: [INFO]: Test message: success +CHECK: [WARNING]: Test message: success +CHECK: [ERROR]: Test message: success diff --git a/unified-runtime/test/logger/level-error.test b/unified-runtime/test/logger/level-error.test new file mode 100644 index 000000000000..4d9865c89670 --- /dev/null +++ b/unified-runtime/test/logger/level-error.test @@ -0,0 +1,16 @@ +RUN: UR_LOG_ADAPTER_TEST="level:error" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:error;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:error;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:error;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:error;level:error;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +CHECK-NOT: [DEBUG]: Test message: success +CHECK-NOT: [INFO]: Test message: success +CHECK-NOT: [WARNING]: Test message: success +CHECK: [ERROR]: Test message: success diff --git a/unified-runtime/test/logger/level-info.test b/unified-runtime/test/logger/level-info.test new file mode 100644 index 000000000000..727089b5f1ba --- /dev/null +++ b/unified-runtime/test/logger/level-info.test @@ -0,0 +1,16 @@ +RUN: UR_LOG_ADAPTER_TEST="level:info" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:info;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:info;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:info;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:info;level:info;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +CHECK-NOT: [DEBUG]: Test message: success +CHECK: [INFO]: Test message: success +CHECK: [WARNING]: Test message: success +CHECK: [ERROR]: Test message: success diff --git a/unified-runtime/test/logger/level-none.test b/unified-runtime/test/logger/level-none.test new file mode 100644 index 000000000000..39b7aee466cf --- /dev/null +++ b/unified-runtime/test/logger/level-none.test @@ -0,0 +1,16 @@ +RUN: UR_LOG_ADAPTER_TEST="" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="output:stdout" logger-test | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="output:stderr" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="output:file,%t" logger-test +RUN: FileCheck --allow-empty --input-file %t %s + +RUN: UR_LOG_ADAPTER_TEST="" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="output:stdout" logger-test | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="output:stderr" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="output:file,%t" logger-test +RUN: FileCheck --allow-empty --input-file %t %s + +CHECK-NOT: [DEBUG]: Test message: success +CHECK-NOT: [INFO]: Test message: success +CHECK-NOT: [WARNING]: Test message: success +CHECK-NOT: [ERROR]: Test message: success diff --git a/unified-runtime/test/logger/level-warning.test b/unified-runtime/test/logger/level-warning.test new file mode 100644 index 000000000000..5ada341acc06 --- /dev/null +++ b/unified-runtime/test/logger/level-warning.test @@ -0,0 +1,16 @@ +RUN: UR_LOG_ADAPTER_TEST="level:warning" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:warning;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:warning;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="level:warning;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning;output:stdout" logger-test | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning;output:stderr" logger-test 2>&1 1>%null | FileCheck %s +RUN: UR_LOG_ADAPTER_TEST="flush:warning;level:warning;output:file,%t" logger-test +RUN: FileCheck --input-file %t %s + +CHECK-NOT: [DEBUG]: Test message: success +CHECK-NOT: [INFO]: Test message: success +CHECK: [WARNING]: Test message: success +CHECK: [ERROR]: Test message: success diff --git a/unified-runtime/test/logger/validation.test b/unified-runtime/test/logger/validation.test new file mode 100644 index 000000000000..1431ade9c664 --- /dev/null +++ b/unified-runtime/test/logger/validation.test @@ -0,0 +1,23 @@ +COM: Multiple levels +RUN: UR_LOG_ADAPTER_TEST="level:error;level:debug" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="level:error;flush:debug;flush:error" logger-test 2>&1 1>%null | FileCheck --allow-empty %s + +COM: Invalid param +RUN: UR_LOG_ADAPTER_TEST=";;;;;;,,,,;;;" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="asdfasdf" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="invalid:value" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="level:invalid" logger-test 2>&1 1>%null | FileCheck --allow-empty %s + +COM: Invalid output +RUN: UR_LOG_ADAPTER_TEST="level:error;output:invalid" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="level:error;output:file" logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="level:error;output:file," logger-test 2>&1 1>%null | FileCheck --allow-empty %s +RUN: UR_LOG_ADAPTER_TEST="level:error;output:stdout,%t" logger-test 2>&1 1>%null | FileCheck --allow-empty %s + +COM: Non-existant output file +RUN: UR_LOG_ADAPTER_TEST="level:error;output:file,/invalid/path" logger-test 2>&1 1>%null | FileCheck --allow-empty %s + +CHECK-NOT: [DEBUG]: Test message: success +CHECK-NOT: [INFO]: Test message: success +CHECK-NOT: [WARNING]: Test message: success +CHECK-NOT: [ERROR]: Test message: success diff --git a/unified-runtime/test/mock/CMakeLists.txt b/unified-runtime/test/mock/CMakeLists.txt deleted file mode 100644 index 59b099505bd1..000000000000 --- a/unified-runtime/test/mock/CMakeLists.txt +++ /dev/null @@ -1,21 +0,0 @@ -# Copyright (C) 2024 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -set(MOCK_TEST_NAME test-mock) - -add_ur_executable(${MOCK_TEST_NAME} mock.cpp) -target_link_libraries(${MOCK_TEST_NAME} - PRIVATE - ${PROJECT_NAME}::loader - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::testing - ${PROJECT_NAME}::mock - GTest::gtest_main) - -add_test(NAME ${MOCK_TEST_NAME} - COMMAND ${MOCK_TEST_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - -set_tests_properties(${MOCK_TEST_NAME} PROPERTIES LABELS "mock") diff --git a/unified-runtime/test/tools/urtrace/CMakeLists.txt b/unified-runtime/test/tools/urtrace/CMakeLists.txt index a16f369c2944..85e5944d1ebb 100644 --- a/unified-runtime/test/tools/urtrace/CMakeLists.txt +++ b/unified-runtime/test/tools/urtrace/CMakeLists.txt @@ -3,29 +3,4 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -set(TEST_NAME trace-hello-world) - -function(add_trace_test name CLI_ARGS) - set(TEST_NAME trace_test_${name}) - configure_file( - ${CMAKE_CURRENT_SOURCE_DIR}/${name}.match - ${CMAKE_CURRENT_BINARY_DIR}/${name}.match - @ONLY - ) - add_test(NAME ${TEST_NAME} - COMMAND ${CMAKE_COMMAND} - -D TEST_FILE=${Python3_EXECUTABLE} - -D TEST_ARGS="${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/urtrace --stdout ${CLI_ARGS} --flush info $" - -D MODE=stdout - -D MATCH_FILE=${CMAKE_CURRENT_BINARY_DIR}/${name}.match - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake - ) - set_tests_properties(${TEST_NAME} PROPERTIES LABELS "urtrace") -endfunction() - -add_trace_test(mock_hello "--libpath $ --mock") -add_trace_test(mock_hello_no_args "--libpath $ --mock --no-args") -add_trace_test(mock_hello_filter_device "--libpath $ --mock --filter \".*Device.*\"") -add_trace_test(mock_hello_profiling "--libpath $ --mock --profiling --time-unit ns") -add_trace_test(mock_hello_begin "--libpath $ --mock --print-begin") -add_trace_test(mock_hello_json "--libpath $ --mock --json") +add_ur_lit_testsuite(urtrace DEPENDS hello_world ur_trace_cli ur_collector xptifw) diff --git a/unified-runtime/test/tools/urtrace/begin.test b/unified-runtime/test/tools/urtrace/begin.test new file mode 100644 index 000000000000..40435319c07d --- /dev/null +++ b/unified-runtime/test/tools/urtrace/begin.test @@ -0,0 +1,27 @@ +RUN: %trace --print-begin hello_world | FileCheck %s -DVER=%ur-version + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK-NEXT: begin(1) - urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (0)); +CHECK-NEXT: end(1) - urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(2) - urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr); +CHECK-NEXT: end(2) - urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(3) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 0, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (0)); +CHECK-NEXT: end(3) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 0, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(4) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = {{.*}} (1)); +CHECK-NEXT: end(4) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(5) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.0)); +CHECK-NEXT: end(5) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ([[VER]])) -> UR_RESULT_SUCCESS; +CHECK-NEXT: API version: {{.*}} +CHECK-NEXT: begin(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (0)); +CHECK-NEXT: end(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {nullptr}, .pNumDevices = nullptr); +CHECK-NEXT: end(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); +CHECK-NEXT: end(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: begin(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); +CHECK-NEXT: end(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: Found a Mock Device gpu. +CHECK-NEXT: begin(10) - urAdapterRelease(.hAdapter = {{.*}}); +CHECK-NEXT: end(10) - urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/tools/urtrace/default.test b/unified-runtime/test/tools/urtrace/default.test new file mode 100644 index 000000000000..e3907f782d35 --- /dev/null +++ b/unified-runtime/test/tools/urtrace/default.test @@ -0,0 +1,17 @@ +RUN: %trace hello_world | FileCheck %s + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK-NEXT: urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 0, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; +CHECK-NEXT: API version: {{.*}} +CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: Found a Mock Device gpu. +CHECK-NEXT: urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/tools/urtrace/filter_device.test b/unified-runtime/test/tools/urtrace/filter_device.test new file mode 100644 index 000000000000..7ff911667a49 --- /dev/null +++ b/unified-runtime/test/tools/urtrace/filter_device.test @@ -0,0 +1,11 @@ +RUN: %trace --filter ".*Device.*" hello_world | FileCheck %s + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK-NEXT: API version: {{.*}} +CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; +CHECK-NEXT: Found a Mock Device gpu. diff --git a/unified-runtime/test/tools/urtrace/json.test b/unified-runtime/test/tools/urtrace/json.test new file mode 100644 index 000000000000..476d2a15ba24 --- /dev/null +++ b/unified-runtime/test/tools/urtrace/json.test @@ -0,0 +1,22 @@ +RUN: %trace --json hello_world | FileCheck %s -DVER=%ur-version + +REQUIRES: tracing + +CHECK: { +CHECK-NEXT: "traceEvents": [ +CHECK-NEXT: Platform initialized. +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1))" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr)" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.hAdapter = {{.*}}, .NumEntries = 0, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1))" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = {{.*}} (1))" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGetApiVersion", "args": "(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.12))" }, +CHECK-NEXT: API version: [[VER]] +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGet", "args": "(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1))" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGet", "args": "(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr)" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}} (UR_DEVICE_TYPE_GPU), .pPropSizeRet = nullptr)" }, +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}} (Mock Device), .pPropSizeRet = nullptr)" }, +CHECK-NEXT: Found a Mock Device gpu. +CHECK-NEXT: { "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterRelease", "args": "(.hAdapter = {{.*}})" }, +CHECK-NEXT: {"name": "", "cat": "", "ph": "", "pid": "", "tid": "", "ts": ""} +CHECK-NEXT: ] +CHECK-NEXT: } diff --git a/unified-runtime/test/tools/urtrace/lit.local.cfg.py b/unified-runtime/test/tools/urtrace/lit.local.cfg.py new file mode 100644 index 000000000000..2795d9bfca52 --- /dev/null +++ b/unified-runtime/test/tools/urtrace/lit.local.cfg.py @@ -0,0 +1,15 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +config.substitutions.append( + ( + r"%trace", + f"urtrace --stdout --flush info --mock --libpath {config.main_lib_dir}", + ) +) diff --git a/unified-runtime/test/tools/urtrace/mock_hello.match b/unified-runtime/test/tools/urtrace/mock_hello.match deleted file mode 100644 index f47da33648a2..000000000000 --- a/unified-runtime/test/tools/urtrace/mock_hello.match +++ /dev/null @@ -1,13 +0,0 @@ -Platform initialized. -urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; -urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; -urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; -urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; -urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; -API version: {{.*}} -urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; -urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; -urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -Found a Mock Device gpu. -urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/tools/urtrace/mock_hello_begin.match b/unified-runtime/test/tools/urtrace/mock_hello_begin.match deleted file mode 100644 index 536d9561c95b..000000000000 --- a/unified-runtime/test/tools/urtrace/mock_hello_begin.match +++ /dev/null @@ -1,23 +0,0 @@ -Platform initialized. -begin(1) - urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (0)); -end(1) - urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(2) - urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr); -end(2) - urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; -begin(3) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (0)); -end(3) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(4) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {nullptr}, .pNumPlatforms = nullptr); -end(4) - urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; -begin(5) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.0)); -end(5) - urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} (@PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@)) -> UR_RESULT_SUCCESS; -API version: {{.*}} -begin(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (0)); -end(6) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; -begin(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {nullptr}, .pNumDevices = nullptr); -end(7) - urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; -begin(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); -end(8) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -begin(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr); -end(9) - urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -Found a Mock Device gpu. -begin(10) - urAdapterRelease(.hAdapter = {{.*}}); -end(10) - urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/tools/urtrace/mock_hello_filter_device.match b/unified-runtime/test/tools/urtrace/mock_hello_filter_device.match deleted file mode 100644 index fde5d03b627d..000000000000 --- a/unified-runtime/test/tools/urtrace/mock_hello_filter_device.match +++ /dev/null @@ -1,7 +0,0 @@ -Platform initialized. -API version: {{.*}} -urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; -urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; -urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; -Found a Mock Device gpu. diff --git a/unified-runtime/test/tools/urtrace/mock_hello_json.match b/unified-runtime/test/tools/urtrace/mock_hello_json.match deleted file mode 100644 index eb6d61a854f0..000000000000 --- a/unified-runtime/test/tools/urtrace/mock_hello_json.match +++ /dev/null @@ -1,18 +0,0 @@ -{ - "traceEvents": [ -Platform initialized. -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1))" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterGet", "args": "(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr)" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.phAdapters = {{.*}} {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1))" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGet", "args": "(.phAdapters = {{.*}} {{{.*}}}, .NumAdapters = 1, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = nullptr)" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urPlatformGetApiVersion", "args": "(.hPlatform = {{.*}}, .pVersion = {{.*}} (0.12))" }, -API version: @PROJECT_VERSION_MAJOR@.@PROJECT_VERSION_MINOR@ -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGet", "args": "(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1))" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGet", "args": "(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr)" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = 4, .pPropValue = {{.*}} (UR_DEVICE_TYPE_GPU), .pPropSizeRet = nullptr)" }, -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urDeviceGetInfo", "args": "(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = 1023, .pPropValue = {{.*}} (Mock Device), .pPropSizeRet = nullptr)" }, -Found a Mock Device gpu. -{ "cat": "UR", "ph": "X", "pid": {{.*}}, "tid": {{.*}}, "ts": {{.*}}, "dur": {{.*}}, "name": "urAdapterRelease", "args": "(.hAdapter = {{.*}})" }, -{"name": "", "cat": "", "ph": "", "pid": "", "tid": "", "ts": ""} -] -} diff --git a/unified-runtime/test/tools/urtrace/mock_hello_no_args.match b/unified-runtime/test/tools/urtrace/mock_hello_no_args.match deleted file mode 100644 index a36fca577fd0..000000000000 --- a/unified-runtime/test/tools/urtrace/mock_hello_no_args.match +++ /dev/null @@ -1,13 +0,0 @@ -Platform initialized. -urAdapterGet(...) -> UR_RESULT_SUCCESS; -urAdapterGet(...) -> UR_RESULT_SUCCESS; -urPlatformGet(...) -> UR_RESULT_SUCCESS; -urPlatformGet(...) -> UR_RESULT_SUCCESS; -urPlatformGetApiVersion(...) -> UR_RESULT_SUCCESS; -API version: {{.*}} -urDeviceGet(...) -> UR_RESULT_SUCCESS; -urDeviceGet(...) -> UR_RESULT_SUCCESS; -urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; -urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; -Found a Mock Device gpu. -urAdapterRelease(...) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/tools/urtrace/mock_hello_profiling.match b/unified-runtime/test/tools/urtrace/mock_hello_profiling.match deleted file mode 100644 index 0ebfd67955b5..000000000000 --- a/unified-runtime/test/tools/urtrace/mock_hello_profiling.match +++ /dev/null @@ -1,13 +0,0 @@ -Platform initialized. -urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -API version: {{.*}} -urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) -Found a Mock Device gpu. -urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) diff --git a/unified-runtime/test/tools/urtrace/no_args.test b/unified-runtime/test/tools/urtrace/no_args.test new file mode 100644 index 000000000000..54ebe5673627 --- /dev/null +++ b/unified-runtime/test/tools/urtrace/no_args.test @@ -0,0 +1,17 @@ +RUN: %trace --no-args hello_world | FileCheck %s + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK-NEXT: urAdapterGet(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urAdapterGet(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urPlatformGet(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urPlatformGet(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urPlatformGetApiVersion(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: API version: {{.*}} +CHECK-NEXT: urDeviceGet(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGet(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: urDeviceGetInfo(...) -> UR_RESULT_SUCCESS; +CHECK-NEXT: Found a Mock Device gpu. +CHECK-NEXT: urAdapterRelease(...) -> UR_RESULT_SUCCESS; diff --git a/unified-runtime/test/tools/urtrace/profiling.test b/unified-runtime/test/tools/urtrace/profiling.test new file mode 100644 index 000000000000..fcd0ac1b3fc5 --- /dev/null +++ b/unified-runtime/test/tools/urtrace/profiling.test @@ -0,0 +1,17 @@ +RUN: %trace --profiling --time-unit ns hello_world | FileCheck %s + +REQUIRES: tracing + +CHECK: Platform initialized. +CHECK-NEXT: urAdapterGet(.NumEntries = 0, .phAdapters = nullptr, .pNumAdapters = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urAdapterGet(.NumEntries = 1, .phAdapters = {{.*}} {{{.*}}}, .pNumAdapters = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 0, .phPlatforms = nullptr, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urPlatformGet(.hAdapter = {{.*}}, .NumEntries = 1, .phPlatforms = {{.*}} {{{.*}}}, .pNumPlatforms = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urPlatformGetApiVersion(.hPlatform = {{.*}}, .pVersion = {{.*}} ({{.*}})) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: API version: {{.*}} +CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 0, .phDevices = nullptr, .pNumDevices = {{.*}} (1)) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urDeviceGet(.hPlatform = {{.*}}, .DeviceType = UR_DEVICE_TYPE_GPU, .NumEntries = 1, .phDevices = {{.*}} {{{.*}}}, .pNumDevices = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_TYPE, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: urDeviceGetInfo(.hDevice = {{.*}}, .propName = UR_DEVICE_INFO_NAME, .propSize = {{.*}}, .pPropValue = {{.*}}, .pPropSizeRet = nullptr) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) +CHECK-NEXT: Found a Mock Device gpu. +CHECK-NEXT: urAdapterRelease(.hAdapter = {{.*}}) -> UR_RESULT_SUCCESS; ({{[0-9]+}}ns) diff --git a/unified-runtime/test/unit/CMakeLists.txt b/unified-runtime/test/unit/CMakeLists.txt index fccfed1956c6..89f1e0103010 100644 --- a/unified-runtime/test/unit/CMakeLists.txt +++ b/unified-runtime/test/unit/CMakeLists.txt @@ -3,33 +3,9 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -add_library(unit_tests_helpers INTERFACE) - -target_include_directories(unit_tests_helpers INTERFACE - ${CMAKE_CURRENT_SOURCE_DIR} -) - -function(add_unit_test name) - set(TEST_TARGET_NAME test-${name}) - - add_ur_executable(${TEST_TARGET_NAME} - ${ARGN} - ) - target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::common - ${PROJECT_NAME}::headers - ${PROJECT_NAME}::loader - gmock - GTest::gtest_main - unit_tests_helpers - ) - add_test(NAME unit-${name} - COMMAND ${TEST_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} - ) - set_tests_properties(unit-${name} PROPERTIES LABELS "unit") -endfunction() - -add_subdirectory(utils) -add_subdirectory(logger) +add_ur_lit_testsuite(unit) +add_gtest_test(getenv getenv.cpp) +add_gtest_test(params params.cpp) +add_gtest_test(print print.cpp) +add_gtest_test(helpers helpers.cpp) +add_gtest_test(mock mock.cpp) diff --git a/unified-runtime/test/unit/utils/getenv.cpp b/unified-runtime/test/unit/getenv.cpp similarity index 100% rename from unified-runtime/test/unit/utils/getenv.cpp rename to unified-runtime/test/unit/getenv.cpp diff --git a/unified-runtime/test/unit/utils/helpers.cpp b/unified-runtime/test/unit/helpers.cpp similarity index 100% rename from unified-runtime/test/unit/utils/helpers.cpp rename to unified-runtime/test/unit/helpers.cpp diff --git a/unified-runtime/test/unit/lit.cfg.py b/unified-runtime/test/unit/lit.cfg.py new file mode 100644 index 000000000000..434a7f79c7f5 --- /dev/null +++ b/unified-runtime/test/unit/lit.cfg.py @@ -0,0 +1,16 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +import lit.formats +from os import path + +config.name = "Unified Runtime Unit" +config.test_format = lit.formats.GoogleTest(".", "-test") +config.test_source_root = config.binary_dir +config.test_exec_root = config.binary_dir diff --git a/unified-runtime/test/unit/lit.site.cfg.py.in b/unified-runtime/test/unit/lit.site.cfg.py.in new file mode 100644 index 000000000000..df980e9caa4b --- /dev/null +++ b/unified-runtime/test/unit/lit.site.cfg.py.in @@ -0,0 +1,3 @@ +config.binary_dir = "@CMAKE_CURRENT_BINARY_DIR@" + +lit_config.load_config(config, "@CMAKE_CURRENT_SOURCE_DIR@/lit.cfg.py") diff --git a/unified-runtime/test/unit/logger/logger.cpp b/unified-runtime/test/unit/logger.cpp similarity index 99% rename from unified-runtime/test/unit/logger/logger.cpp rename to unified-runtime/test/unit/logger.cpp index 495a13e1e349..bbeacaa845af 100644 --- a/unified-runtime/test/unit/logger/logger.cpp +++ b/unified-runtime/test/unit/logger.cpp @@ -8,7 +8,7 @@ #include #include -#include "fixtures.hpp" +#include "../fixtures.hpp" #include "logger/ur_logger_details.hpp" ////////////////////////////////////////////////////////////////////////////// diff --git a/unified-runtime/test/unit/logger/CMakeLists.txt b/unified-runtime/test/unit/logger/CMakeLists.txt deleted file mode 100644 index 86e5859a22fa..000000000000 --- a/unified-runtime/test/unit/logger/CMakeLists.txt +++ /dev/null @@ -1,433 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -add_unit_test(logger - logger.cpp -) - -set(TEST_TARGET_NAME test-logger_env_var) -add_ur_executable(${TEST_TARGET_NAME} - env_var.cpp -) -target_link_libraries(${TEST_TARGET_NAME} - PRIVATE - ${PROJECT_NAME}::common - GTest::gtest_main -) - -set(OUT_FILE ${CMAKE_CURRENT_BINARY_DIR}/logger_test.log) - -function(add_logger_env_var_log_match_test name env_var test_case match_file out) - set(full_name unit-logger_env_var_${name}) - - add_test(NAME ${full_name}-validate-output - COMMAND ${CMAKE_COMMAND} - -D MODE=${out} - -D TEST_FILE=$ - -D OUT_FILE=${OUT_FILE} - -D MATCH_FILE=${match_file} - -P ${PROJECT_SOURCE_DIR}/cmake/match.cmake - ) - set_tests_properties(${full_name}-validate-output PROPERTIES - LABELS "unit" - ENVIRONMENT ${env_var}\;GTEST_FILTER=*${test_case}\;GTEST_BRIEF=1 - ) -endfunction() - -function(add_logger_env_var_no_logfile_test name env_var test_case) - set(full_name unit-logger_env_var_${name}) - - add_test(NAME ${full_name}-validate-no-file - COMMAND ${CMAKE_COMMAND} - -D BIN_PATH=${CMAKE_CURRENT_BINARY_DIR}/${TEST_TARGET_NAME} - -D OUT_FILE=${OUT_FILE} - -P ${CMAKE_CURRENT_SOURCE_DIR}/no_logfile.cmake - ) - - set_tests_properties(${full_name}-validate-no-file PROPERTIES - LABELS "unit" - ENVIRONMENT ${env_var}\;GTEST_FILTER=*${test_case} - ) -endfunction() - -# file sink tests -add_logger_env_var_log_match_test( - default_flush_lvl_err_msg - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:file,\"${OUT_FILE}\" - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_error_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - default_flush_lvl_no_output_warn - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:file,'${OUT_FILE}' - WarningMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "file" -) - -add_logger_env_var_log_match_test( - default_flush_lvl_all_lvls_msg - UR_LOG_ADAPTER_TEST=level:debug\\\\\;output:file,'${OUT_FILE}' - LoggerFromEnvVar*Message - ${CMAKE_CURRENT_SOURCE_DIR}/logger_all_levels_msg_exact.out.match - "file" -) - -# # stdout/stderr tests -add_logger_env_var_log_match_test( - stdout_basic - UR_LOG_ADAPTER_TEST=level:debug\\\\\;flush:debug\\\\\;output:stdout - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_debug_msg.out.match - "stdout" -) - -add_logger_env_var_log_match_test( - stderr_basic - UR_LOG_ADAPTER_TEST=level:debug\\\\\;flush:debug\\\\\;output:stderr - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_debug_msg_exact.out.match - "stderr" -) - -add_logger_env_var_log_match_test( - stdout_with_default_lvls - UR_LOG_ADAPTER_TEST=output:stdout - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_log_match_test( - default_output_stderr_no_output - UR_LOG_ADAPTER_TEST=flush:debug - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "stderr" -) - -add_logger_env_var_log_match_test( - default_output_stderr_2 - UR_LOG_ADAPTER_TEST=level:debug - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_debug_msg_exact.out.match - "stderr" -) - -# log level tests -add_logger_env_var_log_match_test( - default_lvl_no_output - UR_LOG_ADAPTER_TEST=output:file,'${OUT_FILE}' - WarningMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "file" -) - -add_logger_env_var_log_match_test( - default_lvl_no_output_2 - UR_LOG_ADAPTER_TEST=flush:warning\\\\\;output:file,'${OUT_FILE}' - WarningMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_debug - UR_LOG_ADAPTER_TEST=level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - LoggerFromEnvVar*Message - ${CMAKE_CURRENT_SOURCE_DIR}/logger_all_levels_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_info - UR_LOG_ADAPTER_TEST=level:info\\\\\;flush:info\\\\\;output:file,'${OUT_FILE}' - InfoMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_info_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_info_err_msg - UR_LOG_ADAPTER_TEST=level:info\\\\\;flush:info\\\\\;output:file,'${OUT_FILE}' - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_error_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_info_no_output - UR_LOG_ADAPTER_TEST=level:info\\\\\;flush:info\\\\\;output:file,'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_warning - UR_LOG_ADAPTER_TEST=level:warning\\\\\;flush:warning\\\\\;output:file,'${OUT_FILE}' - WarningMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_warning_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_warning_err_msg - UR_LOG_ADAPTER_TEST=level:warning\\\\\;flush:warning\\\\\;output:file,'${OUT_FILE}' - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_error_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_warning_no_output - UR_LOG_ADAPTER_TEST=level:warning\\\\\;flush:warning\\\\\;output:file,'${OUT_FILE}' - InfoMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_error - UR_LOG_ADAPTER_TEST=level:error\\\\\;flush:error\\\\\;output:file,'${OUT_FILE}' - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_error_msg_exact.out.match - "file" -) - -add_logger_env_var_log_match_test( - lvl_error_no_output - UR_LOG_ADAPTER_TEST=level:error\\\\\;flush:error\\\\\;output:file,'${OUT_FILE}' - WarningMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_empty.out.match - "file" -) - -# wrong env var format - default logger, no output -add_logger_env_var_no_logfile_test( - no_env_var - UR_LOG= - DebugMessage -) - -add_logger_env_var_log_match_test( - no_env_var - UR_LOG= - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - empty_env_var - UR_LOG_ADAPTER_TEST= - DebugMessage -) - -add_logger_env_var_log_match_test( - empty_env_var - UR_LOG_ADAPTER_TEST= - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - double_output - UR_LOG_ADAPTER_TEST=output:stdout\\\\\;level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage -) - -add_logger_env_var_log_match_test( - double_output - UR_LOG_ADAPTER_TEST=output:stdout\\\\\;level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - double_flush_level - UR_LOG_ADAPTER_TEST=flush:error\\\\\;level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage -) - -add_logger_env_var_log_match_test( - double_flush_level - UR_LOG_ADAPTER_TEST=flush:error\\\\\;level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - double_log_level - UR_LOG_ADAPTER_TEST=level:error\\\\\;level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage -) - -add_logger_env_var_log_match_test( - double_log_level - UR_LOG_ADAPTER_TEST=level:error\\\\\;level:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_param - UR_LOG_ADAPTER_TEST=lvl:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage -) - -add_logger_env_var_log_match_test( - wrong_param - UR_LOG_ADAPTER_TEST=lvl:debug\\\\\;flush:debug\\\\\;output:file,'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_param_2 - UR_LOG_ADAPTER_TEST=lvl:debug - DebugMessage -) - -add_logger_env_var_log_match_test( - wrong_param_2 - UR_LOG_ADAPTER_TEST=lvl:debug - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_output - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:cout - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_output - UR_LOG_ADAPTER_TEST=level:debug\\\\\;output:cout - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_output_2 - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:stdout,'${OUT_FILE}' - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_output_2 - UR_LOG_ADAPTER_TEST=level:debug\\\\\;output:stdout,'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_output_3 - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:file - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_output_3 - UR_LOG_ADAPTER_TEST=level:debug\\\\\;output:file - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_output_4 - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:file, - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_output_4 - UR_LOG_ADAPTER_TEST=level:debug\\\\\;output:file, - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_output_5 - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:'${OUT_FILE}' - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_output_5 - UR_LOG_ADAPTER_TEST=level:debug\\\\\;output:'${OUT_FILE}' - DebugMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_debug_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_level - UR_LOG_ADAPTER_TEST=level:err\\\\\;output:file,'${OUT_FILE}' - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_level - UR_LOG_ADAPTER_TEST=level:err\\\\\;output:file,'${OUT_FILE}' - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_error_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_flush_level - UR_LOG_ADAPTER_TEST=level:error\\\\\;flush:err\\\\\;output:file,'${OUT_FILE}' - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_flush_level - UR_LOG_ADAPTER_TEST=level:error\\\\\;flush:err\\\\\;output:file,'${OUT_FILE}' - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_error_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - random_str - UR_LOG_ADAPTER_TEST=fvgwfe999&&@$ - ErrorMessage -) - -add_logger_env_var_log_match_test( - random_str - UR_LOG_ADAPTER_TEST=fvgwfe999&&@$ - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_error_msg.out.match - "stdout" -) - -add_logger_env_var_no_logfile_test( - wrong_path - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:file,'${CMAKE_CURRENT_BINARY_DIR}/path/does/not/exist/logger_test.log' - ErrorMessage -) - -add_logger_env_var_log_match_test( - wrong_path - UR_LOG_ADAPTER_TEST=level:error\\\\\;output:file,'${CMAKE_CURRENT_BINARY_DIR}/path/does/not/exist/logger_test.log' - ErrorMessage - ${CMAKE_CURRENT_SOURCE_DIR}/logger_no_error_msg.out.match - "stdout" -) diff --git a/unified-runtime/test/unit/logger/logger_all_levels_msg_exact.out.match b/unified-runtime/test/unit/logger/logger_all_levels_msg_exact.out.match deleted file mode 100644 index dd7acd20bf78..000000000000 --- a/unified-runtime/test/unit/logger/logger_all_levels_msg_exact.out.match +++ /dev/null @@ -1,4 +0,0 @@ -[DEBUG]: Test message: success -[INFO]: Test message: success -[WARNING]: Test message: success -[ERROR]: Test message: success diff --git a/unified-runtime/test/unit/logger/logger_debug_msg.out.match b/unified-runtime/test/unit/logger/logger_debug_msg.out.match deleted file mode 100644 index 0628fad94e89..000000000000 --- a/unified-runtime/test/unit/logger/logger_debug_msg.out.match +++ /dev/null @@ -1,4 +0,0 @@ -{{.*}} -[DEBUG]: Test message: success -{{.*}} -{{.*}} diff --git a/unified-runtime/test/unit/logger/logger_debug_msg_exact.out.match b/unified-runtime/test/unit/logger/logger_debug_msg_exact.out.match deleted file mode 100644 index 031003fa5d53..000000000000 --- a/unified-runtime/test/unit/logger/logger_debug_msg_exact.out.match +++ /dev/null @@ -1 +0,0 @@ -[DEBUG]: Test message: success diff --git a/unified-runtime/test/unit/logger/logger_empty.out.match b/unified-runtime/test/unit/logger/logger_empty.out.match deleted file mode 100644 index e69de29bb2d1..000000000000 diff --git a/unified-runtime/test/unit/logger/logger_error_msg.out.match b/unified-runtime/test/unit/logger/logger_error_msg.out.match deleted file mode 100644 index 451908821cd6..000000000000 --- a/unified-runtime/test/unit/logger/logger_error_msg.out.match +++ /dev/null @@ -1,4 +0,0 @@ -{{.*}} -[ERROR]: Test message: success -{{.*}} -{{.*}} diff --git a/unified-runtime/test/unit/logger/logger_error_msg_exact.out.match b/unified-runtime/test/unit/logger/logger_error_msg_exact.out.match deleted file mode 100644 index a12b08b67e7f..000000000000 --- a/unified-runtime/test/unit/logger/logger_error_msg_exact.out.match +++ /dev/null @@ -1 +0,0 @@ -[ERROR]: Test message: success diff --git a/unified-runtime/test/unit/logger/logger_info_msg_exact.out.match b/unified-runtime/test/unit/logger/logger_info_msg_exact.out.match deleted file mode 100644 index f9b68a0643f2..000000000000 --- a/unified-runtime/test/unit/logger/logger_info_msg_exact.out.match +++ /dev/null @@ -1 +0,0 @@ -[INFO]: Test message: success diff --git a/unified-runtime/test/unit/logger/logger_no_debug_msg.out.match b/unified-runtime/test/unit/logger/logger_no_debug_msg.out.match deleted file mode 100644 index bf0d3e649ea8..000000000000 --- a/unified-runtime/test/unit/logger/logger_no_debug_msg.out.match +++ /dev/null @@ -1,3 +0,0 @@ -{{.*}} -{{^(?!\[DEBUG\]: Test message: success).*$}} -{{.*}} diff --git a/unified-runtime/test/unit/logger/logger_no_error_msg.out.match b/unified-runtime/test/unit/logger/logger_no_error_msg.out.match deleted file mode 100644 index f872879fb82f..000000000000 --- a/unified-runtime/test/unit/logger/logger_no_error_msg.out.match +++ /dev/null @@ -1,3 +0,0 @@ -{{.*}} -{{^(?!\[ERROR\]: Test message: success).*$}} -{{.*}} diff --git a/unified-runtime/test/unit/logger/logger_warning_msg_exact.out.match b/unified-runtime/test/unit/logger/logger_warning_msg_exact.out.match deleted file mode 100644 index 65b4c1e049f4..000000000000 --- a/unified-runtime/test/unit/logger/logger_warning_msg_exact.out.match +++ /dev/null @@ -1 +0,0 @@ -[WARNING]: Test message: success diff --git a/unified-runtime/test/unit/logger/no_logfile.cmake b/unified-runtime/test/unit/logger/no_logfile.cmake deleted file mode 100644 index 5ab4d09a3093..000000000000 --- a/unified-runtime/test/unit/logger/no_logfile.cmake +++ /dev/null @@ -1,30 +0,0 @@ -# Copyright (C) 2023 Intel Corporation -# Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. -# See LICENSE.TXT -# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception - -# -# no_logfile.cmake -- wrapper script for tests verifying that log file was not created -# - -if(NOT DEFINED BIN_PATH) - message(FATAL_ERROR "BIN_PATH needs to be defined with a test binary to be ran") -endif() -if(NOT DEFINED OUT_FILE) - message(FATAL_ERROR "OUT_FILE needs to be defined with an output file to be verified") -endif() - -if(EXISTS ${OUT_FILE}) - file(REMOVE ${OUT_FILE}) -endif() - -execute_process( - COMMAND ${BIN_PATH} -) - -if(EXISTS ${OUT_FILE}) - file(REMOVE ${OUT_FILE}) - message(FATAL_ERROR "Failed: File ${OUT_FILE} should not be created") -else() - message("Passed: File ${OUT_FILE} does not exist") -endif() diff --git a/unified-runtime/test/mock/mock.cpp b/unified-runtime/test/unit/mock.cpp similarity index 100% rename from unified-runtime/test/mock/mock.cpp rename to unified-runtime/test/unit/mock.cpp diff --git a/unified-runtime/test/unit/utils/params.cpp b/unified-runtime/test/unit/params.cpp similarity index 100% rename from unified-runtime/test/unit/utils/params.cpp rename to unified-runtime/test/unit/params.cpp diff --git a/unified-runtime/test/unit/utils/print.cpp b/unified-runtime/test/unit/print.cpp similarity index 100% rename from unified-runtime/test/unit/utils/print.cpp rename to unified-runtime/test/unit/print.cpp diff --git a/unified-runtime/test/usm/CMakeLists.txt b/unified-runtime/test/usm/CMakeLists.txt index 4d0d459bd8be..de7a1cb2d0f7 100644 --- a/unified-runtime/test/usm/CMakeLists.txt +++ b/unified-runtime/test/usm/CMakeLists.txt @@ -3,28 +3,20 @@ # See LICENSE.TXT # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +add_ur_lit_testsuite(usm) set(UR_USM_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}) function(add_usm_test name) - set(TEST_TARGET_NAME usm_test-${name}) - add_ur_executable(${TEST_TARGET_NAME} + set(TEST_TARGET_NAME ${name}-test) + add_gtest_test(${name} ${UR_USM_TEST_DIR}/../conformance/source/environment.cpp ${UR_USM_TEST_DIR}/../conformance/source/main.cpp ${ARGN}) target_link_libraries(${TEST_TARGET_NAME} PRIVATE - ${PROJECT_NAME}::common - ${PROJECT_NAME}::loader ${PROJECT_NAME}::umf - ur_testing - GTest::gtest_main) - add_test(NAME usm-${name} - COMMAND ${TEST_TARGET_NAME} - WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}) - set_tests_properties(usm-${name} PROPERTIES - LABELS "usm" - ENVIRONMENT "UR_ADAPTERS_FORCE_LOAD=\"$\"") - target_compile_definitions("usm_test-${name}" PRIVATE DEVICES_ENVIRONMENT) + ur_testing) + target_compile_definitions(${TEST_TARGET_NAME} PRIVATE DEVICES_ENVIRONMENT) endfunction() add_usm_test(usmPoolManager usmPoolManager.cpp) diff --git a/unified-runtime/test/usm/lit.local.cfg.py b/unified-runtime/test/usm/lit.local.cfg.py new file mode 100644 index 000000000000..ce6081b9e906 --- /dev/null +++ b/unified-runtime/test/usm/lit.local.cfg.py @@ -0,0 +1,10 @@ +""" +Copyright (C) 2025 Intel Corporation + +Part of the Unified-Runtime Project, under the Apache License v2.0 with LLVM Exceptions. +See LICENSE.TXT +SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception + +""" + +config.suffixes = [".cpp"] diff --git a/unified-runtime/test/usm/usmPoolManager.cpp b/unified-runtime/test/usm/usmPoolManager.cpp index 59168e920f05..2b9d90761a21 100644 --- a/unified-runtime/test/usm/usmPoolManager.cpp +++ b/unified-runtime/test/usm/usmPoolManager.cpp @@ -4,7 +4,10 @@ // // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// RUN: %use-mock usmPoolManager-test + #include "umf_helpers.hpp" + #include "umf_pools/disjoint_pool_config_parser.hpp" #include "ur_pool_manager.hpp" diff --git a/unified-runtime/third_party/requirements_testing.txt b/unified-runtime/third_party/requirements_testing.txt new file mode 100644 index 000000000000..1e79c168c61f --- /dev/null +++ b/unified-runtime/third_party/requirements_testing.txt @@ -0,0 +1,3 @@ +# Note: Filecheck 1.0.1 requires Python 3.10 +filecheck==1.0.1 +lit==18.1.8