test(hopper): repair Linux demo setup and native verification (#2638)
* fix(verification): align Linux Hopper setup lane with current contracts * fix(verification): retain orphan checks on clean Linux runners * fix(verification): detect Hopper through alternate launcher paths * fix(verification): report identified Hopper leaks before proc errors * fix(verification): distinguish Hopper string recognition from byte fidelity * fix(verification): report full literal decoding coverage explicitly --------- Co-authored-by: Luis Taffelli <86675342+LuisTaffelli@users.noreply.github.com>
This commit is contained in:
co-authored by
Luis Taffelli
parent
18831491cf
commit
141d2095f5
@@ -5,13 +5,24 @@ volatile int rea_c_global = 7;
|
||||
#define REA_LONG_CHUNK "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
|
||||
#define REA_LONG_256 REA_LONG_CHUNK REA_LONG_CHUNK REA_LONG_CHUNK REA_LONG_CHUNK
|
||||
#define REA_LONG_1024 REA_LONG_256 REA_LONG_256 REA_LONG_256 REA_LONG_256
|
||||
/* Keep the full-size literal even when a loader does not type it as a string. */
|
||||
__attribute__((used)) const char rea_long_literal[] =
|
||||
"REA_LONG_LITERAL_" REA_LONG_1024 REA_LONG_1024 REA_LONG_1024 REA_LONG_1024 "needle";
|
||||
/* Linux Hopper 6.4.2 recognizes this extent and splits it into native objects. */
|
||||
__attribute__((used)) const char rea_fragmented_literal[] =
|
||||
"REA_FRAGMENTED_LITERAL_" REA_LONG_256 REA_LONG_256 "fragment_tail";
|
||||
__attribute__((used)) const char rea_utf8_literal[] = "REA_UTF8_é_😀";
|
||||
__attribute__((used)) const char rea_ellipsis_literal[] = "REA_LITERAL_…";
|
||||
__attribute__((used)) const char rea_latin1_literal[] = "REA_LATIN1_\xff";
|
||||
|
||||
__attribute__((noinline, used)) void rea_long_literal_procedure(void) {
|
||||
puts("REA_LONG_LITERAL_" REA_LONG_1024 REA_LONG_1024 REA_LONG_1024 REA_LONG_1024 "needle");
|
||||
puts("REA_UTF8_é_😀");
|
||||
puts(rea_long_literal);
|
||||
puts(rea_fragmented_literal);
|
||||
puts(rea_utf8_literal);
|
||||
puts("REA_ESCAPED_\"\\line\nend\t\r");
|
||||
puts("REA_LITERAL_BACKSLASH_\\n");
|
||||
puts("REA_LITERAL_…");
|
||||
puts("REA_LATIN1_\xff");
|
||||
puts(rea_ellipsis_literal);
|
||||
puts(rea_latin1_literal);
|
||||
}
|
||||
|
||||
__attribute__((noinline, used)) int rea_leaf(int value) {
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
import { expect, it } from "vitest";
|
||||
|
||||
import { verifyHopperStringObjects } from "../../../../scripts/lib/real-hopper-search.mjs";
|
||||
|
||||
const value = "REA_UTF8_é_😀";
|
||||
const address = "0x402020";
|
||||
const bytes = Buffer.from(`${value}\0`);
|
||||
const item = {
|
||||
address,
|
||||
value,
|
||||
string: {
|
||||
encoding: "utf-8",
|
||||
encoding_status: "inferred" as const,
|
||||
termination: "present_or_not_required" as const,
|
||||
byte_length: bytes.length,
|
||||
},
|
||||
};
|
||||
const expectation = {
|
||||
value,
|
||||
encoding: "utf-8",
|
||||
symbol: "rea_utf8_literal",
|
||||
recognitionOptional: true,
|
||||
};
|
||||
|
||||
it("keeps source identity and unknown decoding when the same text exists elsewhere", async () => {
|
||||
const report = await verifyHopperStringObjects(
|
||||
fixtureCall(),
|
||||
[expectation],
|
||||
[{ ...item, address: "0x403000" }],
|
||||
);
|
||||
expect(report.recognition).toEqual([
|
||||
{ value, address, state: "not_observed", decodedObject: "unverified" },
|
||||
]);
|
||||
});
|
||||
|
||||
it("reuses source bytes and inventory while checking real address filters and searches", async () => {
|
||||
const calls: string[] = [];
|
||||
const report = await verifyHopperStringObjects(
|
||||
fixtureCall(calls),
|
||||
[expectation],
|
||||
[item],
|
||||
);
|
||||
expect(report.recognition).toEqual([
|
||||
{ value, address, state: "observed", decodedObject: "verified" },
|
||||
]);
|
||||
expect(calls).toEqual([
|
||||
"read_bytes:rea_utf8_literal",
|
||||
`list_strings:${address}`,
|
||||
`search_strings:${value}`,
|
||||
"search_strings:\\xC3\\xA9",
|
||||
]);
|
||||
});
|
||||
|
||||
it.each([
|
||||
["changed source bytes", { bytes_hex: "00" }, item],
|
||||
["incomplete source read", { complete: false }, item],
|
||||
["wrong decoded value", {}, { ...item, value: "wrong" }],
|
||||
[
|
||||
"wrong decoded extent",
|
||||
{},
|
||||
{ ...item, string: { ...item.string, byte_length: 1 } },
|
||||
],
|
||||
])(
|
||||
"rejects %s even when native recognition is optional",
|
||||
async (_label, override, decoded) => {
|
||||
await expect(
|
||||
verifyHopperStringObjects(
|
||||
fixtureCall([], override),
|
||||
[expectation],
|
||||
[decoded],
|
||||
),
|
||||
).rejects.toThrow();
|
||||
},
|
||||
);
|
||||
|
||||
function fixtureCall(
|
||||
calls: string[] = [],
|
||||
override: Record<string, unknown> = {},
|
||||
) {
|
||||
return async (name: string, arguments_: Record<string, unknown> = {}) => {
|
||||
calls.push(
|
||||
`${name}:${String(arguments_.address ?? arguments_.pattern ?? "")}`,
|
||||
);
|
||||
if (name === "read_bytes")
|
||||
return {
|
||||
address,
|
||||
bytes_hex: bytes.toString("hex"),
|
||||
complete: true,
|
||||
...override,
|
||||
};
|
||||
if (name === "list_strings" && arguments_.address === address)
|
||||
return [item];
|
||||
if (name === "search_strings")
|
||||
return arguments_.pattern === value ? [item] : [];
|
||||
throw new Error(`Unmodeled verifier call: ${name}`);
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user