80ea339217
* Fix formatting
50 líneas
1.7 KiB
Python
50 líneas
1.7 KiB
Python
import hashlib
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
import yaml
|
|
|
|
|
|
@pytest.mark.autogen_config
|
|
def test_modification_time():
|
|
# Ensure modification time of utils/unified_config.yaml is older than
|
|
# utils/autogen_hash.yaml
|
|
# docs/data/metrics_description.yaml and
|
|
# src/rocprof_compute_soc/analysis_configs/gfx*/*.yaml
|
|
|
|
unified_config_path = Path("utils/unified_config.yaml")
|
|
hash_path = Path("utils/autogen_hash.yaml")
|
|
docs_config_path = Path("docs/data/metrics_description.yaml")
|
|
analysis_config_paths = list(
|
|
Path("src/rocprof_compute_soc/analysis_configs").glob("gfx*/*.yaml")
|
|
)
|
|
|
|
unified_config_time = unified_config_path.stat().st_mtime
|
|
|
|
def is_autogenerated(filepath):
|
|
# Autogenerated filepath should be newer than the unified config
|
|
# Autogenerated filepath can be older than unified config by at most a second due to file system delays
|
|
return unified_config_time - filepath.stat().st_mtime < 1
|
|
|
|
assert is_autogenerated(
|
|
hash_path
|
|
), f"{unified_config_path} is not older than {hash_path}"
|
|
|
|
assert is_autogenerated(
|
|
docs_config_path
|
|
), f"{unified_config_path} is not older than {docs_config_path}"
|
|
|
|
for analysis_config_path in analysis_config_paths:
|
|
assert is_autogenerated(
|
|
analysis_config_path
|
|
), f"{unified_config_path} is not older than {analysis_config_path}"
|
|
|
|
# Ensure hash map consistency
|
|
with open(hash_path, "r") as f:
|
|
hash_map = yaml.safe_load(f)
|
|
for file, hash in hash_map.items():
|
|
file_hash = hashlib.sha256(Path(file).read_bytes()).hexdigest()
|
|
assert (
|
|
file_hash == hash
|
|
), f"Hash mismatch for {file}: expected {hash}, got {file_hash}"
|