Esempio n. 1
0
def execute(argv=None):
  """The main entry point."""
  local_logging.start_loggers()
  logger.info('Version: %s', common.get_version())
  logger.info('Path: %s', __file__)

  parser = argparse.ArgumentParser(description='ClusterFuzz tools')
  subparsers = parser.add_subparsers(dest='command')

  subparsers.add_parser('supported_job_types',
                        help='List all supported job types')
  reproduce = subparsers.add_parser('reproduce', help='Reproduce a crash.')
  reproduce.add_argument('testcase_id', help='The testcase ID.')
  reproduce.add_argument(
      '-c', '--current', action='store_true', default=False,
      help=('Use the current tree; On the other hand, without --current, '
            'the Chrome repository will be switched to the commit specified in '
            'the testcase.'))
  reproduce.add_argument(
      '-b', '--build', action='store', default='chromium',
      choices=['download', 'chromium', 'standalone'],
      help='Select which type of build to run the testcase against.')
  reproduce.add_argument(
      '--disable-goma', action='store_true', default=False,
      help='Disable GOMA when building binaries locally.')
  reproduce.add_argument(
      '-j', '--goma-threads', action='store', default=None, type=int,
      help='Manually specify the number of concurrent jobs for a ninja build.')
  reproduce.add_argument(
      '-i', '--iterations', action='store', default=10, type=int,
      help='Specify the number of times to attempt reproduction.')
  reproduce.add_argument(
      '-dx', '--disable-xvfb', action='store_true', default=False,
      help='Disable running testcases in a virtual frame buffer.')
  reproduce.add_argument(
      '--target-args', action='store', default='',
      help='Additional arguments for the target (e.g. chrome).')
  reproduce.add_argument(
      '--edit-mode', action='store_true', default=False,
      help='Edit args.gn before building and target arguments before running.')
  reproduce.add_argument(
      '--disable-gclient', action='store_true', default=False,
      help='Disable running gclient commands (e.g. sync, runhooks).')
  reproduce.add_argument(
      '--enable-debug', action='store_true', default=False,
      help=(
          'Build Chrome with full debug symbols by injecting '
          '`sanitizer_keep_symbols = true` and `is_debug = true` to args.gn. '
          'Ready to debug with GDB.'))

  args = parser.parse_args(argv)
  command = importlib.import_module('clusterfuzz.commands.%s' % args.command)

  arg_dict = {k: v for k, v in vars(args).items()}
  del arg_dict['command']

  command.execute(**arg_dict)
  def test_start(self):
    """Test starting a logger."""
    rotating_handler = logging.handlers.RotatingFileHandler(filename='test.log')
    self.mock.getLogger.return_value = (
        mock.Mock(handlers=[logging.NullHandler(), rotating_handler]))

    local_logging.start_loggers()

    self.mock.getLogger.assert_called_once_with('clusterfuzz')
    self.assertTrue(os.path.exists(local_logging.LOG_DIR))
    self.mock.doRollover.assert_called_once_with(rotating_handler)
Esempio n. 3
0
    def setUp(self):
        helpers.patch(self, [
            'subprocess.Popen', 'logging.getLogger',
            'logging.config.dictConfig', 'clusterfuzz.common.check_binary',
            'clusterfuzz.common.wait_timeout',
            'clusterfuzz.common.interpret_ninja_output', 'os.environ.copy'
        ])
        self.mock.copy.return_value = {'OS': 'ENVIRON'}
        self.mock.dictConfig.return_value = {}

        from clusterfuzz import local_logging
        local_logging.start_loggers()
        self.lines = 'Line 1\nLine 2\nLine 3'
    def setUp(self):
        helpers.patch(self, [
            'clusterfuzz.common.check_binary', 'clusterfuzz.common.kill',
            'clusterfuzz.common.wait_timeout', 'logging.config.dictConfig',
            'logging.getLogger', 'os.environ.copy', 'subprocess.Popen',
            'time.sleep'
        ])
        self.mock.copy.return_value = {'OS': 'ENVIRON'}
        self.mock.dictConfig.return_value = {}

        from clusterfuzz import local_logging
        local_logging.start_loggers()
        self.stdout = 'Line 1\nLine 2\nLine 3\n'
        self.residue_stdout = 'residue'
        self.stderr = 'Err 1\nErr 2\nErr 3'