This commit is contained in:
hashbro
2026-08-08 05:00:54 +08:00
parent 6447081ed9
commit 91196b8832
7 changed files with 141 additions and 11 deletions
+26
View File
@@ -13,6 +13,7 @@ TOOLS_ROOT = FRONTEND_ROOT / "tools"
sys.path.insert(0, str(TOOLS_ROOT))
from _common import ( # noqa: E402
CORE_DYLIB,
GROUP_DYLIBS,
ORIGINAL_DEPLOYMENT_SEED,
ORIGINAL_REPORTING_SEED,
@@ -101,6 +102,31 @@ class InitialDailyPathPatchTests(unittest.TestCase):
with self.assertRaisesRegex(SystemExit, "unsupported Mach-O UUID"):
patch_initial_daily_path(bytes(source), TEST_CHANNEL)
def test_fat_core_retargets_both_slices(self) -> None:
source = CORE_DYLIB.read_bytes()
self.assertEqual(source[:4], bytes.fromhex("cafebabe"))
patched, metadata = patch_initial_daily_path(
source, TEST_CHANNEL, label=CORE_DYLIB.name
)
self.assertEqual(metadata["container"], "fat")
expected = PATH_TEMPLATE.format(channel=TEST_CHANNEL).encode() + b"\x00"
self.assertEqual(metadata["path"], expected[:-1].decode())
slices = metadata["slices"]
self.assertEqual(len(slices), 2)
self.assertEqual(
{item["architecture"] for item in slices},
{"arm64", "arm64e"},
)
for item in slices:
slice_off = int(item["fat_slice_offset"])
cave = slice_off + int(item["path_file_offset"])
cfstring = slice_off + int(item["cfstring_file_offset"])
self.assertEqual(patched[cave : cave + len(expected)], expected)
self.assertEqual(
struct.unpack_from("<Q", patched, cfstring + 24)[0],
len(expected) - 1,
)
def test_secondary_pack_manifest_records_native_path_patch(self) -> None:
with tempfile.TemporaryDirectory() as temp:
command = [