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

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

Issue 17467003: [android] Switch test scripts to use last modified time instead of md5sum when checking dependencie… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 6 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 | build/android/pylib/gtest/test_package_apk.py » ('j') | build/java_apk.gypi » ('J')
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 f260639352cb073fa6674acbf979f0a307361f44..9dc9d364b9d14cc4e2478bca22ad04e8a0841d92 100644
--- a/build/android/pylib/android_commands.py
+++ b/build/android/pylib/android_commands.py
@@ -61,9 +61,9 @@ KEYCODE_DPAD_RIGHT = 22
KEYCODE_ENTER = 66
KEYCODE_MENU = 82
-MD5SUM_DEVICE_FOLDER = constants.TEST_EXECUTABLE_DIR + '/md5sum/'
-MD5SUM_DEVICE_PATH = MD5SUM_DEVICE_FOLDER + 'md5sum_bin'
-MD5SUM_LD_LIBRARY_PATH = 'LD_LIBRARY_PATH=%s' % MD5SUM_DEVICE_FOLDER
+TIMEMODIFIED_DEVICE_FOLDER = constants.TEST_EXECUTABLE_DIR + '/timemodified/'
frankf 2013/06/20 22:52:38 If these are only used in one function, let's move
frankf 2013/06/20 22:52:38 FOLDER -> DIRECTORY
craigdh 2013/07/02 17:26:12 Done.
craigdh 2013/07/02 17:26:12 Done.
+TIMEMODIFIED_DEVICE_PATH = TIMEMODIFIED_DEVICE_FOLDER + 'timemodified_bin'
+TIMEMODIFIED_LD_LIBRARY_PATH = 'LD_LIBRARY_PATH=%s' % TIMEMODIFIED_DEVICE_FOLDER
def GetEmulators():
"""Returns a list of emulators. Does not filter by status (e.g. offline).
@@ -171,9 +171,9 @@ def _GetFilesFromRecursiveLsOutput(path, ls_output, re_file, utc_offset=None):
return files
-def _ComputeFileListHash(md5sum_output):
- """Returns a list of MD5 strings from the provided md5sum output."""
- return [line.split(' ')[0] for line in md5sum_output]
+def _ComputeFileListTimesModified(timemodified_output):
+ """Returns a list of time strings from the provided timemodified output."""
+ return [line.split(' ')[0] for line in timemodified_output]
def _HasAdbPushSucceeded(command_output):
@@ -220,7 +220,7 @@ class AndroidCommands(object):
self._logcat_tmpoutfile = None
self._pushed_files = []
self._device_utc_offset = self.RunShellCommand('date +%z')[0]
- self._md5sum_build_dir = ''
+ self._timemodified_build_dir = ''
self._external_storage = ''
self._util_wrapper = ''
@@ -696,57 +696,68 @@ class AndroidCommands(object):
"""
self.RunShellCommand('input keyevent %d' % keycode)
- def CheckMd5Sum(self, local_path, device_path, ignore_paths=False):
- """Compares the md5sum of a local path against a device path.
+ def CheckTimesModified(self, local_path, device_path, ignore_paths=False):
frankf 2013/06/20 22:52:38 I would rename this to something like FileOutOfSyn
craigdh 2013/07/02 17:26:12 Done.
craigdh 2013/07/02 17:26:12 Done.
+ """Compares the time modified of a local path against a device path.
Args:
local_path: Path (file or directory) on the host.
device_path: Path on the device.
- ignore_paths: If False, both the md5sum and the relative paths/names of
- files must match. If True, only the md5sum must match.
+ ignore_paths: If False, both the time modified and the relative
+ paths/names of files must match. If True, only the time modified
+ must match.
Returns:
- True if the md5sums match.
+ True if the time the files were modified match or are more recent.
"""
assert os.path.exists(local_path), 'Local path not found %s' % local_path
- if not self._md5sum_build_dir:
+ if not self._timemodified_build_dir:
default_build_type = os.environ.get('BUILD_TYPE', 'Debug')
build_dir = '%s/%s/' % (
cmd_helper.OutDirectory().get(), default_build_type)
frankf 2013/06/20 22:52:38 We should really set the out directory once instea
craigdh 2013/07/02 17:26:12 Why? It's not a very heavy call.
- md5sum_dist_path = '%s/md5sum_dist' % build_dir
- if not os.path.exists(md5sum_dist_path):
+ timemodified_dist_path = '%s/timemodified_dist' % build_dir
frankf 2013/06/20 22:52:38 let's have 'host'/'device' in the variable names t
craigdh 2013/07/02 17:26:12 Done.
+ if not os.path.exists(timemodified_dist_path):
build_dir = '%s/Release/' % cmd_helper.OutDirectory().get()
- md5sum_dist_path = '%s/md5sum_dist' % build_dir
- assert os.path.exists(md5sum_dist_path), 'Please build md5sum.'
- command = 'push %s %s' % (md5sum_dist_path, MD5SUM_DEVICE_FOLDER)
+ timemodified_dist_path = '%s/timemodified_dist' % build_dir
+ assert os.path.exists(timemodified_dist_path), 'Build timemodified.'
+ command = 'push %s %s' % (timemodified_dist_path,
+ TIMEMODIFIED_DEVICE_FOLDER)
assert _HasAdbPushSucceeded(self._adb.SendCommand(command))
- self._md5sum_build_dir = build_dir
+ self._timemodified_build_dir = build_dir
self._pushed_files.append(device_path)
- hashes_on_device = _ComputeFileListHash(
- self.RunShellCommand(MD5SUM_LD_LIBRARY_PATH + ' ' + self._util_wrapper +
- ' ' + MD5SUM_DEVICE_PATH + ' ' + device_path))
+ hashes_on_device = _ComputeFileListTimesModified(
+ self.RunShellCommand(TIMEMODIFIED_LD_LIBRARY_PATH + ' ' +
+ self._util_wrapper + ' ' + TIMEMODIFIED_DEVICE_PATH + ' ' +
+ device_path))
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())
+ timemodified_output = cmd_helper.GetCmdOutput(
+ ['%s/timemodified_bin_host' % self._timemodified_build_dir, local_path])
+ hashes_on_host = _ComputeFileListTimesModified(
+ timemodified_output.splitlines())
+ #TODO(craigdh): This doesn't appear to have any effect.
frankf 2013/06/20 22:52:38 What's the deal here? If not used, can we remove i
craigdh 2013/07/02 17:26:12 Done.
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]
- return hashes_on_device == hashes_on_host
+ if len(hashes_on_device) != len(hashes_on_host):
+ return False
+ hashes_on_device.sort()
+ hashes_on_host.sort()
+ return all(int(dtime) >= int(htime) for dtime, htime in
+ zip(hashes_on_device, hashes_on_host))
def PushIfNeeded(self, local_path, device_path):
"""Pushes |local_path| to |device_path|.
Works for files and directories. This method skips copying any paths in
- |test_data_paths| that already exist on the device with the same hash.
+ |test_data_paths| that already exist on the device with the same modified
+ time.
All pushed files can be removed by calling RemovePushedFiles().
"""
- if self.CheckMd5Sum(local_path, device_path):
+ if self.CheckTimesModified(local_path, device_path):
return
# They don't match, so remove everything first and then create it.
@@ -1274,7 +1285,7 @@ class AndroidCommands(object):
def SetUtilWrapper(self, util_wrapper):
"""Sets a wrapper prefix to be used when running a locally-built
- binary on the device (ex.: md5sum_bin).
+ binary on the device (ex.: timemodified_bin).
"""
self._util_wrapper = util_wrapper
« no previous file with comments | « no previous file | build/android/pylib/gtest/test_package_apk.py » ('j') | build/java_apk.gypi » ('J')

Powered by Google App Engine
This is Rietveld 408576698