2025-01-17 16:42:25 -06:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
|
|
import csv
|
|
|
|
|
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",
|
2025-04-11 16:56:36 -05:00
|
|
|
default="rocdecode-trace/rocdecode-demo-trace/out_results.json",
|
2025-01-17 16:42:25 -06:00
|
|
|
help="Input JSON",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--otf2-input",
|
|
|
|
|
action="store",
|
2025-04-11 16:56:36 -05:00
|
|
|
default="rocdecode-trace/rocdecode-demo-trace/out_results.otf2",
|
2025-01-17 16:42:25 -06:00
|
|
|
help="Input OTF2",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--pftrace-input",
|
|
|
|
|
action="store",
|
2025-04-11 16:56:36 -05:00
|
|
|
default="rocdecode-trace/rocdecode-demo-trace/out_results.pftrace",
|
2025-01-17 16:42:25 -06:00
|
|
|
help="Input pftrace file",
|
|
|
|
|
)
|
|
|
|
|
parser.addoption(
|
|
|
|
|
"--csv-input",
|
|
|
|
|
action="store",
|
2025-04-11 16:56:36 -05:00
|
|
|
default="rocdecode-trace/rocdecode-demo-trace/out_rocdecode_api_trace.csv",
|
2025-01-17 16:42:25 -06:00
|
|
|
help="Input CSV",
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def json_data(request):
|
|
|
|
|
filename = request.config.getoption("--json-input")
|
2025-02-21 15:43:49 -06:00
|
|
|
if not os.path.isfile(filename):
|
|
|
|
|
return pytest.skip("rocdecode tracing unavailable")
|
2025-01-17 16:42:25 -06:00
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
return dotdict(collapse_dict_list(json.load(inp)))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def csv_data(request):
|
|
|
|
|
filename = request.config.getoption("--csv-input")
|
|
|
|
|
data = []
|
2025-02-21 15:43:49 -06:00
|
|
|
if not os.path.isfile(filename):
|
|
|
|
|
# The CSV file is not generated, because the dependency test
|
|
|
|
|
# responsible to generate this file was skipped or failed.
|
|
|
|
|
# Thus emit the message to skip this test as well.
|
|
|
|
|
return pytest.skip("rocdecode tracing unavailable")
|
|
|
|
|
else:
|
|
|
|
|
with open(filename, "r") as inp:
|
|
|
|
|
reader = csv.DictReader(inp)
|
|
|
|
|
for row in reader:
|
|
|
|
|
data.append(row)
|
2025-01-17 16:42:25 -06:00
|
|
|
return data
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def otf2_data(request):
|
|
|
|
|
filename = request.config.getoption("--otf2-input")
|
2025-02-21 15:43:49 -06:00
|
|
|
if not os.path.isfile(filename):
|
|
|
|
|
return pytest.skip("rocdecode tracing unavailable")
|
2025-01-17 16:42:25 -06:00
|
|
|
return OTF2Reader(filename).read()[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.fixture
|
|
|
|
|
def pftrace_data(request):
|
|
|
|
|
filename = request.config.getoption("--pftrace-input")
|
2025-02-21 15:43:49 -06:00
|
|
|
if not os.path.isfile(filename):
|
|
|
|
|
return pytest.skip("rocdecode tracing unavailable")
|
2025-01-17 16:42:25 -06:00
|
|
|
return PerfettoReader(filename).read()[0]
|