Fix versioning logic in ctest to get the correct latest version.

Change-Id: I2721bcd2da38b764ebe21dfb8fe7a39dd947075c

BUG=8500
TEST=Ran it against all boards

Review URL: http://codereview.chromium.org/4235001
This commit is contained in:
Chris Sosa 2010-11-01 14:36:38 -07:00
parent 6203601529
commit b4b09d40a7

View File

@ -93,6 +93,19 @@ def ModifyBootDesc(download_folder, redirect_file=None):
fileinput.close()
def _GreaterVersion(version_a, version_b):
"""Returns the higher version number of two version number strings."""
version_regex = re.compile('.*(\d+)\.(\d+)\.(\d+)\.(\d+).*')
version_a_tokens = version_regex.match(version_a).groups()
version_b_tokens = version_regex.match(version_b).groups()
for i in range(4):
(a, b) = (int(version_a_tokens[i]), int(version_b_tokens[i]))
if a != b:
if a > b: return version_a
return version_b
return version_a
def GetLatestLinkFromPage(url, regex):
"""Returns the latest link from the given url that matches regex.
@ -102,12 +115,13 @@ def GetLatestLinkFromPage(url, regex):
"""
url_file = urllib.urlopen(url)
url_html = url_file.read()
url_file.close()
# Parses links with versions embedded.
url_parser = HTMLDirectoryParser(regex=regex)
url_parser.feed(url_html)
return max(url_parser.link_list)
return reduce(_GreaterVersion, url_parser.link_list)
def GetNewestLinkFromZipBase(board, channel, zip_server_base):