Fix autogen config test (#856)

* Only check file content hash consistency

* Do not check file modification timestamps since that can be updated by
  git commands
This commit is contained in:
vedithal-amd
2025-08-05 10:50:32 -04:00
committed by GitHub
parent b349e406ed
commit e867524344
+1 -32
View File
@@ -7,39 +7,8 @@ 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
hash_path = Path("utils/autogen_hash.yaml")
with open(hash_path, "r") as f:
hash_map = yaml.safe_load(f)
for file, hash in hash_map.items():