Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: build/android/pylib/android_commands.py

Issue 19675006: [android] Ignore extra files on the client when comparing md5sum output. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/android_commands.py
diff --git a/build/android/pylib/android_commands.py b/build/android/pylib/android_commands.py
index 48116b88ffd8e7e7a889ea679ff99e55569e702c..be9d1e06a7680cb33e722b4a52986f276bd66af9 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -172,8 +172,18 @@ def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None):
def _ComputeFileListHash(md5sum_output):
- """Returns a list of MD5 strings from the provided md5sum output."""
- return [line.split(' ')[0] for line in md5sum_output]
+ """Returns a list of tuples from the provided md5sum output.
+
+ Args:
+ md5sum_output: output directly from md5sum binary.
+
+ Returns:
+ List of namedtuples (hash, path).
+ """
+ HashAndPath = collections.namedtuple('HashAndPath', ['hash', 'path'])
+ split_lines = [line.split(' ') for line in md5sum_output]
+ assert all(len(s) == 2 for s in split_lines), 'Invalid md5sum output'
+ return [HashAndPath._make(s) for s in split_lines]
def _HasAdbPushSucceeded(command_output):
@@ -727,17 +737,30 @@ class AndroidCommands(object):
cmd = (MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper + ' ' +
MD5SUM_DEVICE_PATH + ' ' + device_path)
- hashes_on_device = _ComputeFileListHash(
+ device_hash_tuples = _ComputeFileListHash(
self.RunShellCommand(cmd, timeout_time=2 * 60))
assert os.path.exists(local_path), 'Local path not found %s' % local_path
md5sum_output = cmd_helper.GetCmdOutput(
['%s/md5sum_bin_host' % self._md5sum_build_dir, local_path])
- hashes_on_host = _ComputeFileListHash(md5sum_output.splitlines())
+ host_hash_tuples = _ComputeFileListHash(md5sum_output.splitlines())
+
+ # Ignore extra files on the device.
+ if len(device_hash_tuples) > len(host_hash_tuples):
+ host_files = [os.path.relpath(os.path.normpath(p.path),
+ os.path.normpath(local_path)) for p in host_hash_tuples]
- if ignore_paths:
- hashes_on_device = [h.split()[0] for h in hashes_on_device]
- hashes_on_host = [h.split()[0] for h in hashes_on_host]
+ def _host_has(fname):
+ return any(path in fname for path in host_files)
+
+ hashes_on_device = [h.hash for h in device_hash_tuples if
+ _host_has(h.path)]
+ else:
+ hashes_on_device = [h.hash for h in device_hash_tuples]
+ # Compare md5sums between host and device files.
+ hashes_on_host = [h.hash for h in host_hash_tuples]
+ hashes_on_device.sort()
+ hashes_on_host.sort()
return hashes_on_device == hashes_on_host
def PushIfNeeded(self, local_path, device_path):
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698