Example #1
0
def _EnsureTraceProcessor(trace_processor_path):
    global _fetched_trace_processor

    if trace_processor_path is None:
        with _fetch_lock:
            if not _fetched_trace_processor:
                _fetched_trace_processor = binary_deps_manager.FetchHostBinary(
                    TP_BINARY_NAME)
                logging.info('Trace processor binary downloaded to %s',
                             _fetched_trace_processor)
        trace_processor_path = _fetched_trace_processor

    if not os.path.isfile(trace_processor_path):
        raise RuntimeError("Can't find trace processor executable at %s" %
                           trace_processor_path)
    return trace_processor_path
Example #2
0
 def testFetchHostBinaryWrongHash(self):
   remote_path = 'remote/path/to/bin'
   self.writeConfig({
       'dep': {
           'testos': {
               'remote_path': remote_path,
               'hash': '123',
           }
       }
   })
   with mock.patch('py_utils.cloud_storage.Get'):
     with mock.patch('py_utils.GetHostOsName') as get_os_patch:
       with mock.patch('py_utils.cloud_storage.CalculateHash') as hash_patch:
         hash_patch.return_value = '234'
         get_os_patch.return_value = 'testos'
         with self.assertRaises(RuntimeError):
           binary_deps_manager.FetchHostBinary('dep')
Example #3
0
  def testFetchHostBinary(self):
    remote_path = 'remote/path/to/bin'
    self.writeConfig({
        'dep': {
            'testos': {
                'remote_path': remote_path,
                'hash': '123',
            }
        }
    })
    with mock.patch('py_utils.cloud_storage.Get') as get_patch:
      with mock.patch('py_utils.GetHostOsName') as get_os_patch:
        with mock.patch('py_utils.cloud_storage.CalculateHash') as hash_patch:
          with mock.patch('os.stat'):
            with mock.patch('os.chmod'):
              hash_patch.return_value = '123'
              get_os_patch.return_value = 'testos'
              local_path = binary_deps_manager.FetchHostBinary('dep')

    self.assertEqual(os.path.basename(local_path), 'bin')
    get_patch.assert_called_once_with('chromium-telemetry', remote_path,
                                      local_path)