fix(process): stabilize native capture and ownership prerequisites

This commit is contained in:
morluto
2026-10-09 06:49:02 +08:00
parent 44fd18305f
commit 2b27515476
11 changed files with 341 additions and 114 deletions
@@ -548,7 +548,6 @@ it.skipIf(!onDarwin)(
clearedAppleVectorTokenFailsClosed: true,
callerPfzBeforeTokenRead: true,
emptyLaterArgumentRead: true,
emptyEnvironmentFailsClosed: true,
emptyArgv0Read: true,
emptyEnvironmentRecordsBeforeTokenFailClosed: true,
duplicateTokenFailsClosed: true,
@@ -677,7 +676,7 @@ it.skipIf(!onDarwin)(
);
it.skipIf(!onDarwin)(
"reads owned tokens with empty later arguments across executable path padding",
"reads owned tokens across executable padding and distinguishes a real empty environment",
async () => {
const root = await mkdtemp(join(tmpdir(), "rea-process-token-padding-"));
const host = createSystemProcessOwnershipHost("darwin");
@@ -699,6 +698,7 @@ it.skipIf(!onDarwin)(
),
);
}
children.push(await startNodeChild({}));
const processes = await host.listProcesses();
const entries = children.map(({ pid }) => {
const entry = processes.find((process) => process.pid === pid);
@@ -710,6 +710,7 @@ it.skipIf(!onDarwin)(
expect(children.map(({ pid }) => observations?.get(pid))).toEqual([
{ state: "readable", runId: "synthetic-padding-0" },
{ state: "readable", runId: "synthetic-padding-1" },
{ state: "readable" },
]);
} finally {
for (const { child } of children) await stopNodeChild(child);
+3 -1
View File
@@ -4,6 +4,7 @@ let app = NSApplication.shared
app.setActivationPolicy(.accessory)
let window = NSWindow(contentRect: NSRect(x: 120, y: 120, width: 360, height: 180), styleMask: [.titled, .closable], backing: .buffered, defer: false)
window.title = "REA source-owned UI verification"
window.animationBehavior = .none
final class FixtureController: NSObject {
@objc func increment(_ sender: NSButton) { sender.title = "REA fixture incremented" }
}
@@ -13,7 +14,8 @@ button.title = "Increment REA fixture"
button.target = controller
button.action = #selector(FixtureController.increment(_:))
window.contentView?.addSubview(button)
window.orderFront(nil)
window.makeKeyAndOrderFront(nil)
app.activate(ignoringOtherApps: true)
DispatchQueue.main.asyncAfter(deadline: .now() + 0.5) {
let record = "{\"pid\":\(ProcessInfo.processInfo.processIdentifier),\"window_id\":\(window.windowNumber)}\n"
FileHandle.standardOutput.write(Data(record.utf8))
-8
View File
@@ -132,13 +132,6 @@ struct ProcessRunTokenParserProbe {
} catch RunTokenReadError.duplicateToken {
duplicateTokenFailsClosed = true
}
let emptyEnvironmentFailsClosed: Bool
do {
_ = try token(in: fixture(arguments: ["/fixture/executable"], environment: []))
emptyEnvironmentFailsClosed = false
} catch RunTokenReadError.environmentUnavailable {
emptyEnvironmentFailsClosed = true
}
let missingAppleBoundaryFailsClosed: Bool
do {
_ = try token(in: fixture(
@@ -158,7 +151,6 @@ struct ProcessRunTokenParserProbe {
"alternatePaddingRead": alternatePadding == "alternate-padding-token",
"truncatedArgvFailsClosed": truncatedArgvFailsClosed,
"duplicateTokenFailsClosed": duplicateTokenFailsClosed,
"emptyEnvironmentFailsClosed": emptyEnvironmentFailsClosed,
"missingAppleBoundaryFailsClosed": missingAppleBoundaryFailsClosed,
"emptyArgv0Read": emptyArgv0Read == "empty-argv0-token",
"finalAssignmentArgumentRead": finalAssignmentArgumentRead == "final-assignment-token",