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

Unified Diff: build/android/pylib/utils/md5sum_test.py

Issue 1321503003: Fix md5sum printing a stale checksum for missing files. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: forgot if I already uploaded... Created 5 years, 4 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 | « build/android/pylib/utils/md5sum.py ('k') | tools/android/md5sum/md5sum.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/pylib/utils/md5sum_test.py
diff --git a/build/android/pylib/utils/md5sum_test.py b/build/android/pylib/utils/md5sum_test.py
index 6821c0ff659ee3fcbc5d079722a97621c913f111..e60b810254c4be86d13d8038b0dee8887ce40dab 100755
--- a/build/android/pylib/utils/md5sum_test.py
+++ b/build/android/pylib/utils/md5sum_test.py
@@ -93,12 +93,13 @@ class Md5SumTest(unittest.TestCase):
]
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)
- out = md5sum.CalculateDeviceMd5Sums(test_path, device)
- self.assertEquals(1, len(out))
- self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
- self.assertEquals('0123456789abcdeffedcba9876543210',
- out['/storage/emulated/legacy/test/file.dat'])
- self.assertEquals(1, len(device.RunShellCommand.call_args_list))
+ with mock.patch('os.path.getsize', return_value=1337):
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device)
+ self.assertEquals(1, len(out))
+ self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
+ self.assertEquals('0123456789abcdeffedcba9876543210',
+ out['/storage/emulated/legacy/test/file.dat'])
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list))
def testCalculateDeviceMd5Sums_list(self):
test_path = ['/storage/emulated/legacy/test/file0.dat',
@@ -112,15 +113,16 @@ class Md5SumTest(unittest.TestCase):
]
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)
- out = md5sum.CalculateDeviceMd5Sums(test_path, device)
- self.assertEquals(2, len(out))
- self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out)
- self.assertEquals('0123456789abcdeffedcba9876543210',
- out['/storage/emulated/legacy/test/file0.dat'])
- self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out)
- self.assertEquals('123456789abcdef00fedcba987654321',
- out['/storage/emulated/legacy/test/file1.dat'])
- self.assertEquals(1, len(device.RunShellCommand.call_args_list))
+ with mock.patch('os.path.getsize', return_value=1337):
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device)
+ self.assertEquals(2, len(out))
+ self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out)
+ self.assertEquals('0123456789abcdeffedcba9876543210',
+ out['/storage/emulated/legacy/test/file0.dat'])
+ self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out)
+ self.assertEquals('123456789abcdef00fedcba987654321',
+ out['/storage/emulated/legacy/test/file1.dat'])
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list))
def testCalculateDeviceMd5Sums_generator(self):
test_path = ('/storage/emulated/legacy/test/file%d.dat' % n
@@ -135,15 +137,16 @@ class Md5SumTest(unittest.TestCase):
]
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)
- out = md5sum.CalculateDeviceMd5Sums(test_path, device)
- self.assertEquals(2, len(out))
- self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out)
- self.assertEquals('0123456789abcdeffedcba9876543210',
- out['/storage/emulated/legacy/test/file0.dat'])
- self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out)
- self.assertEquals('123456789abcdef00fedcba987654321',
- out['/storage/emulated/legacy/test/file1.dat'])
- self.assertEquals(1, len(device.RunShellCommand.call_args_list))
+ with mock.patch('os.path.getsize', return_value=1337):
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device)
+ self.assertEquals(2, len(out))
+ self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out)
+ self.assertEquals('0123456789abcdeffedcba9876543210',
+ out['/storage/emulated/legacy/test/file0.dat'])
+ self.assertTrue('/storage/emulated/legacy/test/file1.dat' in out)
+ self.assertEquals('123456789abcdef00fedcba987654321',
+ out['/storage/emulated/legacy/test/file1.dat'])
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list))
def testCalculateDeviceMd5Sums_singlePath_linkerWarning(self):
# See crbug/479966
@@ -159,12 +162,13 @@ class Md5SumTest(unittest.TestCase):
]
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)
- out = md5sum.CalculateDeviceMd5Sums(test_path, device)
- self.assertEquals(1, len(out))
- self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
- self.assertEquals('0123456789abcdeffedcba9876543210',
- out['/storage/emulated/legacy/test/file.dat'])
- self.assertEquals(1, len(device.RunShellCommand.call_args_list))
+ with mock.patch('os.path.getsize', return_value=1337):
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device)
+ self.assertEquals(1, len(out))
+ self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
+ self.assertEquals('0123456789abcdeffedcba9876543210',
+ out['/storage/emulated/legacy/test/file.dat'])
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list))
def testCalculateDeviceMd5Sums_list_fileMissing(self):
test_path = ['/storage/emulated/legacy/test/file0.dat',
@@ -178,12 +182,13 @@ class Md5SumTest(unittest.TestCase):
]
device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)
- out = md5sum.CalculateDeviceMd5Sums(test_path, device)
- self.assertEquals(1, len(out))
- self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out)
- self.assertEquals('0123456789abcdeffedcba9876543210',
- out['/storage/emulated/legacy/test/file0.dat'])
- self.assertEquals(1, len(device.RunShellCommand.call_args_list))
+ with mock.patch('os.path.getsize', return_value=1337):
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device)
+ self.assertEquals(1, len(out))
+ self.assertTrue('/storage/emulated/legacy/test/file0.dat' in out)
+ self.assertEquals('0123456789abcdeffedcba9876543210',
+ out['/storage/emulated/legacy/test/file0.dat'])
+ self.assertEquals(1, len(device.RunShellCommand.call_args_list))
def testCalculateDeviceMd5Sums_requiresBinary(self):
@@ -203,14 +208,15 @@ class Md5SumTest(unittest.TestCase):
device.RunShellCommand = mock.Mock(
side_effect=(error, device_md5sum_output))
- out = md5sum.CalculateDeviceMd5Sums(test_path, device)
- self.assertEquals(1, len(out))
- self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
- self.assertEquals('0123456789abcdeffedcba9876543210',
- out['/storage/emulated/legacy/test/file.dat'])
- self.assertEquals(2, len(device.RunShellCommand.call_args_list))
- device.adb.Push.assert_called_once_with(
- 'test/out/directory/md5sum_dist', '/data/local/tmp/md5sum/')
+ with mock.patch('os.path.getsize', return_value=1337):
+ out = md5sum.CalculateDeviceMd5Sums(test_path, device)
+ self.assertEquals(1, len(out))
+ self.assertTrue('/storage/emulated/legacy/test/file.dat' in out)
+ self.assertEquals('0123456789abcdeffedcba9876543210',
+ out['/storage/emulated/legacy/test/file.dat'])
+ self.assertEquals(2, len(device.RunShellCommand.call_args_list))
+ device.adb.Push.assert_called_once_with(
+ 'test/out/directory/md5sum_dist', '/data/local/tmp/md5sum/')
if __name__ == '__main__':
« no previous file with comments | « build/android/pylib/utils/md5sum.py ('k') | tools/android/md5sum/md5sum.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698