Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
test(artifacts): read /bin/ls slice layout from its FAT table
The real-lipo slice test pinned the byte offsets and sizes of one macOS
release's /bin/ls, so it failed on any host whose /bin/ls differs
(macOS 26.7.1: x86_64 48128 bytes, arm64e 88672, versus the pinned 48112
and 89088). Read the expected layout from the binary's FAT header
instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
  • Loading branch information
kaoru0822-kitauji and claude committed Oct 9, 2026
commit 09e8a7712d6753ffec745ddbc6c14c32e6e65375
22 changes: 18 additions & 4 deletions src/artifacts/MachOSliceArtifactReader.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,24 @@
import { readFile } from "node:fs/promises";

import { describe, expect, it } from "vitest";

import { MachOSliceArtifactReader } from "./MachOSliceArtifactReader.js";

/**
* Read a 32-bit FAT table directly. The host's /bin/ls changes between macOS
* releases, so the expected slice layout comes from the file itself.
*/
const fatSlices = async (
path: string,
): Promise<readonly (readonly [number, number])[]> => {
const bytes = await readFile(path);
expect(bytes.readUInt32BE(0)).toBe(0xca_fe_ba_be);
return Array.from({ length: bytes.readUInt32BE(4) }, (_, index) => {
const entry = 8 + index * 20;
return [bytes.readUInt32BE(entry + 8), bytes.readUInt32BE(entry + 12)];
});
};

describe("Mach-O slice reader with system lipo", () => {
it.skipIf(process.platform !== "darwin")(
"checks real /bin/ls lipo CPU symbols and ptrauth capabilities against the FAT table",
Expand All @@ -18,10 +35,7 @@ describe("Mach-O slice reader with system lipo", () => {
byteOffset,
declaredSize,
]),
).toEqual([
[16384, 48112],
[65536, 89088],
]);
).toEqual(await fatSlices("/bin/ls"));
},
);
});
Loading