Fixing multi pmc line tests (#848)
* Fixing multi pmc line tests * Fixing cmake-format from commandline locally
Esse commit está contido em:
@@ -2,12 +2,22 @@
|
||||
|
||||
import json
|
||||
import pytest
|
||||
import csv
|
||||
import pandas as pd
|
||||
|
||||
|
||||
def pytest_addoption(parser):
|
||||
parser.addoption("--input", action="store", help="Path to csv file.")
|
||||
parser.addoption("--input-dir", action="store", help="Path to output dir.")
|
||||
parser.addoption(
|
||||
"--agent-input",
|
||||
action="store",
|
||||
help="Path to agent info CSV file.",
|
||||
)
|
||||
parser.addoption(
|
||||
"--counter-input",
|
||||
action="store",
|
||||
help="Path to counter collection CSV file.",
|
||||
)
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -21,6 +31,24 @@ def input_data(request):
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def input_dir(request):
|
||||
dirname = request.config.getoption("--input-dir")
|
||||
return dirname
|
||||
def agent_info_input_data(request):
|
||||
filename = request.config.getoption("--agent-input")
|
||||
data = []
|
||||
with open(filename, "r") as inp:
|
||||
reader = csv.DictReader(inp)
|
||||
for row in reader:
|
||||
data.append(row)
|
||||
|
||||
return data
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
def counter_input_data(request):
|
||||
filename = request.config.getoption("--counter-input")
|
||||
data = []
|
||||
with open(filename, "r") as inp:
|
||||
reader = csv.DictReader(inp)
|
||||
for row in reader:
|
||||
data.append(row)
|
||||
|
||||
return data
|
||||
|
||||
@@ -20,8 +20,8 @@ add_test(
|
||||
NAME rocprofv3-test-counter-collection-pmc2-execute
|
||||
COMMAND
|
||||
$<TARGET_FILE:rocprofiler-sdk::rocprofv3> -i
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.txt -d ${CMAKE_CURRENT_BINARY_DIR}/out_cc_2 -o
|
||||
pmc2 $<TARGET_FILE:simple-transpose>)
|
||||
${CMAKE_CURRENT_BINARY_DIR}/input.txt -d ${CMAKE_CURRENT_BINARY_DIR}/%argt%-cc -o
|
||||
out $<TARGET_FILE:simple-transpose>)
|
||||
|
||||
string(REPLACE "LD_PRELOAD=" "ROCPROF_PRELOAD=" PRELOAD_ENV
|
||||
"${ROCPROFILER_MEMCHECK_PRELOAD_ENV}")
|
||||
@@ -39,12 +39,33 @@ set_tests_properties(
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" ENVIRONMENT "${cc-env-pmc2}"
|
||||
FAIL_REGULAR_EXPRESSION "${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
|
||||
add_test(NAME rocprofv3-test-counter-collection-pmc2-validate
|
||||
COMMAND ${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py
|
||||
--input-dir "${CMAKE_CURRENT_BINARY_DIR}/out_cc_2")
|
||||
add_test(
|
||||
NAME rocprofv3-test-counter-collection-pmc2-validate
|
||||
COMMAND
|
||||
${Python3_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/validate.py --agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_agent_info.csv
|
||||
--counter-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_counter_collection.csv
|
||||
--agent-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_agent_info.csv
|
||||
--counter-input
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_counter_collection.csv)
|
||||
|
||||
set(SYS_VALIDATION_FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_1/out_counter_collection.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_agent_info.csv
|
||||
${CMAKE_CURRENT_BINARY_DIR}/simple-transpose-cc/pmc_2/out_counter_collection.csv)
|
||||
|
||||
set_tests_properties(
|
||||
rocprofv3-test-counter-collection-pmc2-validate
|
||||
PROPERTIES TIMEOUT 45 LABELS "integration-tests" DEPENDS
|
||||
rocprofv3-test-counter-collection-pmc2-execute FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}")
|
||||
PROPERTIES TIMEOUT
|
||||
45
|
||||
LABELS
|
||||
"integration-tests"
|
||||
DEPENDS
|
||||
rocprofv3-test-counter-collection-pmc2-execute
|
||||
FAIL_REGULAR_EXPRESSION
|
||||
"${ROCPROFILER_DEFAULT_FAIL_REGEX}"
|
||||
ATTACHED_FILES_ON_FAIL
|
||||
"${VALIDATION_FILES}")
|
||||
|
||||
@@ -4,43 +4,45 @@ import sys
|
||||
import pytest
|
||||
|
||||
|
||||
def test_validate_counter_collection_pmc2(input_dir: pd.DataFrame):
|
||||
directory_path = input_dir
|
||||
def test_agent_info(agent_info_input_data):
|
||||
logical_node_id = max([int(itr["Logical_Node_Id"]) for itr in agent_info_input_data])
|
||||
|
||||
# Check if the directory is not empty
|
||||
assert os.path.isdir(directory_path), f"{directory_path} is not a directory."
|
||||
assert os.listdir(directory_path), f"{directory_path} is empty."
|
||||
assert logical_node_id + 1 == len(agent_info_input_data)
|
||||
|
||||
# Check if there are 2 subdirectories pmc_1 and pmc_2
|
||||
subdirectories = [
|
||||
d
|
||||
for d in os.listdir(directory_path)
|
||||
if os.path.isdir(os.path.join(directory_path, d))
|
||||
]
|
||||
assert (
|
||||
len(subdirectories) == 2
|
||||
), f"Expected 2 subdirectories, found {len(subdirectories)}."
|
||||
for row in agent_info_input_data:
|
||||
agent_type = row["Agent_Type"]
|
||||
assert agent_type in ("CPU", "GPU")
|
||||
if agent_type == "CPU":
|
||||
assert int(row["Cpu_Cores_Count"]) > 0
|
||||
assert int(row["Simd_Count"]) == 0
|
||||
assert int(row["Max_Waves_Per_Simd"]) == 0
|
||||
else:
|
||||
assert int(row["Cpu_Cores_Count"]) == 0
|
||||
assert int(row["Simd_Count"]) > 0
|
||||
assert int(row["Max_Waves_Per_Simd"]) > 0
|
||||
|
||||
# Check if each subdirectory has files
|
||||
for subdirectory in subdirectories:
|
||||
subdirectory_path = os.path.join(directory_path, subdirectory)
|
||||
assert os.listdir(subdirectory_path), f"{subdirectory_path} is empty."
|
||||
|
||||
# Check if each file in the subdirectory has some data
|
||||
for file_name in os.listdir(subdirectory_path):
|
||||
file_path = os.path.join(subdirectory_path, file_name)
|
||||
# ignore hidden folders
|
||||
if os.path.isdir(file_path) and os.path.basename(file_path).startswith("."):
|
||||
continue
|
||||
assert os.path.isfile(file_path), f"{file_path} is not a file."
|
||||
def test_validate_counter_collection_pmc2(counter_input_data):
|
||||
counter_names = ["SQ_WAVES", "GRBM_COUNT"]
|
||||
di_list = []
|
||||
|
||||
if "agent_info.csv" not in file_path:
|
||||
with open(file_path, "r") as file:
|
||||
df = pd.read_csv(file)
|
||||
# check if kernel-name is present
|
||||
assert len(df["Kernel_Name"]) > 0
|
||||
# check if counter value is positive
|
||||
assert len(df["Counter_Value"]) > 0
|
||||
for row in counter_input_data:
|
||||
assert int(row["Agent_Id"]) > 0
|
||||
assert int(row["Queue_Id"]) > 0
|
||||
assert int(row["Process_Id"]) > 0
|
||||
assert len(row["Kernel_Name"]) > 0
|
||||
|
||||
assert len(row["Counter_Value"]) > 0
|
||||
# assert row["Counter_Name"].contains("SQ_WAVES").all()
|
||||
assert row["Counter_Name"] in counter_names
|
||||
assert int(row["Counter_Value"]) > 0
|
||||
|
||||
di_list.append(int(row["Dispatch_Id"]))
|
||||
|
||||
# # make sure the dispatch ids are unique and ordered
|
||||
di_list = list(dict.fromkeys(di_list))
|
||||
di_expect = [idx + 1 for idx in range(len(di_list))]
|
||||
assert di_expect == di_list
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Referência em uma Nova Issue
Bloquear um usuário