2024-07-29 14:33:50 -05:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import pytest
|
|
|
|
|
import json
|
2024-07-30 19:57:19 -05:00
|
|
|
import os
|
2024-07-29 14:33:50 -05:00
|
|
|
|
|
|
|
|
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
|
2024-07-30 19:57:19 -05:00
|
|
|
from rocprofiler_sdk.pytest_utils.otf2_reader import OTF2Reader
|
2024-07-29 14:33:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
def pytest_addoption(parser):
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--json-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to JSON file.",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--pftrace-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to Perfetto trace file.",
|
|
|
|
|
)
|
2024-07-30 19:57:19 -05:00
|
|
|
parser.addoption(
|
|
|
|
|
"--otf2-input",
|
|
|
|
|
action="store",
|
|
|
|
|
help="Path to OTF2 trace file.",
|
|
|
|
|
)
|
2024-07-29 14:33:50 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@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 pftrace_data(request):
|
|
|
|
|
filename = request.config.getoption("--pftrace-input")
|
|
|
|
|
return PerfettoReader(filename).read()[0]
|
2024-07-30 19:57:19 -05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
@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]
|