diff options
author | Milosz Wasilewski <milosz.wasilewski@linaro.org> | 2017-06-12 02:19:40 +0100 |
---|---|---|
committer | Chase Qi <chase.qi@linaro.org> | 2017-06-12 16:56:56 +0800 |
commit | 468f33fde99d1f7b2c9e877c594f2f8b08dcc954 (patch) | |
tree | 0cb5ddf408e3c20abb4d622158b27a2d2be91ef0 /automated | |
parent | cd14082b290876301fdf83cd04b48f502d1b99c5 (diff) |
automated: android: fix tradefed-runner.py
This patch fixes the high CPU utilization when running tradefed (CTS)
with big modules. pexpect buffer is now flushed often to ensure the
search is only performed on the recent chunk of input.
Change-Id: I33d68d7709dc73eb631f1e71c765ba3cc0be84ae
Signed-off-by: Milosz Wasilewski <milosz.wasilewski@linaro.org>
Diffstat (limited to 'automated')
-rwxr-xr-x | automated/android/tradefed/tradefed-runner.py | 36 |
1 files changed, 21 insertions, 15 deletions
diff --git a/automated/android/tradefed/tradefed-runner.py b/automated/android/tradefed/tradefed-runner.py index dde8abc..cc7a281 100755 --- a/automated/android/tradefed/tradefed-runner.py +++ b/automated/android/tradefed/tradefed-runner.py @@ -88,7 +88,7 @@ parser.add_argument('-t', dest='TEST_PARAMS', required=True, parser.add_argument('-p', dest='TEST_PATH', required=True, help="path to tradefed package top directory") args = parser.parse_args() -#TEST_PARAMS = args.TEST_PARAMS +# TEST_PARAMS = args.TEST_PARAMS if os.path.exists(OUTPUT): suffix = datetime.datetime.now().strftime('%Y%m%d%H%M%S') @@ -152,23 +152,29 @@ while child.isalive(): else: logger.info('adb device is alive') - try: - # Check if all tests finished every minute. - m = child.expect(['I/ResultReporter: Full Result:', - 'I/ConsoleReporter:.*Test run failed to complete.'], - timeout=60) - if m == 0: - py_test_lib.add_result(RESULT_FILE, 'tradefed-test-run pass') - elif m == 1: - py_test_lib.add_result(RESULT_FILE, 'tradefed-test-run fail') - - # Once all tests finshed, exit from tf shell and throw EOF. - child.sendline('exit') - child.expect(pexpect.EOF, timeout=60) - except pexpect.TIMEOUT: + # Check if all tests finished every minute. + m = child.expect(['I/ResultReporter: Full Result:', + 'I/ConsoleReporter:.*Test run failed to complete.', + pexpect.TIMEOUT], + timeout=60) + # CTS tests finished correctly. + if m == 0: + py_test_lib.add_result(RESULT_FILE, 'tradefed-test-run pass') + # CTS tests ended with failure. + elif m == 1: + py_test_lib.add_result(RESULT_FILE, 'tradefed-test-run fail') + # CTS not finished yet, continue to wait. + elif m == 2: + # Flush pexpect input buffer. + child.expect(['.+', pexpect.TIMEOUT, pexpect.EOF], timeout=1) logger.info('Printing tradefed recent output...') subprocess.call(['tail', TRADEFED_STDOUT]) + # 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) + logger.info('Tradefed test finished') tradefed_logcat.kill() tradefed_logcat_out.close() |