diff options
Diffstat (limited to 'test')
| -rw-r--r-- | test/daemon.py | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/test/daemon.py b/test/daemon.py index 7b0e5343..b55c9b24 100644 --- a/test/daemon.py +++ b/test/daemon.py @@ -132,6 +132,21 @@ def ps(*args): return subprocess.run(['ps', *args], capture_output=True).stdout +def exit_session(nine, pane): + """Exit, by the session's 9P, again when unsaved text asks first. The + Exit that ends the session may close its link before the write's clunk + is answered: that EOF is the session gone, as asked.""" + for _ in range(2): + try: + nine.write(f'/pane/{pane}/exec', b'Exit\n') + return + except EOFError: + return + except OSError as err: + # An edited file asks before it goes. + assert 'Exit again' in str(err), err + + def processes(root): """The pids whose environment is this run's (its runtime directory).""" found = [] @@ -434,12 +449,7 @@ def clients(binary): f'one put off the session\'s state joined again and agreed {len(checks(root / "d.check"))} times; ' f'one killed, the other typed on and detached; a third typed into a shell, agreed ' f'{len(checks(root / "c.check"))} times, and was hung up') - try: - nine.write(f'/pane/{pane}/exec', b'Exit\n') - except OSError as e: - # An edited file asks before it goes. - assert 'Exit again' in str(e), e - nine.write(f'/pane/{pane}/exec', b'Exit\n') + exit_session(nine, pane) sess.wait(timeout=10) nine.socket.close() wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=10) @@ -704,12 +714,7 @@ def window_clients(binary, gui_binary): print(f'daemon: window clients of a terminal\'s session at 0/30/80/207 ms beside a terminal\'s, digests agreed ' f'{agreements} and {len(checks(root / "a.check"))} times; one put off the session\'s state joined again, ' f'joined again across an Upgrade, agreed {len(checks(dcheck))} times and detached (far: its joins {joins(root / "wd.stats")})') - try: - nine.write(f'/pane/{pane}/exec', b'Exit\n') - except OSError as e: - # An edited file asks before it goes. - assert 'Exit again' in str(e), e - nine.write(f'/pane/{pane}/exec', b'Exit\n') + exit_session(nine, pane) sess.wait(timeout=10) nine.socket.close() # A window's session (its daemon on, as a desktop's is), served to a @@ -947,11 +952,7 @@ def far(binary): a_joins[0]['sent_kb'], b_joins[0]['from_disk'], b_joins[0]['blobs'], b_joins[1]['from_memory'], b_joins[1]['blobs'], c_join['from_disk'], c_join['blobs'], d_join['sent_kb'], sum(len(checks(root / f'{n}.check')) for n in 'abcdef'))) - try: - nine.write(f'/pane/{pane}/exec', b'Exit\n') - except OSError as err: - assert 'Exit again' in str(err), err - nine.write(f'/pane/{pane}/exec', b'Exit\n') + exit_session(nine, pane) sess.wait(timeout=10) nine.socket.close() wait_for('nothing left', lambda: not [p for p in processes(root) if alive(p)], timeout=10) |
