mirror of
https://github.com/morluto/rea.git
synced 2026-11-14 18:52:48 +00:00
The chained-import CLI test ran xcrun through a bare execFile, outside the test's process registry, so a stalled compiler or dyld_info could outlive the test; it now uses the processes fixture. The slice selection refusal tests compared whole English messages; they now check the refusal kind, the offered selector, and that the selector works. Refs #8723 Refs #9792 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com>
73 lines
2.3 KiB
TypeScript
73 lines
2.3 KiB
TypeScript
import { writeFile } from "node:fs/promises";
|
|
import { join } from "node:path";
|
|
|
|
import { describe, expect } from "vitest";
|
|
|
|
import { createTestTempDirectory } from "../../fixtures/temporaryDirectory.js";
|
|
import { cliTest } from "../../support/cli/cliFixture.js";
|
|
|
|
describe.skipIf(process.platform !== "darwin")(
|
|
"native Mach-O CLI chained import names",
|
|
() => {
|
|
cliTest(
|
|
"names a weak-def-coalesce import that the undefined symbol table omits",
|
|
async ({ cli, processes }) => {
|
|
const directory = await createTestTempDirectory("rea-macho-imports-");
|
|
const source = join(directory, "coalesce.cpp");
|
|
// Taking an exported inline function's address makes the linker bind
|
|
// it through <weak-def-coalesce>, as a defined weak symbol.
|
|
await writeFile(
|
|
source,
|
|
[
|
|
'inline __attribute__((visibility("default"))) int inl(int x) { return x * 3; }',
|
|
'__attribute__((visibility("default"))) int (*getinl())(int) { return &inl; }',
|
|
"",
|
|
].join("\n"),
|
|
);
|
|
const library = join(directory, "libcoalesce.dylib");
|
|
const compiled = await processes.run("/usr/bin/xcrun", [
|
|
"clang++",
|
|
"-arch",
|
|
"arm64",
|
|
"-dynamiclib",
|
|
source,
|
|
"-o",
|
|
library,
|
|
]);
|
|
expect(compiled.exitCode, compiled.stderr).toBe(0);
|
|
const imports = await processes.run("/usr/bin/xcrun", [
|
|
"dyld_info",
|
|
"-imports",
|
|
library,
|
|
]);
|
|
expect(imports.exitCode, imports.stderr).toBe(0);
|
|
expect(imports.stdout).toMatch(
|
|
/__Z3inli {2}\(from <weak-def-coalesce>\)/u,
|
|
);
|
|
const result = await cli.run({
|
|
arguments: ["inspect-macho", library, "--json"],
|
|
environment: {
|
|
REA_LOG_LEVEL: "silent",
|
|
REA_ANALYSIS_PROVIDER: "auto",
|
|
},
|
|
});
|
|
expect(result.exitCode, result.stdout).toBe(0);
|
|
expect(result.json).toMatchObject({
|
|
normalized_result: {
|
|
imports: {
|
|
items: [
|
|
{
|
|
name: "__Z3inli",
|
|
name_status: "exact",
|
|
source: "<weak-def-coalesce>",
|
|
},
|
|
],
|
|
},
|
|
},
|
|
});
|
|
},
|
|
60_000,
|
|
);
|
|
},
|
|
);
|