From 718b5220790c99d2beae9dea630efb05a9223df6 Mon Sep 17 00:00:00 2001 From: Adrian Perez Date: Mon, 5 Jun 2017 11:43:18 -0700 Subject: [PATCH] fix for ADB no longer mashing STDOUT and STDERR on shell calls --- bin/android_ndk_perf.py | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/bin/android_ndk_perf.py b/bin/android_ndk_perf.py index c9005eb..ce42ac9 100755 --- a/bin/android_ndk_perf.py +++ b/bin/android_ndk_perf.py @@ -428,15 +428,17 @@ def shell_command(self, command, error, **kwargs): returncode = 0 else: returncode = 1 - # Regardless of the destination stream on the Android device ADB - # redirects everything to the standard error stream so this looks at the - # last line of the stream to get the command status code. - if out_lines: - try: - returncode = int(out_lines[-1]) - out_lines = out_lines[:-1] - except ValueError: - pass + + try: + returncode = int(err.splitlines()[-1]) + except ValueError: + # legacy behavior: check last line of stdout (ADB used to merge STDOUT and STDERR) + if out_lines: + try: + returncode = int(out_lines[-1]) + out_lines = out_lines[:-1] + except ValueError: + pass if returncode and not kwargs.get('display_output'): print out print >> sys.stderr, err