summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChase Qi <chase.qi@linaro.org>2017-08-29 19:55:50 +0800
committerMilosz Wasilewski <milosz.wasilewski@linaro.org>2017-08-30 09:57:37 +0000
commitf44d8699d7cff00755e21631ffbc2b82453cf166 (patch)
treee1ae0fd1a01ac467a94e8b6f3fdd805b6a921c58
parent444df81b449c49226097288b97e1832370f0cd17 (diff)
android: tradefed: handle timeout exception on tf shell exit
In some cases, TF shell refuse to exit with timeout in 60 seconds. Once pexpect captured the pattern in index 0 or index 1, test should be already finished. In the successful case, index 0, test report should be already generated, refer to the following example. It should be safe to kill the child process and continue to do the result parsing. ResultReporter: Full Result: /lava-21588/0/tests/\ 0_CtsFileSystemTestCases/automated/android/tradefed/android-cts/results\ /2017.08.28_21.28.08.zip Change-Id: I5ffeea82d0904891db464dd08f89a2b199541e92 Signed-off-by: Chase Qi <chase.qi@linaro.org>
-rwxr-xr-xautomated/android/tradefed/tradefed-runner.py14
1 files changed, 12 insertions, 2 deletions
diff --git a/automated/android/tradefed/tradefed-runner.py b/automated/android/tradefed/tradefed-runner.py
index 4c3abff..edbe35e 100755
--- a/automated/android/tradefed/tradefed-runner.py
+++ b/automated/android/tradefed/tradefed-runner.py
@@ -199,8 +199,18 @@ while child.isalive():
# Once all tests finshed, exit from tf shell to throw EOF, which sets child.isalive() to false.
if m == 0 or m == 1:
- child.sendline('exit')
- child.expect(pexpect.EOF, timeout=60)
+ try:
+ child.expect(prompt, timeout=60)
+ logger.debug('Sending "exit" command to TF shell...')
+ child.sendline('exit')
+ child.expect(pexpect.EOF, timeout=60)
+ logger.debug('Child process ended properly.')
+ except pexpect.TIMEOUT as e:
+ print(e)
+ logger.debug('Unsuccessful clean exit, force killing child process...')
+ child.terminate(force=True)
+ break
+
logger.info('Tradefed test finished')
tradefed_logcat.kill()