Files
reverse-engineering-anything/tests/boundary/goRustSubjectArchitecture.test.ts
T
morluto 352a846127 test: reduce brittle assertions and test-only runtime paths (#9289)
* test: focus assertions on behavioral evidence

Prune redundant and wording-coupled checks while retaining diagnostic, parser, recovery, and cleanup coverage.

* refactor: remove test-only wrappers and duplicate checks

Exercise production operations through test fixtures, remove unused adapters, and keep managed-member uncertainty guidance under its existing owner.

* test: focus process validation on diagnostic facts

* refactor: remove test-only runtime helpers

Move semantic evidence fixture setup out of runtime and remove unused Windows settle recovery helpers while checking configured defaults independently.

* test: focus artifact diagnostics on format facts

* test: verify retained cleanup guidance delivery
2026-11-08 02:02:31 +08:00

43 lines
1.7 KiB
TypeScript

import { createHash } from "node:crypto";
import { writeFile } from "node:fs/promises";
import { join } from "node:path";
import { expect, it } from "vitest";
import { GoBinaryService } from "../../src/application/go/GoBinaryService.js";
import { RustBinaryService } from "../../src/application/rust/RustBinaryService.js";
import { elf } from "../../src/domain/binaryTarget.fixture.js";
import { GoBinaryProvider } from "../../src/go/GoBinaryProvider.js";
import { RustBinaryProvider } from "../../src/rust/RustBinaryProvider.js";
import { createTestTempDirectory } from "../fixtures/temporaryDirectory.js";
it.each([
[1, 1, 20, "ppc", "powerpc"],
[1, 2, 20, "ppc", "powerpc"],
[1, 1, 3, "386", "x86"],
[2, 1, 62, "amd64", "x86_64"],
[2, 2, 21, "ppc64", null],
] as const)(
"preserves ELF class%d byte-order%d machine%d in Go and Rust subjects",
async (bits, endian, machine, local, canonical) => {
const root = await createTestTempDirectory("rea-metadata-subject-");
const path = join(root, "header.elf");
const bytes = elf(bits, endian, machine);
await writeFile(path, bytes);
for (const service of [
new GoBinaryService(new GoBinaryProvider()),
new RustBinaryService(new RustBinaryProvider()),
]) {
const result = await service.inspect({ path });
if (!result.ok) throw result.error;
expect(result.value.subject).toMatchObject({
architecture: canonical,
digest: { sha256: createHash("sha256").update(bytes).digest("hex") },
});
expect(result.value.normalized_result).toMatchObject({
architecture: local,
bits: bits === 1 ? 32 : 64,
byte_order: endian === 1 ? "little" : "big",
});
}
},
);