diff options
Diffstat (limited to 'src/ninep')
| -rw-r--r-- | src/ninep/ctl.zig | 30 | ||||
| -rw-r--r-- | src/ninep/tree.zig | 5 |
2 files changed, 33 insertions, 2 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index 40ffebc8..16fbabb4 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -4379,3 +4379,33 @@ test "a Mount dial with a network it does not know is a bad dial address, EINVAL try testing.expectEqual(E.INVAL, r.errno()); try testing.expectStringStartsWith(r.reply.ename, "Mount: bad dial address: nowhere!x"); } + +test "a command or a terminal refused for room is refused before anything is logged of it, and its serial is never handed out again" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + const exec = Node.of(serialOf(p), .exec); + var buf: [32]u8 = undefined; + for ([_][]const u8{ "ls\n", "Tty\n" }) |line| { + // Each a pane of its own until the column has no room for one more. + var before = p.next_serial; + var tries: usize = 0; + while (tries < pardes.MAX_PANES) : (tries += 1) { + before = p.next_serial; + const r = wr(p, exec, line); + p.sync(); + if (r.reply.status == .err) break; + } else return error.NeverRefused; + // Nothing said of the refused one: no new, no run, no del. + for (before + 1..p.next_serial + 1) |n| { + try testing.expect(!th.logHas(p, try std.fmt.bufPrint(&buf, "new {d} ", .{n}))); + try testing.expect(!th.logHas(p, try std.fmt.bufPrint(&buf, "run {d} ", .{n}))); + try testing.expect(!th.logHas(p, try std.fmt.bufPrint(&buf, "del {d} ", .{n}))); + } + // And the next pane made takes a serial past it. + const spent = p.next_serial; + p.update(.{ .resize = .{ .cols = 200, .rows = 200 } }); + const made = try th.newPane(p); + try testing.expect(made > spent); + p.update(.{ .resize = .{ .cols = 80, .rows = 24 } }); + } +} diff --git a/src/ninep/tree.zig b/src/ninep/tree.zig index e6c139c1..40543ecf 100644 --- a/src/ninep/tree.zig +++ b/src/ninep/tree.zig @@ -1905,10 +1905,11 @@ test "no placement leaves a pane shorter than its tag and two rows; a full colum } else return error.NeverRefused; try testing.expectEqual(E.NOSPC, refused.errno()); try testing.expect(std.mem.indexOf(u8, refused.reply.ename, "no space for a pane in that column") != null); - // The refused pane was never there: no serial spent on it. + // The refused pane was never there; its serial is not handed out again + // (gaps are fine: a serial once said names one pane for good). const before = p.next_serial; try testing.expectEqual(E.NOSPC, call(p, .{ .tag = 1, .op = .open, .node = new }).errno()); - try testing.expectEqual(before, p.next_serial); + try testing.expectEqual(before + 1, p.next_serial); p.sync(); var count: usize = 0; for (p.panes) |slot| count += @intFromBool(slot != null); |
