diff options
Diffstat (limited to 'src/ninep/ctl.zig')
| -rw-r--r-- | src/ninep/ctl.zig | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/ninep/ctl.zig b/src/ninep/ctl.zig index a78a9fcd..4b37c23e 100644 --- a/src/ninep/ctl.zig +++ b/src/ninep/ctl.zig @@ -2036,6 +2036,26 @@ test "/index shows a name as the log does: a newline in it is \\n, controls spac try testing.expect(std.mem.indexOf(u8, rd(p, @intFromEnum(tree.TopFile.index), 0, 4096).bytes, "/tmp/back\\\\nslash") != null); } +test "a look at a ./ or ../ name that is not there names the file, ENOENT; a plain one is looked for as text" { + const p = try withFile(testing.allocator, "x\n"); + defer p.deinit(); + var tmp = testing.tmpDir(.{}); + defer tmp.cleanup(); + try tmp.dir.createDirPath(testing.io, "many"); + var dir_buf: [4096]u8 = undefined; + const dir = dir_buf[0..try tmp.dir.realPath(testing.io, &dir_buf)]; + var line: [4200]u8 = undefined; + _ = wr(p, Node.of(serialOf(p), .name), try std.fmt.bufPrint(&line, "{s}/many/a.txt\n", .{dir})); + for ([_][]const u8{ "./zz.txt", "../zz.txt" }) |name| { + const r = wr(p, Node.of(serialOf(p), .look), try std.fmt.bufPrint(&line, "{s}\n", .{name})); + try testing.expectEqual(E.NOENT, r.errno()); + var want: [64]u8 = undefined; + try testing.expectEqualStrings(try std.fmt.bufPrint(&want, "look: {s}: no such file", .{name}), r.reply.ename); + } + try testing.expectEqual(Status.ok, wr(p, Node.of(serialOf(p), .look), "zz.txt\n").reply.status); + try testing.expect(th.logHas(p, "look: no match for \"zz.txt\"")); +} + test "a served-tree pane spoils no Grep, and Look . from a gone directory is ENOENT, not /virtual/" { const p = try withFile(testing.allocator, "x\n"); defer p.deinit(); |
