summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenjamin Berg <bberg@redhat.com>2021-07-20 13:42:49 +0200
committerBenjamin Berg <bberg@redhat.com>2021-07-22 14:23:50 +0200
commit6dc24e0c410b50d8f9ceeda48d10b3fa16e1c715 (patch)
tree38f0b5b6030998c6a540f2b97714c96dba4b5239 /tests
parent8461c26598e5add1f594bacdff3f842e8b59345e (diff)
downloadgnome-settings-daemon-6dc24e0c410b50d8f9ceeda48d10b3fa16e1c715.tar.gz
tests: Correctly handle EOF in OutputChecker
Diffstat (limited to 'tests')
-rw-r--r--tests/output_checker.py17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/output_checker.py b/tests/output_checker.py
index 453d2698..26f9217c 100644
--- a/tests/output_checker.py
+++ b/tests/output_checker.py
@@ -58,12 +58,18 @@ class OutputChecker(object):
r = os.read(self._pipe_fd_r, 1024)
if not r:
+ os.close(self._pipe_fd_r)
+ self._pipe_fd_r = -1
+ self._lines_sem.release()
return
except OSError as e:
if e.errno == errno.EWOULDBLOCK:
continue
# We get a bad file descriptor error when the outside closes the FD
+ os.close(self._pipe_fd_r)
+ self._pipe_fd_r = -1
+ self._lines_sem.release()
return
l = r.split(b'\n')
@@ -88,6 +94,13 @@ class OutputChecker(object):
try:
l = self._lines.pop(0)
except IndexError:
+ # EOF, throw error
+ if self._pipe_fd_r == -1:
+ if failmsg:
+ raise AssertionError("No further messages: " % failmsg)
+ else:
+ raise AssertionError('No client waiting for needle %s' % (str(needle_re)))
+
# Check if should wake up
if not self._lines_sem.acquire(timeout = deadline - time.time()):
if failmsg:
@@ -121,6 +134,10 @@ class OutputChecker(object):
try:
l = self._lines.pop(0)
except IndexError:
+ # EOF, so everything good
+ if self._pipe_fd_r == -1:
+ break
+
# Check if should wake up
if not self._lines_sem.acquire(timeout = deadline - time.time()):
# Timed out, so everything is good