Skip to content

Commit 8746834

Browse files
committed
contest: vm: improve stdout / stderr drain reliability
We seem to have leftover data in the stdout / stderr now that the draining is improved. Increase select timeout to 200msec and wait for a full timeout with no data before we consider the drain completed. Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4bf0999 commit 8746834

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

contest/remote/lib/vm.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -302,9 +302,10 @@ def drain_to_prompt(self, prompt="xx__-> ", dump_after=None, deadline=None):
302302
total_wait = 0
303303
stdout = ""
304304
stderr = ""
305+
prompt_seen = False
305306
last_read = time.monotonic()
306307
while True:
307-
select.select([self.p.stdout, self.p.stderr], [], [], 0.1)
308+
readable, _, _ = select.select([self.p.stdout, self.p.stderr], [], [], 0.2)
308309

309310
read_some, out = self._read_pipe_nonblock(self.p.stdout)
310311
self.log_out += out
@@ -319,9 +320,9 @@ def drain_to_prompt(self, prompt="xx__-> ", dump_after=None, deadline=None):
319320
last_read = now
320321
total_wait += elapsed
321322

322-
if read_some:
323-
if stdout.endswith(prompt):
324-
break
323+
if read_some and stdout.endswith(prompt):
324+
prompt_seen = True
325+
elif read_some:
325326
if self.fail_state == "oops" and _dump_after is None and dump_after > 300:
326327
dump_after = 300
327328
self.log_out += '\nDETECTED CRASH, lowering timeout\n'
@@ -333,6 +334,10 @@ def drain_to_prompt(self, prompt="xx__-> ", dump_after=None, deadline=None):
333334
self.cmd('\n')
334335
time.sleep(0.25)
335336
waited = 0
337+
elif prompt_seen and not read_some and not readable:
338+
# No data read - if we saw the prompt and select() timed out,
339+
# the pipe is quiescent, safe to return
340+
break
336341
else:
337342
waited += elapsed
338343

0 commit comments

Comments
 (0)