diff --git a/tests/system/ci-runner/ci-artifact-contract.test.ts b/tests/system/ci-runner/ci-artifact-contract.test.ts index 4982fae0..f74bf8b2 100644 --- a/tests/system/ci-runner/ci-artifact-contract.test.ts +++ b/tests/system/ci-runner/ci-artifact-contract.test.ts @@ -790,7 +790,6 @@ describe("candidate archive and provider upload boundaries", () => { await expect(readFile(path.join(cgroupRoot, "pids.max"), "utf8")).resolves.toBe("64\n"); await expect(readFile(path.join(cgroupRoot, "cpu.max"), "utf8")).resolves.toBe("100000 100000\n"); expect(readProviderUnitMetadata(unit)).not.toMatch(new RegExp(`${command}|${credential}`, "u")); - expect(showProcessArguments(execution.child.pid)).not.toMatch(new RegExp(`${command}|${credential}`, "u")); const reportIdentity = await lstat(fixture.reportPath); const result = await execution.completion; tree.stop(); @@ -806,8 +805,13 @@ describe("candidate archive and provider upload boundaries", () => { const processArguments = tree.cgroupArguments(); const directChildPids = tree.directChildPids(); const directChildArguments = tree.directChildArguments(); + // The supervisor's argv comes from the recording too: once `completion` + // resolves Node has reaped it, so a lookup by PID here can only fail. + const supervisorArguments = tree.supervisorArguments(); + expect(supervisorArguments.join("\n"), "supervisor never observed").toContain("run-and-validate-provider.ts"); + expect(supervisorArguments.join("\n")).not.toMatch(new RegExp(`${command}|${credential}`, "u")); const observedArguments = [ - showProcessArguments(execution.child.pid), + ...supervisorArguments, ...directChildArguments, ...processArguments, ]; @@ -1899,6 +1903,10 @@ function readProcessArguments(pid: number): string | null { * the right instant?" into "what did this run actually contain?". */ function recordProviderProcessTree(supervisorPid: number) { + // Every distinct value, not just the first: a process can rewrite its own + // argv (`process.title`) mid-run, and the supervisor is the process whose + // argv a later lookup can no longer see. + const supervisorArguments = new Set(); const directChildren = new Map(); const cgroupMembers = new Map(); let stopped = false; @@ -1935,6 +1943,8 @@ function recordProviderProcessTree(supervisorPid: number) { }; const sample = (): void => { if (stopped) return; + const own = readProcessArguments(supervisorPid); + if (own) supervisorArguments.add(own); const direct = childrenOf(supervisorPid); for (const pid of direct) remember(directChildren, pid); // Walk the whole subtree: the scope wrapper, bubblewrap and the provider @@ -1959,6 +1969,7 @@ function recordProviderProcessTree(supervisorPid: number) { stopped = true; clearInterval(timer); }, + supervisorArguments: () => [...supervisorArguments], directChildPids: () => [...directChildren.keys()], directChildArguments: () => [...directChildren.values()], cgroupPids: () => [...cgroupMembers.keys()],