[systemtest] Avoid time increments after compare
We didn't use the same time value for a comparision and later on in a
statement, causing a negative value to be passed to select.select().
This leads to "ValueError: timeout must be non-negative".
Avoid the problem by buffering the current time for the check and the
socket.select() call.
Signed-off-by: Philipp Wagner <phw@lowrisc.org>
diff --git a/test/systemtest/test_utils.py b/test/systemtest/test_utils.py
index 4002a91..6fc5971 100644
--- a/test/systemtest/test_utils.py
+++ b/test/systemtest/test_utils.py
@@ -232,7 +232,8 @@
os.set_blocking(fd, False)
line_of_output = b''
while True:
- if deadline != None and time.monotonic() > deadline:
+ curtime = time.monotonic()
+ if deadline != None and curtime > deadline:
return None
if line_of_output.endswith(b'\n'):
@@ -242,7 +243,7 @@
# we wouldn't get anything out of it.
if deadline != None:
rlist, _, _ = select.select([fd], [], [],
- deadline - time.monotonic())
+ deadline - curtime)
else:
rlist, _, _ = select.select([fd], [], [])