OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 The Chromium Authors. All rights reserved. |
3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
5 | 5 |
6 import os | 6 import os |
7 import sys | 7 import sys |
8 import unittest | 8 import unittest |
9 | 9 |
10 from pylib import cmd_helper | 10 from pylib import cmd_helper |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 self.assertEquals(2, len(out)) | 170 self.assertEquals(2, len(out)) |
171 self.assertEquals('0123456789abcdeffedcba9876543210', out[0].hash) | 171 self.assertEquals('0123456789abcdeffedcba9876543210', out[0].hash) |
172 self.assertEquals('/storage/emulated/legacy/test/file0.dat', out[0].path) | 172 self.assertEquals('/storage/emulated/legacy/test/file0.dat', out[0].path) |
173 self.assertEquals('123456789abcdef00fedcba987654321', out[1].hash) | 173 self.assertEquals('123456789abcdef00fedcba987654321', out[1].hash) |
174 self.assertEquals('/storage/emulated/legacy/test/file1.dat', out[1].path) | 174 self.assertEquals('/storage/emulated/legacy/test/file1.dat', out[1].path) |
175 device.adb.Push.assert_called_once_with( | 175 device.adb.Push.assert_called_once_with( |
176 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh') | 176 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh') |
177 device.RunShellCommand.assert_called_once_with( | 177 device.RunShellCommand.assert_called_once_with( |
178 ['sh', '/data/local/tmp/test/script/file.sh']) | 178 ['sh', '/data/local/tmp/test/script/file.sh']) |
179 | 179 |
| 180 def testCalculateDeviceMd5Sums_singlePath_linkerWarning(self): |
| 181 # See crbug/479966 |
| 182 test_path = '/storage/emulated/legacy/test/file.dat' |
| 183 |
| 184 device = mock.NonCallableMock() |
| 185 device.adb = mock.NonCallableMock() |
| 186 device.adb.Push = mock.Mock() |
| 187 device_md5sum_output = [ |
| 188 'WARNING: linker: /data/local/tmp/md5sum/md5sum_bin: ' |
| 189 'unused DT entry: type 0x1d arg 0x15db', |
| 190 '0123456789abcdeffedcba9876543210 ' |
| 191 '/storage/emulated/legacy/test/file.dat', |
| 192 ] |
| 193 device.RunShellCommand = mock.Mock(return_value=device_md5sum_output) |
| 194 |
| 195 mock_temp_file = mock.mock_open() |
| 196 mock_temp_file.return_value.name = '/tmp/test/script/file.sh' |
| 197 |
| 198 mock_device_temp_file = mock.mock_open() |
| 199 mock_device_temp_file.return_value.name = ( |
| 200 '/data/local/tmp/test/script/file.sh') |
| 201 |
| 202 with mock.patch('tempfile.NamedTemporaryFile', new=mock_temp_file), ( |
| 203 mock.patch('pylib.utils.device_temp_file.DeviceTempFile', |
| 204 new=mock_device_temp_file)): |
| 205 out = md5sum.CalculateDeviceMd5Sums(test_path, device) |
| 206 self.assertEquals(1, len(out)) |
| 207 self.assertEquals('0123456789abcdeffedcba9876543210', out[0].hash) |
| 208 self.assertEquals('/storage/emulated/legacy/test/file.dat', out[0].path) |
| 209 device.adb.Push.assert_called_once_with( |
| 210 '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh') |
| 211 device.RunShellCommand.assert_called_once_with( |
| 212 ['sh', '/data/local/tmp/test/script/file.sh']) |
| 213 |
180 | 214 |
181 if __name__ == '__main__': | 215 if __name__ == '__main__': |
182 unittest.main(verbosity=2) | 216 unittest.main(verbosity=2) |
183 | 217 |
OLD | NEW |