test(signals): verify native decoder discovery coverage (#2818)
* test(signals): verify native decoder discovery coverage Compare catalog and help pages against independent native sigrok output, including full coverage counts, empty matches and boundary offsets. Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> * style(test): format the JVM class fixture * fix(comparison): recheck historical calls-only changes (#2223) * fix(comparison): preserve incomplete function call evidence Keep missing, unknown, partial and unresolved call relationships unknown in function comparisons and reconstruction claims. Aggregate IDA caller and callee coverage without overwriting uncertainty. Validate with 144 focused tests, typecheck/lint, docs checks and test discovery. Real providers were not verified; the full headless IDA session suite requires unavailable Windows native controls. * fix(comparison): recheck historical calls-only changes --------- Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> * fix(ci): isolate Linux Hopper process fixture inventory --------- Co-authored-by: Kaoru0822 <208281322+kaoru0822-kitauji@users.noreply.github.com> Co-authored-by: morluto <76467478+morluto@users.noreply.github.com> Co-authored-by: Lucien <164857476+dakjdakd@users.noreply.github.com>
This commit is contained in:
co-authored by
Kaoru0822
morluto
Lucien
parent
3cb9d61ec1
commit
87a8c8c923
@@ -276,12 +276,41 @@ try {
|
||||
)
|
||||
).stdout.split(/\r?\n/);
|
||||
if (nativeHelp.at(-1) === "") nativeHelp.pop();
|
||||
const nativeCatalogText = (
|
||||
await execute(
|
||||
process.env.REA_SIGROK_COMMAND,
|
||||
["--dont-scan", "--list-supported"],
|
||||
{ env: environment, timeout: 30000, maxBuffer: 4 * 1024 * 1024 },
|
||||
)
|
||||
).stdout;
|
||||
const catalogHeading = "Supported protocol decoders:\n";
|
||||
assert.ok(nativeCatalogText.includes(catalogHeading));
|
||||
// Independent native-output oracle, without importing the production parser.
|
||||
const nativeCatalog = nativeCatalogText
|
||||
.split(catalogHeading)[1]
|
||||
.trim()
|
||||
.split("\n")
|
||||
.map((line) => {
|
||||
const record = line.trimStart();
|
||||
const separator = record.indexOf(" ");
|
||||
assert.ok(separator > 0);
|
||||
return {
|
||||
id: record.slice(0, separator),
|
||||
name: record.slice(separator).trimStart(),
|
||||
};
|
||||
});
|
||||
assert.ok(nativeCatalog.length > 0);
|
||||
for (const input of [
|
||||
{ query: "uart" },
|
||||
{},
|
||||
{ query: "UaRt" },
|
||||
{ limit: 1 },
|
||||
{ offset: 1, limit: 2 },
|
||||
{ limit: null },
|
||||
{ offset: nativeCatalog.length, limit: 2 },
|
||||
{ decoder: "uart" },
|
||||
{ decoder: "uart", query: "BaUd" },
|
||||
{ decoder: "uart", offset: 50, limit: null },
|
||||
{ decoder: "uart", query: "[" },
|
||||
{ query: "rea_no_such_decoder" },
|
||||
]) {
|
||||
const started = performance.now();
|
||||
@@ -306,23 +335,28 @@ try {
|
||||
JSON.stringify(response),
|
||||
),
|
||||
});
|
||||
if (input.decoder) {
|
||||
const matched = nativeHelp
|
||||
.map((text, i) => ({ line_number: i + 1, text }))
|
||||
.filter(({ text }) =>
|
||||
text.toLowerCase().includes((input.query ?? "").toLowerCase()),
|
||||
);
|
||||
assert.deepEqual(
|
||||
report.help_lines,
|
||||
matched.slice(
|
||||
input.offset ?? 0,
|
||||
input.limit === null
|
||||
? undefined
|
||||
: (input.offset ?? 0) + (input.limit ?? 50),
|
||||
),
|
||||
);
|
||||
} else if (input.query === "uart")
|
||||
assert.ok(report.decoders.some(({ id }) => id === "uart"));
|
||||
const nativeRecords = input.decoder
|
||||
? nativeHelp.map((text, i) => ({ line_number: i + 1, text }))
|
||||
: nativeCatalog;
|
||||
const matched = nativeRecords.filter((record) =>
|
||||
("text" in record ? record.text : `${record.id} ${record.name}`)
|
||||
.toLowerCase()
|
||||
.includes((input.query ?? "").toLowerCase()),
|
||||
);
|
||||
const offset = input.offset ?? 0;
|
||||
const page = matched.slice(
|
||||
offset,
|
||||
input.limit === null ? undefined : offset + (input.limit ?? 50),
|
||||
);
|
||||
assert.deepEqual(input.decoder ? report.help_lines : report.decoders, page);
|
||||
assert.deepEqual(input.decoder ? report.decoders : report.help_lines, []);
|
||||
assert.deepEqual(report.output_window, {
|
||||
unit: input.decoder ? "help-lines" : "decoders",
|
||||
examined: nativeRecords.length,
|
||||
matching: matched.length,
|
||||
returned: page.length,
|
||||
has_more: offset + page.length < matched.length,
|
||||
});
|
||||
const flags = Object.entries(input).flatMap(([key, value]) =>
|
||||
value === null ? ["--all"] : [`--${key}`, String(value)],
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user