mirror of
https://github.com/morluto/rea.git
synced 2026-11-09 16:26:36 +00:00
* test: focus configuration diagnostics on their owners Preserve shape errors, selected paths, recovery guidance, and unchanged-file behavior across parser, setup, and uninstall boundaries. * test: focus artifact and evidence checks on behavior Retain format, identity, malformed-input, and cleanup coverage while removing fixed prose and closing the admitted test source. * refactor(debugger): use configured session admission limits * test: focus evidence and diagnostics on behavior * fix(test): restore verifier export and formatting * test(config): verify debugger limit ranges * test(rizin): keep fixture executable authoritative * test(rizin): isolate debugger fixture environment
61 lines
1.9 KiB
TypeScript
61 lines
1.9 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { readElfDynamicEntry } from "./elfDynamicEntry.js";
|
|
|
|
const formats = [
|
|
{ bits: 32, littleEndian: false },
|
|
{ bits: 32, littleEndian: true },
|
|
{ bits: 64, littleEndian: false },
|
|
{ bits: 64, littleEndian: true },
|
|
] as const;
|
|
|
|
it.each(formats)(
|
|
"preserves signed ELF$bits tags and unsigned values (littleEndian=$littleEndian)",
|
|
({ bits, littleEndian }) => {
|
|
const wide = bits === 64;
|
|
const length = wide ? 16 : 8;
|
|
const backing = Buffer.alloc(length + 19, 0xa5);
|
|
const bytes = backing.subarray(7, 7 + length);
|
|
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
const tag = wide ? -0x8000000000000000n : -0x80000000n;
|
|
const value = wide ? 0xffffffffffffffffn : 0xffffffffn;
|
|
if (wide) {
|
|
view.setBigInt64(0, tag, littleEndian);
|
|
view.setBigUint64(8, value, littleEndian);
|
|
} else {
|
|
view.setInt32(0, Number(tag), littleEndian);
|
|
view.setUint32(4, Number(value), littleEndian);
|
|
}
|
|
const before = Buffer.from(backing);
|
|
const parsed = readElfDynamicEntry(backing.subarray(7), bits, littleEndian);
|
|
expect(backing.equals(before)).toBe(true);
|
|
backing.fill(0);
|
|
expect(parsed).toEqual({ ok: true, value: { tag, value } });
|
|
expect(readElfDynamicEntry(bytes, bits, littleEndian)).toEqual({
|
|
ok: true,
|
|
value: { tag: 0n, value: 0n },
|
|
});
|
|
},
|
|
);
|
|
|
|
it.each(formats)(
|
|
"refuses incomplete ELF$bits dynamic entries (littleEndian=$littleEndian)",
|
|
({ bits, littleEndian }) => {
|
|
const length = bits === 64 ? 16 : 8;
|
|
const backing = Buffer.alloc(length + 7);
|
|
for (let observed = 0; observed < length; observed++)
|
|
expect(
|
|
readElfDynamicEntry(
|
|
backing.subarray(7, 7 + observed),
|
|
bits,
|
|
littleEndian,
|
|
),
|
|
).toEqual({
|
|
ok: false,
|
|
error: {
|
|
kind: "malformed",
|
|
message: expect.stringContaining("truncated"),
|
|
},
|
|
});
|
|
},
|
|
);
|