ファイル
rocm-systems/tests/rocprofv3/counter-collection/input2/validate.py
T
Jonathan R. Madsen 87490d0018 Update lib/rocprofiler-sdk-tool (#755)
- questionable data race within std::regex in CI
- simplify rocprofiler::tool::format
- set config::tmp_directory to default to output_path
- fs::create_directories for tmp_file
- rework get_file_name(...) and compose_tmp_file_name(...) in tool.cpp
2024-04-12 03:48:02 -05:00

49 行
1.7 KiB
Python

import pandas as pd
import os
import sys
import pytest
def test_validate_counter_collection_pmc2(input_dir: pd.DataFrame):
directory_path = input_dir
# 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."
# 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)}."
# 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."
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
if __name__ == "__main__":
exit_code = pytest.main(["-x", __file__] + sys.argv[1:])
sys.exit(exit_code)