From 367a6df7cee4d79ad60c71699dd2d843bce9f7ab Mon Sep 17 00:00:00 2001 From: Chase Qi Date: Mon, 13 Nov 2017 10:44:34 +0800 Subject: android: tradefed: dump logs when adb connection lost When adb connection lost, send 'd l' command to TF shell to dump the logs of all invocations to files, and then upload them to Artifactorial for debugging. Change-Id: Iaf3d5a4509370b449390b2b590f870d8a1150909 Signed-off-by: Chase Qi --- automated/android/tradefed/tradefed-runner.py | 3 +++ automated/android/tradefed/tradefed.yaml | 2 ++ 2 files changed, 5 insertions(+) (limited to 'automated') diff --git a/automated/android/tradefed/tradefed-runner.py b/automated/android/tradefed/tradefed-runner.py index b0c5d77..ebf9b26 100755 --- a/automated/android/tradefed/tradefed-runner.py +++ b/automated/android/tradefed/tradefed-runner.py @@ -164,6 +164,9 @@ while child.isalive(): adb_command = "adb shell echo OK" adb_check = subprocess.Popen(shlex.split(adb_command)) if adb_check.wait() != 0: + logger.debug('adb connection lost! Trying to dump logs of all invocations...') + child.sendline('d l') + time.sleep(30) subprocess.call(['sh', '-c', '. ../../lib/sh-test-lib && . ../../lib/android-test-lib && adb_debug_info']) logger.debug('"adb devices" output') subprocess.call(['adb', 'devices']) diff --git a/automated/android/tradefed/tradefed.yaml b/automated/android/tradefed/tradefed.yaml index 5d6515e..d9db822 100644 --- a/automated/android/tradefed/tradefed.yaml +++ b/automated/android/tradefed/tradefed.yaml @@ -44,6 +44,8 @@ run: # Upload test log and result files to artifactorial. - cp -r ./${TEST_PATH}/results ./output/ || true - cp -r ./${TEST_PATH}/logs ./output/ || true + # Include logs dumped from TF shell 'd l' command. + - if ls /tmp/tradefed*; then cp -r /tmp/tradefed* ./output || true; fi - tar caf tradefed-output-$(date +%Y%m%d%H%M%S).tar.xz ./output - ATTACHMENT=$(ls tradefed-output-*.tar.xz) - ../../utils/upload-to-artifactorial.sh -a "${ATTACHMENT}" -u "${URL}" -t "${TOKEN}" -- cgit v1.2.3