feat: add by_sha256 index, fix reporting attribution

generate_db: add by_sha256 index for O(1) variant lookup.
verify: _find_best_variant uses indexed sha256 instead of O(n) scan.
validation: check_file_validation returns (reason, emulators) tuple,
attributing mismatch only to emulators whose check actually failed.
beetle_psx: remove incorrect size field for ps1_rom.bin (code does
not validate size, swanstation is sole size authority).
This commit is contained in:
Abdessamad Derraz
2026-04-02 00:59:01 +02:00
parent 95b7a9813c
commit 0401d058a1
7 changed files with 7382 additions and 51 deletions

View File

@@ -1137,9 +1137,11 @@ class TestE2E(unittest.TestCase):
profiles = load_emulator_profiles(self.emulators_dir)
index = _build_validation_index(profiles)
path = self.files["present_opt.bin"]["path"]
reason = check_file_validation(path, "present_opt.bin", index)
self.assertIsNotNone(reason)
result = check_file_validation(path, "present_opt.bin", index)
self.assertIsNotNone(result)
reason, emus = result
self.assertIn("size mismatch", reason)
self.assertIsInstance(emus, list)
def test_73_validation_crc32_pass(self):
"""File with correct CRC32 passes validation."""
@@ -1154,9 +1156,11 @@ class TestE2E(unittest.TestCase):
profiles = load_emulator_profiles(self.emulators_dir)
index = _build_validation_index(profiles)
path = self.files["no_md5.bin"]["path"]
reason = check_file_validation(path, "no_md5.bin", index)
self.assertIsNotNone(reason)
result = check_file_validation(path, "no_md5.bin", index)
self.assertIsNotNone(result)
reason, emus = result
self.assertIn("crc32 mismatch", reason)
self.assertIsInstance(emus, list)
def test_75_validation_applied_in_existence_mode(self):
"""Existence mode reports discrepancy when validation fails, keeps OK."""
@@ -1212,9 +1216,11 @@ class TestE2E(unittest.TestCase):
profiles = load_emulator_profiles(self.emulators_dir)
index = _build_validation_index(profiles)
path = self.files["alias_target.bin"]["path"]
reason = check_file_validation(path, "alias_target.bin", index)
self.assertIsNotNone(reason)
result = check_file_validation(path, "alias_target.bin", index)
self.assertIsNotNone(result)
reason, emus = result
self.assertIn("md5 mismatch", reason)
self.assertIsInstance(emus, list)
def test_81_validation_index_has_md5_sha1(self):
"""Validation index stores md5 and sha1 when declared."""