From b551075351f5c403b864e34eb408996b03b47a14 Mon Sep 17 00:00:00 2001 From: Demi Marie Obenour Date: Mon, 1 Apr 2024 00:21:55 -0400 Subject: [PATCH] tests: treat ECONNRESET as EOF If the other end of an AF_UNIX stream socket closes the socket without reading all data, read() and recv() will return ECONNRESET once all data has been read. For the purposes of the test suite, this is equivalent to normal EOF and should be treated as such. Fixes intermittent failures in test_run_dom0_service_socket_no_read(). --- qrexec/tests/socket/qrexec.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qrexec/tests/socket/qrexec.py b/qrexec/tests/socket/qrexec.py index eb564837..e8fa174c 100644 --- a/qrexec/tests/socket/qrexec.py +++ b/qrexec/tests/socket/qrexec.py @@ -54,7 +54,10 @@ def sendall(self, data): def recvall(self, data_len): data = b"" while len(data) < data_len: - res = self.conn.recv(data_len - len(data)) + try: + res = self.conn.recv(data_len - len(data)) + except ConnectionResetError: + return data if not res: return data data += res