md5sum_test.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:buildroot 作者: flutter 项目源码 文件源码
def testCalculateDeviceMd5Sums_singlePath_linkerWarning(self):
    # See crbug/479966
    test_path = '/storage/emulated/legacy/test/file.dat'

    device = mock.NonCallableMock()
    device.adb = mock.NonCallableMock()
    device.adb.Push = mock.Mock()
    device_md5sum_output = [
        'WARNING: linker: /data/local/tmp/md5sum/md5sum_bin: '
            'unused DT entry: type 0x1d arg 0x15db',
        'THIS_IS_NOT_A_VALID_CHECKSUM_ZZZ some random text',
        '0123456789abcdeffedcba9876543210 '
            '/storage/emulated/legacy/test/file.dat',
    ]
    device.RunShellCommand = mock.Mock(return_value=device_md5sum_output)

    mock_temp_file = mock.mock_open()
    mock_temp_file.return_value.name = '/tmp/test/script/file.sh'

    mock_device_temp_file = mock.mock_open()
    mock_device_temp_file.return_value.name = (
        '/data/local/tmp/test/script/file.sh')

    with mock.patch('tempfile.NamedTemporaryFile', new=mock_temp_file), (
         mock.patch('pylib.utils.device_temp_file.DeviceTempFile',
                    new=mock_device_temp_file)):
      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'])
      device.adb.Push.assert_called_once_with(
          '/tmp/test/script/file.sh', '/data/local/tmp/test/script/file.sh')
      device.RunShellCommand.assert_called_once_with(
          ['sh', '/data/local/tmp/test/script/file.sh'])
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号