Skip to content

Commit

Permalink
[lldbtest] Use netloc instead of hostname to look up Android device ID.
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Siva Chandra committed Jun 5, 2015
1 parent c80dad6 commit 29e0392
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lldb/test/lldbtest.py
Original file line number Diff line number Diff line change
@@ -444,18 +444,20 @@ def run_adb_command(cmd, device_id):
return p.returncode, stdout, stderr

def android_device_api():
assert lldb.platform_url is not None
device_id = None
if lldb.platform_url:
parsed = urlparse.urlparse(lldb.platform_url)
if parsed.scheme == "adb":
device_id = parsed.hostname
parsed_url = urlparse.urlparse(lldb.platform_url)
if parsed_url.scheme == "adb":
device_id = parsed_url.netloc.split(":")[0]
retcode, stdout, stderr = run_adb_command(
["shell", "getprop", "ro.build.version.sdk"], device_id)
if retcode == 0:
return int(stdout)
else:
raise LookupError(
"Unable to determine the API level of the Android device.")
">>> Unable to determine the API level of the Android device.\n"
">>> stdout:\n%s\n"
">>> stderr:\n%s\n" % (stdout, stderr))

#
# Decorators for categorizing test cases.

0 comments on commit 29e0392

Please sign in to comment.