summaryrefslogtreecommitdiff
path: root/dev/host_io.zig
diff options
context:
space:
mode:
Diffstat (limited to 'dev/host_io.zig')
-rw-r--r--dev/host_io.zig21
1 files changed, 20 insertions, 1 deletions
diff --git a/dev/host_io.zig b/dev/host_io.zig
index 1c4fe332..0efb37fd 100644
--- a/dev/host_io.zig
+++ b/dev/host_io.zig
@@ -2265,7 +2265,7 @@ test "PTY EOF reserve cannot evict terminal output" {
for (0..pardes.MAX_PANES) |pane| queue.push(.{ .eof = .{ .pane = .at(pane), .gen = 1 } });
var batch = queue.take();
defer for (batch.slice()) |msg| msg.deinit(gpa, gpa);
- try std.testing.expectEqual(Inbox.capacity, batch.len);
+ try std.testing.expectEqual(Inbox.output_capacity + pardes.MAX_PANES, batch.len);
for (batch.items[0..Inbox.output_capacity]) |msg| try std.testing.expectEqualStrings("before", msg.output.bytes);
for (batch.items[Inbox.output_capacity..batch.len], 0..) |msg, pane| try std.testing.expectEqual(pane, msg.eof.pane.index());
}
@@ -2302,6 +2302,25 @@ test "a search's rows posted into a full queue wait for room: a take lets them i
}
}
+test "an Adopt's shells are taken in whatever output fills the queue" {
+ const gpa = std.testing.allocator;
+ var queue: Inbox = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa };
+ defer queue.deinit();
+ queue.acceptReader(.at(0), 1);
+ for (0..Inbox.output_capacity) |_| queue.push(.{ .output = .{ .pane = .at(0), .gen = 1, .bytes = try gpa.dupe(u8, "flood") } });
+ var fds: [2]c_int = undefined;
+ if (libc.pipe(&fds) != 0) return error.PipeFailed;
+ defer _ = libc.close(fds[1]);
+ queue.push(.{ .adopted = .{ .pid = 42, .fd = fds[0] } });
+ queue.push(.{ .adopted = .{ .pid = 0, .fd = -1 } });
+ var batch = queue.take();
+ defer for (batch.slice()) |msg| msg.deinit(gpa, gpa);
+ try std.testing.expectEqual(Inbox.output_capacity + 2, batch.len);
+ try std.testing.expectEqual(@as(libc.pid_t, 42), batch.items[Inbox.output_capacity].adopted.pid);
+ try std.testing.expectEqual(fds[0], batch.items[Inbox.output_capacity].adopted.fd);
+ try std.testing.expectEqual(@as(libc.pid_t, 0), batch.items[Inbox.output_capacity + 1].adopted.pid);
+}
+
test "completions retain their arrival order across LSP and pipes" {
const gpa = std.testing.allocator;
var queue: Inbox = .{ .io = std.testing.io, .gpa = gpa, .lsp_allocator = gpa, .lsp_id = 2 };