提交 d314e247 编写于 作者: S Stephen Warren 提交者: Simon Glass

test/py: fix timeout to be absolute

Currently, Spawn.expect() imposes its timeout solely upon receipt of new
data, not on its overall operation. In theory, this could cause the
timeout not to fire if U-Boot continually generated output that did not
match the expected patterns.

Fix the code to additionally impose a timeout on overall operation, which
is the intended mode of operation.
Signed-off-by: NStephen Warren <swarren@nvidia.com>
Reviewed-by: NLukasz Majewski <l.majewski@samsung.com>
Acked-by: NSimon Glass <sjg@chromium.org>
上级 b75fdc11
......@@ -122,6 +122,7 @@ class Spawn(object):
if type(patterns[pi]) == type(''):
patterns[pi] = re.compile(patterns[pi])
tstart_s = time.time()
try:
while True:
earliest_m = None
......@@ -142,7 +143,11 @@ class Spawn(object):
self.after = self.buf[pos:posafter]
self.buf = self.buf[posafter:]
return earliest_pi
events = self.poll.poll(self.timeout)
tnow_s = time.time()
tdelta_ms = (tnow_s - tstart_s) * 1000
if tdelta_ms > self.timeout:
raise Timeout()
events = self.poll.poll(self.timeout - tdelta_ms)
if not events:
raise Timeout()
c = os.read(self.fd, 1024)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册