- tests/pytest-packages/pytest_utils containing utilities for pytest validation tests
- example:

```python
from rocprofiler_sdk.pytest_utils.dotdict import dotdict
```

[ROCm/rocprofiler-sdk commit: 39dd5a81df]
Этот коммит содержится в:
Jonathan R. Madsen
2024-04-18 03:09:01 -05:00
коммит произвёл GitHub
родитель b8ecfee16d
Коммит 7e166e2b5a
20 изменённых файлов: 134 добавлений и 28 удалений
+5
Просмотреть файл
@@ -240,6 +240,11 @@ parse:
PERFETTO_METRIC: '*'
TIMEMORY_FILE: '*'
TIMEMORY_METRIC: '*'
rocprofiler_configure_pytest_files:
kwargs:
COPY: '*'
CONFIG: '*'
OUTPUT_DIRECTORY: '*'
override_spec: {}
vartags: []
proptags: []
+5
Просмотреть файл
@@ -10,6 +10,8 @@ endif()
project(rocprofiler-tests LANGUAGES C CXX)
set(CMAKE_INSTALL_DEFAULT_COMPONENT_NAME "tests")
set(ROCPROFILER_SDK_TESTS_SOURCE_DIR "${PROJECT_SOURCE_DIR}")
set(ROCPROFILER_SDK_TESTS_BINARY_DIR "${PROJECT_BINARY_DIR}")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE
@@ -34,6 +36,9 @@ set(CMAKE_INSTALL_LIBDIR "lib")
# needed for validation
find_package(Python3 REQUIRED)
# configure python module <BINARY_DIR>/rocprofiler_sdk/pytest_utils
add_subdirectory(pytest-packages)
# common utilities
add_subdirectory(common)
+2 -4
Просмотреть файл
@@ -31,10 +31,8 @@ set_tests_properties(
"${async-copy-tracing-env}" FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
foreach(FILENAME validate.py pytest.ini conftest.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY validate.py conftest.py CONFIG pytest.ini)
add_test(NAME test-async-copy-tracing-validate
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --input
+1
Просмотреть файл
@@ -2,3 +2,4 @@
[pytest]
addopts = --durations=20 -rA -s -vv
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
+19
Просмотреть файл
@@ -3,6 +3,7 @@
#
include(FetchContent)
include(CMakeParseArguments)
set(FETCHCONTENT_BASE_DIR ${PROJECT_BINARY_DIR}/external)
@@ -131,3 +132,21 @@ if(EXISTS ${EXTERNAL_SUBMODULE_DIR}/filesystem/include/ghc/filesystem.hpp)
rocprofiler-tests-common-library SYSTEM
INTERFACE $<BUILD_INTERFACE:${EXTERNAL_SUBMODULE_DIR}/filesystem/include>)
endif()
function(rocprofiler_configure_pytest_files)
cmake_parse_arguments(RCPF "" "OUTPUT_DIRECTORY" "COPY;CONFIG" ${ARGN})
if(NOT RCPF_OUTPUT_DIRECTORY)
set(RCPF_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
endif()
foreach(FILENAME ${RCPF_COPY})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${RCPF_OUTPUT_DIRECTORY}/${FILENAME} COPYONLY)
endforeach()
foreach(FILENAME ${RCPF_CONFIG})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${RCPF_OUTPUT_DIRECTORY}/${FILENAME} @ONLY)
endforeach()
endfunction()
+2 -4
Просмотреть файл
@@ -29,10 +29,8 @@ set_tests_properties(
"${counter-collection-env}" FAIL_REGULAR_EXPRESSION
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
foreach(FILENAME validate.py pytest.ini conftest.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY validate.py conftest.py CONFIG pytest.ini)
add_test(NAME test-counter-collection-validate
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --input
+1
Просмотреть файл
@@ -2,3 +2,4 @@
[pytest]
addopts = --durations=20 -ras -vv
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
+2 -4
Просмотреть файл
@@ -35,10 +35,8 @@ set_tests_properties(
PROPERTIES TIMEOUT 100 LABELS "integration-tests" ENVIRONMENT "${kernel-tracing-env}"
FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}")
foreach(FILENAME validate.py pytest.ini conftest.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY validate.py conftest.py CONFIG pytest.ini)
add_test(
NAME test-kernel-tracing-validate
+1
Просмотреть файл
@@ -2,3 +2,4 @@
[pytest]
addopts = --durations=20 -rA -s -vv
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
+2 -4
Просмотреть файл
@@ -40,10 +40,8 @@ set_tests_properties(
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
foreach(FILENAME validate.py pytest.ini conftest.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY validate.py conftest.py CONFIG pytest.ini)
add_test(NAME test-page-migration-validate
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --input
+1
Просмотреть файл
@@ -2,3 +2,4 @@
[pytest]
addopts = --durations=20 -rA -s -vv
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
+20
Просмотреть файл
@@ -0,0 +1,20 @@
#
#
#
set(PACKAGE_OUTPUT_DIR
${ROCPROFILER_SDK_TESTS_BINARY_DIR}/pytest-packages/rocprofiler_sdk)
set(PYTEST_UTILS_PYTHON_SOURCES __init__.py dotdict.py)
foreach(_FILE ${PYTEST_UTILS_PYTHON_SOURCES})
configure_file(${CMAKE_CURRENT_LIST_DIR}/pytest_utils/${_FILE}
${PACKAGE_OUTPUT_DIR}/pytest_utils/${_FILE} COPYONLY)
endforeach()
file(
WRITE "${PACKAGE_OUTPUT_DIR}/__init__.py"
"
from __future__ import absolute_import
from . import pytest_utils
")
+23
Просмотреть файл
@@ -0,0 +1,23 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from __future__ import absolute_import
+40
Просмотреть файл
@@ -0,0 +1,40 @@
# MIT License
#
# Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
from __future__ import absolute_import
class dotdict(dict):
"""dot.notation access to dictionary attributes"""
__getattr__ = dict.get
__setattr__ = dict.__setitem__
__delattr__ = dict.__delitem__
def __init__(self, d):
super(dotdict, self).__init__(d)
for k, v in self.items():
if isinstance(v, dict):
self.__setitem__(k, dotdict(v))
# print(k)
elif isinstance(v, list):
self.__setitem__(k, [dotdict(i) for i in v])
+2 -4
Просмотреть файл
@@ -2,10 +2,8 @@
# Various counter collection tests
#
foreach(FILENAME conftest.py pytest.ini)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY conftest.py CONFIG pytest.ini)
add_subdirectory(input1)
add_subdirectory(input2)
+1
Просмотреть файл
@@ -4,3 +4,4 @@ addopts = --durations=20 -rA -s -vv
testpaths = input1/validate.py
input2/validate.py
list_metrics/validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
+3 -4
Просмотреть файл
@@ -10,10 +10,9 @@ project(
find_package(rocprofiler-sdk REQUIRED)
foreach(FILENAME validate.py conftest.py pytest.ini input.txt)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY validate.py conftest.py input.txt
CONFIG pytest.ini)
# pmc3
add_test(
+1
Просмотреть файл
@@ -2,3 +2,4 @@
[pytest]
addopts = --durations=20 -rA -s -vv
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages
+2 -4
Просмотреть файл
@@ -31,10 +31,8 @@ set_tests_properties(
"${scratch-memory-tracing-env}" FAIL_REGULAR_EXPRESSION
"threw an exception")
foreach(FILENAME validate.py pytest.ini conftest.py)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}
${CMAKE_CURRENT_BINARY_DIR}/${FILENAME} COPYONLY)
endforeach()
# copy to binary directory
rocprofiler_configure_pytest_files(COPY validate.py conftest.py CONFIG pytest.ini)
add_test(NAME test-scratch-memory-tracing-validate
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --input
+1
Просмотреть файл
@@ -2,3 +2,4 @@
[pytest]
addopts = --durations=20 -rA -s -vv
testpaths = validate.py
pythonpath = @ROCPROFILER_SDK_TESTS_BINARY_DIR@/pytest-packages