Files
rocm-systems/tests/rocprofv3/memory-allocation/conftest.py
T

41 lines
1.1 KiB
Python
Raw Normal View History

2024-11-18 20:22:14 -06:00
#!/usr/bin/env python3
import json
import os
import pytest
from rocprofiler_sdk.pytest_utils.dotdict import dotdict
from rocprofiler_sdk.pytest_utils import collapse_dict_list
from rocprofiler_sdk.pytest_utils.perfetto_reader import PerfettoReader
from rocprofiler_sdk.pytest_utils.otf2_reader import OTF2Reader
def pytest_addoption(parser):
parser.addoption(
"--json-input",
action="store",
default="memory-allocation-tracing/out_results.json",
help="Input JSON",
)
parser.addoption(
"--otf2-input",
action="store",
default="memory-allocation-tracing/out_results.otf2",
help="Input JSON",
)
@pytest.fixture
def json_data(request):
filename = request.config.getoption("--json-input")
with open(filename, "r") as inp:
return dotdict(collapse_dict_list(json.load(inp)))
@pytest.fixture
def otf2_data(request):
filename = request.config.getoption("--otf2-input")
if not os.path.exists(filename):
raise FileExistsError(f"{filename} does not exist")
return OTF2Reader(filename).read()[0]