mirror of
https://github.com/morluto/rea.git
synced 2026-10-12 02:19:24 +00:00
Validate Mach command counts, byte totals, scalar uniqueness, section counts, and build-tool counts before claiming exhaustive evidence. Preserve raw output in typed parsing failures and distinguish dylib commands from the dynamic loader. Correct inconsistent handcrafted fixtures and label their provenance. Validation: 38 native tests, combined checks, and temporary-directory hygiene. Multiline dylib-name ambiguity was reproduced with the host Apple otool; regression workflows use captured output and injected command runners.
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { parseOtoolLoadCommands } from "../../../../src/native/parsers/otool.js";
|
|
import {
|
|
nativeFixture,
|
|
withOtoolMachHeader,
|
|
} from "../../../fixtures/nativeCommands.js";
|
|
it.each([
|
|
["decimal-space", "123 library.dylib"],
|
|
["hex-space", "0x123 library.dylib"],
|
|
["decimal", "123"],
|
|
["hex", "0x123"],
|
|
["ordinary", "ordinary.dylib"],
|
|
])("preserves native install-name text from %s capture", async (slug, name) => {
|
|
const load = parseOtoolLoadCommands(
|
|
withOtoolMachHeader(
|
|
await nativeFixture(`load-command-text-values/${slug}.txt`),
|
|
),
|
|
);
|
|
expect(load.dependencies).toContainEqual({
|
|
path: name,
|
|
kind: "LC_ID_DYLIB",
|
|
current_version: "0.0.0",
|
|
compatibility_version: "0.0.0",
|
|
});
|
|
expect(
|
|
load.commands.find((command) => command.kind === "LC_ID_DYLIB")?.fields
|
|
.name,
|
|
).toBe(`${name} (offset 24)`);
|
|
const text = load.segments.find((segment) => segment.name === "__TEXT");
|
|
expect(text).toMatchObject({
|
|
file_offset: 0,
|
|
file_size: 16384,
|
|
initial_permissions: { read: true, write: false, execute: true },
|
|
});
|
|
expect(
|
|
load.commands.find((command) => command.kind === "LC_SEGMENT_64")?.fields
|
|
.cmdsize,
|
|
).toBe(232);
|
|
});
|