summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-28 10:18:59 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:14 -0300
commitd9c6786e19567878e3c89ae212296ce941484096 (patch)
tree23b973692fc258bd7910cadf135d06776015da6f /test
parent5b27be228f5961dee8727bec7480f375dfb588ed (diff)
downloadpardes-d9c6786e19567878e3c89ae212296ce941484096.tar.gz
pardes-d9c6786e19567878e3c89ae212296ce941484096.zip
Truncating data or xdata deletes only the addressed range, not the whole body
A shell's echo NEW > data opens data with OTRUNC, and truncate() spliced the whole body away before the write replaced the addressed range: a five-byte replacement erased a buffer. data and xdata hold what addr names, so truncating one now deletes that range and nothing else; > on data replaces the range and : > data deletes it, and only truncating body clears the buffer. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'test')
-rw-r--r--test/fs.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/fs.py b/test/fs.py
index c7552a2b..ca1ca70e 100644
--- a/test/fs.py
+++ b/test/fs.py
@@ -338,6 +338,14 @@ def discovery(binary, embedded=False):
assert client.read('/src/pardes.zig').startswith(b'const std')
assert client.stat('/src/pardes.zig')['mode'] == 0o444
assert b'pub const Pardes' in client.read(f'/pane/{look(client, "/virtual/src/pardes.zig")}/body')
+ # An open of data with OTRUNC (a shell's >) deletes the addressed
+ # range only, so the write after it replaces that range.
+ scratch = new_pane(client, b'hello world\nsecond line\n')
+ client.write(f'/pane/{scratch}/addr', b'#0,#5')
+ client.write(f'/pane/{scratch}/data', b'HOWDY', truncate=True)
+ assert client.read(f'/pane/{scratch}/body') == b'HOWDY world\nsecond line\n'
+ client.remove(f'/pane/{scratch}')
+
print('9P discovery: listing/stat/find are inert; new, remove, look, exec, name, sel, log, ctl lock, focus, the ctl split and commands behave')