Files
rocm-systems/tests/rocprofv3/counter-collection/input2/validate.py
T
Gopesh Bhardwaj 8a25b239bc Fixing counter collection in tools and enabling tests (#436)
* Fixing coutner colleciton in tools and enabling tests

* fixing tests

* improving coverage on test

* Adding vector operations app

* Fixing tools bug for counter collection

* removing roctx linking
2024-02-06 09:55:07 -08:00

45 lines
1.5 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)
assert os.path.isfile(file_path), f"{file_path} is not a file."
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)