Skip to content

Commit 29e0392

Browse files
author
Siva Chandra
committedJun 5, 2015
[lldbtest] Use netloc instead of hostname to look up Android device ID.
Summary: urlparse.ParseResult.hostname has only lowercase characters even if the input URL had uppercase characters. Since Android device IDs can have uppercase characters as well, use urlparse.ParseResult.netloc instead and extract the device ID from it. This change also improves the error message when lookup of the Android device's API fails. Reviewers: chaoren Reviewed By: chaoren Subscribers: tberghammer, lldb-commits Differential Revision: http://reviews.llvm.org/D10278 llvm-svn: 239173
1 parent c80dad6 commit 29e0392

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed
 

‎lldb/test/lldbtest.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,20 @@ def run_adb_command(cmd, device_id):
444444
return p.returncode, stdout, stderr
445445

446446
def android_device_api():
447+
assert lldb.platform_url is not None
447448
device_id = None
448-
if lldb.platform_url:
449-
parsed = urlparse.urlparse(lldb.platform_url)
450-
if parsed.scheme == "adb":
451-
device_id = parsed.hostname
449+
parsed_url = urlparse.urlparse(lldb.platform_url)
450+
if parsed_url.scheme == "adb":
451+
device_id = parsed_url.netloc.split(":")[0]
452452
retcode, stdout, stderr = run_adb_command(
453453
["shell", "getprop", "ro.build.version.sdk"], device_id)
454454
if retcode == 0:
455455
return int(stdout)
456456
else:
457457
raise LookupError(
458-
"Unable to determine the API level of the Android device.")
458+
">>> Unable to determine the API level of the Android device.\n"
459+
">>> stdout:\n%s\n"
460+
">>> stderr:\n%s\n" % (stdout, stderr))
459461

460462
#
461463
# Decorators for categorizing test cases.

0 commit comments

Comments
 (0)
Please sign in to comment.