summaryrefslogtreecommitdiff
path: root/src/ninep/addr.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/ninep/addr.zig')
-rw-r--r--src/ninep/addr.zig16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ninep/addr.zig b/src/ninep/addr.zig
index f7642b9e..566e2364 100644
--- a/src/ninep/addr.zig
+++ b/src/ninep/addr.zig
@@ -255,17 +255,25 @@ test "the address language, form by form" {
try testing.expectEqual(@as(u32, 6), p.fs.panes[0].addr.q0); // the `o` in "two"
try testing.expectEqual(@as(u32, 7), p.fs.panes[0].addr.q1);
+ // limit is its own file: copying addr onto it bounds the search, and
+ // truncating it lifts the bound again.
+ const limit = Node.of(serial, .limit);
_ = th.wr(p, addr, "1");
- _ = th.wr(p, Node.of(serial, .ctl), "limit=addr\n");
+ try testing.expectEqualStrings("", th.rd(p, limit, 0, 64).bytes);
+ var copied: [64]u8 = undefined;
+ const pair = th.rd(p, addr, 0, 64).bytes;
+ @memcpy(copied[0..pair.len], pair);
+ _ = th.wr(p, limit, copied[0..pair.len]);
+ try testing.expectEqual(@as(u32, 4), p.fs.panes[0].limit.?.q1);
+ try testing.expectEqualStrings(" 0 4 ", th.rd(p, limit, 0, 64).bytes);
_ = th.wr(p, addr, "#0");
try testing.expectEqual(E.INVAL, th.wr(p, addr, "/three/").errno());
- _ = th.wr(p, Node.of(serial, .ctl), "clean\n");
- _ = th.call(p, .{ .tag = 6, .op = .open, .node = Node.of(serial, .ctl) });
+ _ = th.call(p, .{ .tag = 6, .op = .setattr, .node = limit, .truncate = true });
try testing.expect(p.fs.panes[0].limit == null);
_ = th.wr(p, addr, "#0");
try testing.expectEqual(Status.ok, th.wr(p, addr, "/three/").reply.status);
- for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2", "99", "/a\\" }) |bad| {
+ for ([_][]const u8{ "zzz", "#", "//", "/nomatch/", "1 2 3", "99", "/a\\" }) |bad| {
_ = th.wr(p, addr, "#0");
try testing.expectEqual(E.INVAL, th.wr(p, addr, bad).errno());
}