summaryrefslogtreecommitdiff
path: root/test/process/other_files.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-04 16:24:25 -0300
committerGabriel Schneider <[email protected]>2026-11-04 16:24:25 -0300
commitbe3985092df1c3388cfa09ca5e989d2fa66f55ec (patch)
treea45695a2f486e4cb55789940ff9c5d15460efdeb /test/process/other_files.zig
parentb3ef9fb0be86471973331d409adf641beb63e685 (diff)
downloadpardes-be3985092df1c3388cfa09ca5e989d2fa66f55ec.tar.gz
pardes-be3985092df1c3388cfa09ca5e989d2fa66f55ec.zip
test: the process runner's held connection and options, for the Python ports: process.Conn, one blocking 9P2000 connection over a unix socket on cloud9's client (walk, hold, readFid, writeFid, clunk, read, write, remove, stat, list), the last refusal's words in said; Detached.Options (args before the file, the file, more environment, a root shared with another session, the socket's name) and put, get, signal, exited (the wait word), socket; a second process test drives the held connection against a real session
Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'test/process/other_files.zig')
-rw-r--r--test/process/other_files.zig32
1 files changed, 31 insertions, 1 deletions
diff --git a/test/process/other_files.zig b/test/process/other_files.zig
index 178b20cd..d03d6b36 100644
--- a/test/process/other_files.zig
+++ b/test/process/other_files.zig
@@ -5,6 +5,7 @@ const process = @import("../process.zig");
pub const cases = .{
.{ "other-files: kbdin and mousein drive a detached session as the user would, each write done before it is answered", keysAndMouse },
+ .{ "other-files: a held connection lists a directory, stats a file, writes and reads, is refused in words and removes a pane", heldConnection },
};
/// A script types and clicks as the user does: no sleep or poll between a
@@ -12,7 +13,7 @@ pub const cases = .{
/// (test/fs.py's keys_and_mouse, the first case written through the files
/// alone.)
fn keysAndMouse(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
- var d = try process.Detached.start(gpa, exe, "kbd");
+ var d = try process.Detached.start(gpa, exe, "kbd", .{});
defer d.deinit();
const f = &d.files;
var buf: [4096]u8 = undefined;
@@ -34,3 +35,32 @@ fn keysAndMouse(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
try f.keys("u");
try f.expect(f.at("/pane/{d}/body", .{serial}), "see \n");
}
+
+/// The runner's held connection, against a real session: a directory's
+/// entries, a stat, an open held while another write lands, a remove.
+fn heldConnection(gpa: std.mem.Allocator, exe: [:0]const u8) !void {
+ var d = try process.Detached.start(gpa, exe, "conn", .{});
+ defer d.deinit();
+ const c = try process.Conn.dial(gpa, d.socket());
+ defer c.deinit(gpa);
+ const names = try c.list(gpa, "/");
+ defer {
+ for (names) |n| gpa.free(n);
+ gpa.free(names);
+ }
+ var has_index = false;
+ for (names) |n| has_index = has_index or std.mem.eql(u8, n, "index");
+ try std.testing.expect(has_index);
+ try std.testing.expect((try c.stat("/kbdin")).mode & 0o222 != 0);
+ const serial = try std.fmt.parseInt(u32, std.mem.trim(u8, try d.files.read("/pane/new"), "\n"), 10);
+ var path: [64]u8 = undefined;
+ const body = try std.fmt.bufPrint(&path, "/pane/{d}/body", .{serial});
+ try c.write(body, "held\n");
+ const got = try c.read(gpa, body);
+ defer gpa.free(got);
+ try std.testing.expectEqualStrings("held\n", got);
+ try std.testing.expectError(error.Refused, c.write("/mousein", "nonsense\n"));
+ try std.testing.expect(c.said.len > 0);
+ try c.remove(try std.fmt.bufPrint(&path, "/pane/{d}", .{serial}));
+ try std.testing.expectError(error.NotFound, c.walk(body));
+}