chore: merge resolver and profiles batch

This commit is contained in:
Abdessamad Derraz committed 2026-11-05 21:47:10 +01:00
commit afd062d111
50 files changed
+8205 -4632

No files matched your search

+65
View File
@@ -5801,6 +5801,71 @@ class AHashScanningCoreContradictsNoPlatform(unittest.TestCase):
self.assertEqual(claimed, [])
class FsUaeKickstartIsFoundByContent(unittest.TestCase):
"""FS-UAE scans its Kickstarts directory and names a ROM by checksum
(src/fs-uae/config.c:121-140, main.c:431-470), and with no ROM loads the
AROS replacement (memory.cpp:2374-2379). kick13.rom and its required
flag came from the RetroPie launcher, which the platform layer records."""
def test_the_kickstart_is_an_optional_label(self):
from scripts.validation import opens_by_name
profile = yaml.safe_load((ROOT / "emulators" / "fs-uae.yml").read_text(encoding="utf-8"))
entry = next(f for f in profile["files"] if f.get("sha1") == "891e9a547772fe0c6c19b610baf8bc4ea7fcb785")
self.assertFalse(opens_by_name(entry, profile, standalone=True))
self.assertFalse(entry.get("required"))
self.assertNotIn("RetroPie launcher", entry.get("note", ""))
class NoProfileHashFromASecondarySource(unittest.TestCase):
"""ecwolf.yml pinned ecwolf.pk3 to an md5 its note said came from the
.info. The code checks none, and no file shipped at the pin carries it:
a source without a hash gives the profile none."""
PATTERN = re.compile(
r"(md5|sha1|crc32|hash)[^.]{0,40}\bfrom (the )?(\.info|core-?info|docs?|documentation)",
re.IGNORECASE,
)
def test_no_hashed_entry_names_a_secondary_source(self):
found = []
for path in sorted((ROOT / "emulators").glob("*.yml")):
profile = yaml.safe_load(path.read_text(encoding="utf-8")) or {}
for entry in profile.get("files") or []:
if not isinstance(entry, dict):
continue
if any(entry.get(k) for k in ("md5", "sha1", "crc32", "sha256")) and (
self.PATTERN.search(str(entry.get("note", "")))
):
found.append(f"{path.name}: {entry.get('name')}")
self.assertEqual(found, [])
class XeniosFollowsThePreviewBranch(unittest.TestCase):
"""The xenios pin 87b176a0 and tag v2.0.1 are ancestors of `preview`
(compare: ahead 129, behind 0) and diverged from the default `xenios`
branch (ahead 1784, behind 24). Without source_branch, profile_sync read
the pin as orphaned and 19 refs as moved by the branch divergence."""
def test_the_profile_names_the_branch_its_pin_is_on(self):
profile = yaml.safe_load((ROOT / "emulators" / "xenios.yml").read_text(encoding="utf-8"))
self.assertEqual(profile.get("source_branch"), "preview")
self.assertNotIn("from the xenios branch", profile.get("notes", ""))
class PcemUpstreamPinIsTheLastSync(unittest.TestCase):
"""The pcem bump set upstream_commit to dev's HEAD 25b54e3f, and dev was
rewritten: the pin left every branch (compare: diverged 109/114). The
port shares no history with upstream and took mainline patches by hand
until 2016-04-13, whose last upstream commit is 10739b96. Held there, a
bump cannot move it to a HEAD the port never contained."""
def test_the_upstream_pin_is_held_at_the_last_sync(self):
profile = yaml.safe_load((ROOT / "emulators" / "pcem.yml").read_text(encoding="utf-8"))
self.assertEqual(profile["upstream_commit"], "10739b9618e388a5bf8c21e752f12b3952fa83e1")
self.assertTrue(profile.get("upstream_frozen"))
class AHashScanLabelNamesNoOtherDump(unittest.TestCase):
"""A core that finds its firmware by content names no file, so each
entry name is a label. ares labelled its Famicom Disk System revision
+4
View File
@@ -32,6 +32,10 @@ UNIDENTIFIED = {
"cdogs": 16,
"citra-mmj": 3,
"drastic": 5,
# No pk3 shipped at the pin is the standalone entry's: the 1.3.x
# releases carry 13fe8057, cc10cb70, d312ebbe and 8f4f0387, the buildbot
# 653f7b37, the core embeds 1a3fd445. The .info md5 c011b428 was none.
"ecwolf": 1,
"emucorex": 5,
"hcl": 3,
"hurrican": 1,
+65
View File
@@ -250,5 +250,70 @@ class AliasesFollowContentNotPrimaryCopy(unittest.TestCase):
self.assertIn("_collect_all_aliases(files, aliases)", source)
class TheSmsBiosKeepsItsNames(unittest.TestCase):
"""RetroArch pins bios_E.sms and bios_U.sms to the v1.3 BIOS. Its only
path was ZEsarUX's sms.rom, which sorted before bios/Sega/Master System/,
and the two names were refused because .variants/ copies carried them.
Genesis Plus GX then got the Store Display Unit BIOS as bios_U.sms."""
def test_a_name_only_variants_carry_is_registered_for_the_pinned_content(self):
files = {
"v13": {"name": "SMS_us_1.3.sms", "path": "bios/Sega/MS/SMS_us_1.3.sms", "md5": "m13"},
"kiosk": {"name": "bios_U.sms", "path": "bios/Sega/MS/.variants/bios_U.sms.ee2c29ba",
"md5": "mk"},
}
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
previous = os.getcwd()
os.chdir(tmp)
try:
Path("platforms").mkdir()
Path("platforms/_registry.yml").write_text("platforms:\n p:\n status: active\n")
Path("platforms/p.yml").write_text(
"systems:\n sms:\n files:\n"
' - name: "bios_U.sms"\n sha1: "v13"\n'
)
aliases = generate_db._collect_all_aliases(files)
finally:
os.chdir(previous)
self.assertIn("bios_U.sms", {a["name"] for a in aliases.get("v13", [])})
def test_a_primary_name_still_refuses_another_content(self):
files = {
"v13": {"name": "SMS_us_1.3.sms", "path": "bios/Sega/MS/SMS_us_1.3.sms", "md5": "m13"},
"other": {"name": "bios_U.sms", "path": "bios/Sega/MS/bios_U.sms", "md5": "mo"},
}
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
previous = os.getcwd()
os.chdir(tmp)
try:
Path("platforms").mkdir()
Path("platforms/_registry.yml").write_text("platforms:\n p:\n status: active\n")
Path("platforms/p.yml").write_text(
"systems:\n sms:\n files:\n"
' - name: "bios_U.sms"\n sha1: "v13"\n'
)
aliases = generate_db._collect_all_aliases(files)
finally:
os.chdir(previous)
self.assertEqual(aliases, {})
def test_a_copy_under_its_machine_is_the_path_over_an_emulator_tree(self):
with tempfile.TemporaryDirectory(dir=REPO_ROOT / "tmp") as tmp:
bios = Path(tmp) / "bios"
for rel in ("Other/zesarux/sms.rom", "Sega/Master System/SMS_us_1.3.sms"):
(bios / rel).parent.mkdir(parents=True, exist_ok=True)
(bios / rel).write_bytes(b"v1.3")
(bios / "Other/zesarux/own.rom").write_bytes(b"only zesarux")
files, copies, _cache = generate_db.scan_bios_dir(bios, {}, True)
paths = {entry["path"] for entry in files.values()}
self.assertIn("bios/Sega/Master System/SMS_us_1.3.sms", paths)
self.assertIn("bios/Other/zesarux/own.rom", paths)
self.assertNotIn("bios/Other/zesarux/sms.rom", paths)
self.assertIn(
"bios/Other/zesarux/sms.rom",
{copy["path"] for entries in copies.values() for copy in entries},
)
if __name__ == "__main__":
unittest.main()
+48
View File
@@ -93,6 +93,54 @@ class ForeignTreeNames(unittest.TestCase):
self.assertEqual(status, "data_dir")
self.assertEqual(Path(path).read_bytes(), b"B" * 64)
def _bluemsx_cache(self, rel: str, data: bytes) -> dict:
cache = self.root / "data" / "bluemsx"
(cache / rel).parent.mkdir(parents=True, exist_ok=True)
(cache / rel).write_bytes(data)
return {"bluemsx": {"local_cache": str(cache)}}
def test_a_platform_declaration_reads_the_data_directory_at_its_path(self):
"""AmberELEC declares every blueMSX machine's config.ini with no hash.
The name step met msx-emu's ColecoVision config.ini first and wrote it
into each machine folder, while data/bluemsx held the machine's own
at that very path."""
self._hold("bios/Other/msx-emu/Machines/COL - ColecoVision/config.ini", b"C" * 64)
registry = self._bluemsx_cache("Machines/MSX - Arabic/config.ini", b"A" * 64)
entry = {
"name": "config.ini",
"destination": "bios/Machines/MSX - Arabic/config.ini",
}
path, status = resolve_local_file(entry, self.db, data_dir_registry=registry)
self.assertEqual(status, "path_exact")
self.assertEqual(Path(path).read_bytes(), b"A" * 64)
def test_a_platform_rs232_rom_reads_the_data_directory_at_its_path(self):
self._hold("bios/Microsoft/MSX/RS232.ROM", b"L" * 128)
registry = self._bluemsx_cache("Machines/Shared Roms/RS232.ROM", b"S" * 64)
entry = {
"name": "RS232.ROM",
"destination": "bios/Machines/Shared Roms/RS232.ROM",
}
path, _status = resolve_local_file(entry, self.db, data_dir_registry=registry)
self.assertEqual(Path(path).read_bytes(), b"S" * 64)
def test_a_profile_dump_outranks_the_free_copy_of_its_tree(self):
"""Dolphin's dsp_coef.bin: the dump in bios/ wins over the free
replacement Sys/GC bundles at the same path."""
own = self._hold("bios/Nintendo/GameCube/.variants/dsp_coef.bin.c116d867", b"R" * 64)
cache = self.root / "data" / "dolphin-sys"
(cache / "GC").mkdir(parents=True)
(cache / "GC" / "dsp_coef.bin").write_bytes(b"F" * 64)
entry = {
"name": "dsp_coef.bin", "destination": "GC/dsp_coef.bin",
"source_profile": "dolphin",
}
path, _status = resolve_local_file(
entry, self.db, dest_hint="GC/dsp_coef.bin",
data_dir_registry={"dolphin-sys": {"local_cache": str(cache)}},
)
self.assertEqual(path, own)
def test_another_casing_in_another_tree_is_not_the_file(self):
"""reminiscence's music module reunion took skyline's
zoneinfo/Indian/Reunion, a time-zone file, on the casefold step."""
+25
View File
@@ -439,5 +439,30 @@ class TheSitePageOfACardPlatform(unittest.TestCase):
self.assertIn("No ZIP for MinUI. The command installs every file and checks it.", page)
class TheWholeTreeKeepsCoresMinUILeavesOut(unittest.TestCase):
"""Without --platform, cross_reference and the site's gap report merge
every platform's standalone set. MinUI's per-core folders came along and
left every core MinUI does not list with no layout: px68k showed 0 files
and the global report lost 238 profiles."""
def test_a_core_minui_does_not_list_keeps_its_files(self):
from common import merged_standalone_set, platform_layouts
minui = {"core_system_dirs": {"Bios/FC": {"cores": ["fceumm"]}}}
retroarch = {}
merged = merged_standalone_set([minui, retroarch])
profile = {"type": "libretro", "files": [{"name": "cgrom.tmp"}]}
layouts = platform_layouts("px68k", profile, merged)
self.assertEqual(layouts, [(profile, False)])
def test_both_readers_build_the_set_the_same_way(self):
for script in ("cross_reference.py", "generate_site.py"):
source = (REPO_ROOT / "scripts" / script).read_text(encoding="utf-8")
with self.subTest(script=script):
self.assertIn("merged_standalone_set(", source)
self.assertNotIn("set().union(*(\n standalone_set(", source)
self.assertNotIn("*(standalone_set(cov", source)
if __name__ == "__main__":
unittest.main()
+81
View File
@@ -0,0 +1,81 @@
"""NP2kai and meowPC98 read font.bmp and FONT.ROM as two files.
font_load reads the PC-98 bitmap (font.bmp, FONT.BMP) and then the V98 ROM
(FONT.ROM, font.rom), each through its own reader (NP2kai font/font.c:192-195,
meowPC98 font/font.c:180-181). Hung on font.bmp as aliases, the V98 names let
a collection without font.bmp serve the PC-88's 2 KB font.rom as np2kai/font.bmp,
which fontpc98_read cannot parse, and FONT.ROM was never placed under its name.
"""
from __future__ import annotations
import hashlib
import os
import shutil
import sys
import tempfile
import unittest
from pathlib import Path
import yaml
REPO_ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(REPO_ROOT / "scripts"))
from common import resolve_local_file # noqa: E402
V98_SIZE = 0x46800
def _entry(profile: str, name: str) -> dict:
with open(REPO_ROOT / "emulators" / f"{profile}.yml") as handle:
files = yaml.safe_load(handle)["files"]
entry = next(f for f in files if f.get("name") == name)
return {**entry, "source_profile": profile}
class FontFormatsAreSeparateFiles(unittest.TestCase):
def setUp(self):
(REPO_ROOT / "tmp").mkdir(exist_ok=True)
self.root = Path(tempfile.mkdtemp(dir=REPO_ROOT / "tmp"))
self.addCleanup(shutil.rmtree, self.root, True)
self.addCleanup(os.chdir, os.getcwd())
os.chdir(self.root)
self.db = {"files": {}, "indexes": {
"by_md5": {}, "by_name": {}, "by_crc32": {}, "by_path_suffix": {},
}}
self.pc88 = self._hold("bios/NEC/PC-88/font.rom", b"8" * 2048)
self.v98 = self._hold("bios/NEC/PC-98/font.rom", b"V" * V98_SIZE)
def _hold(self, rel: str, data: bytes) -> str:
target = self.root / rel
target.parent.mkdir(parents=True, exist_ok=True)
target.write_bytes(data)
sha1 = hashlib.sha1(data).hexdigest()
name = rel.rsplit("/", 1)[-1]
self.db["files"][sha1] = {
"path": rel, "name": name, "size": len(data),
"md5": hashlib.md5(data).hexdigest(), "crc32": "",
}
self.db["indexes"]["by_name"].setdefault(name, []).append(sha1)
return rel
def test_no_v98_name_answers_for_the_bitmap(self):
for profile in ("np2kai", "nekop2"):
with self.subTest(profile=profile):
entry = _entry(profile, "font.bmp")
self.assertEqual(resolve_local_file(entry, self.db), (None, "not_found"))
def test_the_v98_font_is_its_own_entry_and_skips_the_pc88_font(self):
for profile in ("np2kai", "nekop2"):
with self.subTest(profile=profile):
entry = _entry(profile, "FONT.ROM")
self.db["indexes"]["by_name"]["FONT.ROM"] = (
self.db["indexes"]["by_name"]["font.rom"]
)
path, _status = resolve_local_file(entry, self.db)
self.assertEqual(path, self.v98)
if __name__ == "__main__":
unittest.main()
+42 -1
View File
@@ -956,7 +956,7 @@ class DsiNandFollowsTheHeaderRegion(unittest.TestCase):
SLOTS = {
"JPN": ["japan"],
"USA": ["north-america"],
"USA": ["north-america", "latin-america"],
"EUR": ["europe"],
"AUS": ["oceania"],
"CHN": ["china"],
@@ -1411,5 +1411,46 @@ class MachineModelRomsCarryNoTerritory(unittest.TestCase):
)
class UsaRegionServesTheAmericas(unittest.TestCase):
"""A code that knows a USA region and no Latin America one selects the
USA file there: Citra's shared font for CFG USA is 0x00014002
(apt.cpp:128-140), and a --region br,cn pack dropped it for the Chinese
archive alone."""
PROFILE = Path(__file__).resolve().parents[1] / "emulators" / "citra-mmj.yml"
FONT = (
"nand/00000000000000000000000000000000/title/0004009b/00014002/"
"content/00000000.app.romfs"
)
def test_brazil_ranks_the_default_shared_font(self):
import yaml
profile = yaml.safe_load(self.PROFILE.read_text(encoding="utf-8"))
index = region.build_region_index({"citra-mmj": profile})
requested = region.parse_requested("br,cn")
for destination, name in (
(self.FONT, "00000000.app.romfs"),
("sysdata/cbf_std.bcfnt", "cbf_std.bcfnt"),
):
with self.subTest(file=destination):
regions = region.lookup_regions(index, destination, name)
self.assertEqual(region.rank(regions, requested), 0)
def test_brazil_ranks_the_usa_dsi_nand_before_the_japanese_one(self):
"""BizHawk's DecideNAND knows JPN, USA, EUR, AUS, CHN and KOR region
bits (MelonDS.cs:684-706): a DSi title from the Americas carries USA."""
import yaml
bizhawk = self.PROFILE.with_name("bizhawk.yml")
profile = yaml.safe_load(bizhawk.read_text(encoding="utf-8"))
index = region.build_region_index({"bizhawk": profile})
requested = region.parse_requested("br,jp")
usa = region.lookup_regions(index, "", "DSi_Nand_USA.bin")
jpn = region.lookup_regions(index, "", "DSi_Nand_JPN.bin")
self.assertEqual(region.rank(usa, requested), 0)
self.assertEqual(region.rank(jpn, requested), 1)
if __name__ == "__main__":
unittest.main()