fix(test): make host fixtures portable

This commit is contained in:
morluto
2026-07-16 19:51:25 +08:00
parent b2d1f2affd
commit f23f52903c
11 changed files with 74 additions and 23 deletions
+18 -12
View File
@@ -40,16 +40,22 @@ export const isInitializedPtyRoot = (options: {
readonly before: ProcessIdentitySnapshot;
readonly observedRunId: string | undefined;
readonly after: ProcessIdentitySnapshot;
}): boolean =>
options.before.pid === options.rootPid &&
options.before.process_group_id === options.rootPid &&
options.before.session_id === options.rootPid &&
options.after.pid === options.rootPid &&
options.after.parent_pid === options.before.parent_pid &&
options.after.process_group_id === options.rootPid &&
options.after.session_id === options.rootPid &&
options.after.startTime === options.before.startTime &&
options.observedRunId === options.expectedRunId;
}): boolean => {
const sessionIdentityMatches =
(options.before.session_id === options.rootPid &&
options.after.session_id === options.rootPid) ||
(options.before.session_id === null && options.after.session_id === null);
return (
options.before.pid === options.rootPid &&
options.before.process_group_id === options.rootPid &&
sessionIdentityMatches &&
options.after.pid === options.rootPid &&
options.after.parent_pid === options.before.parent_pid &&
options.after.process_group_id === options.rootPid &&
options.after.startTime === options.before.startTime &&
options.observedRunId === options.expectedRunId
);
};
const isExpectedProcReadFailure = (cause: unknown): boolean =>
cause instanceof Error &&
@@ -315,7 +321,7 @@ const readPsRows = async (
pid: Number(match[1]),
parent_pid: Number(match[2]),
process_group_id: Number(match[3]),
session_id: Number(match[4]),
session_id: Number(match[4]) || null,
command: match[5] ?? "",
startTime: undefined,
}))
@@ -346,7 +352,7 @@ const inspectInitializedPtyRoot = async (
if (
before === undefined ||
before.process_group_id !== rootPid ||
before.session_id !== rootPid
(before.session_id !== rootPid && before.session_id !== null)
)
return undefined;
let observedRunId: string | undefined;
+2
View File
@@ -63,6 +63,8 @@ export interface GhidraJavaObservation {
/** Narrow synchronous seam used by provider discovery without launching Ghidra. */
export interface GhidraInstallationHost {
readonly platform?: NodeJS.Platform;
readonly architecture?: NodeJS.Architecture;
readText(path: string): string | undefined;
executable(path: string): boolean;
probeJava(
+6
View File
@@ -415,6 +415,12 @@ export class GhidraProvider implements AnalysisProviderCandidate {
...(this.config.ghidraJavaHome === undefined
? {}
: { javaHome: this.config.ghidraJavaHome }),
...(this.installationHost?.platform === undefined
? {}
: { platform: this.installationHost.platform }),
...(this.installationHost?.architecture === undefined
? {}
: { architecture: this.installationHost.architecture }),
};
this.#installation ??=
this.installationHost === undefined