diff options
Diffstat (limited to 'test/fs.py')
| -rw-r--r-- | test/fs.py | 31 |
1 files changed, 30 insertions, 1 deletions
@@ -360,6 +360,32 @@ def discovery(binary, embedded=False): # Through a mount both read as EINVAL; the log says which and why. assert f'err {scratch} addr: no match for regexp\n'.encode() in client.read('/log') client.remove(f'/pane/{scratch}') + # A save the host cannot do fails the write that asked for it, + # and the log's err record names the path and why. + unsaved = new_pane(client, b'unsaved\n') + try: + client.write(f'/pane/{unsaved}/ctl', b'Save /nonexistent-pardes-dir/x.txt\n') + raise AssertionError('a Save into a missing directory succeeded') + except OSError as refused: + assert 'Save /nonexistent-pardes-dir/x.txt: ' in str(refused), refused + assert f'err {unsaved} ctl: Save /nonexistent-pardes-dir/x.txt: '.encode() in client.read('/log'), client.read('/log') + client.remove(f'/pane/{unsaved}') + + # Sixteen connections fill the slots; the next is told why. + extra = [Client(address) for _ in range(15)] + try: + try: + Client(address).__exit__() + raise AssertionError('a seventeenth connection was served') + except OSError as refused: + assert 'too many connections' in str(refused), refused + finally: + for other in extra: + other.__exit__() + deadline = time.monotonic() + 5 + while b'err - 9p: too many connections' not in client.read('/log'): + assert time.monotonic() < deadline, client.read('/log') + time.sleep(.01) print('9P discovery: listing/stat/find are inert; new, remove, look, exec, name, sel, log, ctl lock, focus, the ctl split and commands behave') @@ -636,7 +662,10 @@ def test(binary, quic=False): raise AssertionError('Restore left an old body fid usable') with Client(address) as restored: # The new log names its panes, then where they came from. - assert restored.read('/log').endswith(b'\nrestore ' + str(saved).encode() + b'\n'), restored.read('/log') + log = restored.read('/log') + assert b'\nrestore ' + str(saved).encode() + b'\n' in log, log + # then which serial each pane had: restored <old> <new> + assert log.endswith(b'\n'.join(b'restored %d %d' % (old, new) for old, new in zip(sorted(old_ids), sorted(int(r.split()[0]) for r in restored.read('/index').splitlines()))) + b'\n'), log restored_ids = [int(row.split()[0]) for row in restored.read('/index').splitlines()] assert len(restored_ids) == 2 and old_ids.isdisjoint(restored_ids), restored_ids file_id, control_id = restored_ids |
