Beispiel #1
0
    def test_correct_calls(self):
        """Tests the correct checks and commands are run to build."""

        revision_num = 12345
        testcase_id = 54321
        chrome_source = '/chrome/source'
        goma_dir = '/goma/dir/location'
        testcase = mock.Mock(id=testcase_id,
                             build_url='',
                             revision=revision_num)
        self.mock_os_environment({'V8_SRC': chrome_source})
        binary_definition = mock.Mock(source_var='V8_SRC',
                                      binary_name='binary')
        builder = binary_providers.V8Builder(testcase, binary_definition,
                                             False, goma_dir)
        builder.build_directory = '/chrome/source/out/clusterfuzz_54321'
        builder.build_target()

        self.assert_exact_calls(self.mock.execute, [
            mock.call('GYP_DEFINES=asan=1 gclient runhooks', chrome_source),
            mock.call('GYP_DEFINES=asan=1 gypfiles/gyp_v8', chrome_source),
            mock.call('gclient sync', chrome_source),
            mock.call((
                "ninja -w 'dupbuild=err' -C /chrome/source/out/clusterfuzz_54321 "
                "-j 120 -l 120 d8"),
                      chrome_source,
                      capture_output=False)
        ])

        self.assert_exact_calls(self.mock.setup_gn_args, [mock.call(builder)])
  def test_correct_calls(self):
    """Tests the correct checks and commands are run to build."""

    revision_num = 12345
    testcase_id = 54321
    chrome_source = '/chrome/source'
    goma_dir = '/goma/dir/location'
    testcase = mock.Mock(id=testcase_id, build_url='', revision=revision_num)
    self.mock_os_environment({'V8_SRC': chrome_source})
    binary_definition = mock.Mock(source_var='V8_SRC', binary_name='binary')
    builder = binary_providers.V8Builder(
        testcase, binary_definition, False, goma_dir, None, False)
    builder.build_directory = '/chrome/source/out/clusterfuzz_54321'
    builder.build_target()

    self.assert_exact_calls(self.mock.execute, [
        mock.call('gclient', 'sync', chrome_source),
        mock.call('gclient', 'runhooks', chrome_source),
        mock.call('python', 'tools/clang/scripts/update.py', chrome_source),
        mock.call(
            'ninja',
            ("-w 'dupbuild=err' -C /chrome/source/out/clusterfuzz_54321 "
             '-j 120 -l 15 d8'),
            chrome_source,
            capture_output=False)
    ])
    self.assert_exact_calls(self.mock.setup_gn_args, [mock.call(builder)])
Beispiel #3
0
    def test_correct_calls(self):
        """Tests the correct checks and commands are run to build."""

        revision_num = 12345
        testcase_id = 54321
        chrome_source = '/chrome/source'
        testcase = mock.Mock(id=testcase_id,
                             build_url='',
                             revision=revision_num)
        self.mock_os_environment({'V8_SRC': chrome_source})
        definition = mock.Mock(source_var='V8_SRC', binary_name='binary')
        builder = binary_providers.V8Builder(testcase, definition,
                                             libs.make_options())
        builder.build_directory = '/chrome/source/out/clusterfuzz_54321'
        builder.build_target()

        self.assert_exact_calls(self.mock.execute, [
            mock.call('gclient', 'sync --no-history --shallow', chrome_source),
            mock.call('gclient', 'runhooks', chrome_source),
            mock.call('python', 'tools/clang/scripts/update.py',
                      chrome_source),
            mock.call(
                'ninja',
                ("-w 'dupbuild=err' -C /chrome/source/out/clusterfuzz_54321 "
                 '-j 120 -l 8 d8'),
                chrome_source,
                capture_output=False,
                stdout_transformer=mock.ANY)
        ])
        self.assertIsInstance(
            self.mock.execute.call_args[1]['stdout_transformer'],
            output_transformer.Ninja)
        self.assert_exact_calls(self.mock.setup_gn_args, [mock.call(builder)])
Beispiel #4
0
 def setUp(self):
     helpers.patch(self, ['clusterfuzz.binary_providers.sha_from_revision'])
     self.mock_os_environment({'V8_SRC': '/source/dir'})
     testcase = mock.Mock(id=1234, build_url='', revision=54321)
     definition = mock.Mock(source_var='V8_SRC')
     self.builder = binary_providers.V8Builder(
         testcase, definition, libs.make_options(testcase_id=testcase.id))
Beispiel #5
0
    def test_parameter_not_set_invalid_source(self):
        """Tests when build is not downloaded & no valid source passed."""

        self.mock_os_environment({'V8_SRC': ''})
        testcase = mock.Mock(id=12345,
                             build_url=self.build_url,
                             revision=54321)
        binary_definition = mock.Mock(source_var='V8_SRC')
        provider = binary_providers.V8Builder(testcase, binary_definition,
                                              False, '/goma/dir')

        self.mock.ask.return_value = self.chrome_source

        result = provider.get_build_directory()
        self.assertEqual(
            result,
            os.path.join(self.chrome_source, 'out',
                         'clusterfuzz_12345_1a2s3d4f5g6h'))
        self.assert_exact_calls(self.mock.download_build_data,
                                [mock.call(provider)])
        self.assert_exact_calls(self.mock.build_target, [mock.call(provider)])
        self.assert_exact_calls(self.mock.checkout_source_by_sha,
                                [mock.call(provider)])
        self.assert_exact_calls(self.mock.ask, [
            mock.call(('This is a V8 testcase, please define $V8_SRC or enter '
                       'your V8 source location here'),
                      'Please enter a valid directory', mock.ANY)
        ])
Beispiel #6
0
 def test_run(self):
     """Test run."""
     builder = binary_providers.V8Builder(
         self.testcase, self.definition,
         libs.make_options(goma_dir='/goma/dir', skip_deps=False))
     builder.setup_all_deps()
     self.mock.gclient_sync.assert_called_once_with(builder)
     self.mock.gclient_runhooks.assert_called_once_with(builder)
     self.mock.install_deps.assert_called_once_with(builder)
Beispiel #7
0
 def test_skip(self):
     """Test skip."""
     builder = binary_providers.V8Builder(
         self.testcase, self.definition,
         libs.make_options(goma_dir='/goma/dir', skip_deps=True))
     builder.setup_all_deps()
     self.assert_n_calls(0, [
         self.mock.gclient_sync, self.mock.gclient_runhooks,
         self.mock.install_deps
     ])
 def setUp(self):
   helpers.patch(self, ['clusterfuzz.common.execute',
                        'clusterfuzz.binary_providers.sha_from_revision'])
   self.mock_os_environment({'V8_SRC': '/source/dir'})
   self.sha = '1a2s3d4f5g6h'
   self.mock.sha_from_revision.return_value = self.sha
   testcase = mock.Mock(id=1234, build_url='', revision=54321)
   binary_definition = mock.Mock(source_var='V8_SRC')
   self.builder = binary_providers.V8Builder(
       testcase, binary_definition, False, '/goma/dir', None, False)
    def test_parameter_already_set(self):
        """Tests functionality when build_directory parameter is already set."""

        provider = binary_providers.V8Builder(12345, self.build_url, '', False,
                                              '', '')
        provider.build_directory = 'dir/already/set'

        result = provider.get_build_directory()
        self.assertEqual(result, 'dir/already/set')
        self.assert_n_calls(0, [self.mock.download_build_data])
 def setUp(self):
     self.setup_fake_filesystem()
     helpers.patch(self, [
         'clusterfuzz.common.execute',
         'clusterfuzz.binary_providers.sha_from_revision'
     ])
     self.testcase_dir = os.path.expanduser(os.path.join('~', 'test_dir'))
     self.builder = binary_providers.V8Builder(1234, '', '', False,
                                               '/goma/dir',
                                               '/chrome/source/dir')
 def setUp(self):
     helpers.patch(self, [
         'clusterfuzz.common.execute', 'clusterfuzz.common.check_confirm',
         'clusterfuzz.binary_providers.sha_from_revision'
     ])
     self.chrome_source = '/usr/local/google/home/user/repos/chromium/src'
     self.command = ('git fetch && git checkout 1a2s3d4f'
                     ' in %s' % self.chrome_source)
     self.builder = binary_providers.V8Builder(1234, '', 12345, False, '',
                                               self.chrome_source)
     self.builder.git_sha = '1a2s3d4f'
 def setUp(self):
     helpers.patch(self, [
         'clusterfuzz.binary_providers.GenericBuilder.get_source_dir_path',
         'clusterfuzz.binary_providers.sha_from_revision',
         'clusterfuzz.binary_providers.get_third_party_sha',
         'clusterfuzz.binary_providers.install_build_deps',
         'clusterfuzz.common.execute',
     ])
     self.mock.get_source_dir_path.return_value = '/src'
     self.builder = binary_providers.V8Builder(
         libs.make_testcase(revision=1234), libs.make_definition(),
         libs.make_options())
Beispiel #13
0
 def setUp(self):
     self.setup_fake_filesystem()
     helpers.patch(self, [
         'clusterfuzz.common.execute',
         'clusterfuzz.binary_providers.sha_from_revision'
     ])
     self.testcase_dir = os.path.expanduser(os.path.join('~', 'test_dir'))
     testcase = mock.Mock(id=1234, build_url='', revision=54321)
     self.mock_os_environment({'V8_SRC': '/chrome/source/dir'})
     binary_definition = mock.Mock(source_var='V8_SRC')
     self.builder = binary_providers.V8Builder(testcase, binary_definition,
                                               False, '/goma/dir')
  def test_parameter_already_set(self):
    """Tests functionality when build_directory parameter is already set."""

    testcase = mock.Mock(id=12345, build_url=self.build_url, revision=54321)
    binary_definition = mock.Mock(source_var='V8_SRC')
    provider = binary_providers.V8Builder(
        testcase, binary_definition, False, '/goma/dir', None, False)

    provider.build_directory = 'dir/already/set'

    result = provider.get_build_directory()
    self.assertEqual(result, 'dir/already/set')
    self.assert_n_calls(0, [self.mock.download_build_data])
Beispiel #15
0
    def test_parameter_already_set(self):
        """Tests functionality when build_directory parameter is already set."""

        testcase = mock.Mock(id=12345,
                             build_url=self.build_url,
                             revision=54321)
        definition = mock.Mock(source_var='V8_SRC')
        provider = binary_providers.V8Builder(testcase, definition,
                                              libs.make_options())

        provider.build_directory = 'dir/already/set'

        result = provider.get_build_directory()
        self.assertEqual(result, 'dir/already/set')
    def test_parameter_not_set_valid_source(self):
        """Tests functionality when build has never been downloaded."""

        chrome_source = os.path.join('chrome', 'src', 'dir')
        provider = binary_providers.V8Builder(12345, self.build_url, 54321,
                                              False, '', chrome_source)

        result = provider.get_build_directory()
        self.assertEqual(
            result, os.path.join(chrome_source, 'out', 'clusterfuzz_12345'))
        self.assert_exact_calls(self.mock.download_build_data,
                                [mock.call(provider)])
        self.assert_exact_calls(self.mock.build_target, [mock.call(provider)])
        self.assert_exact_calls(self.mock.checkout_source_by_sha,
                                [mock.call(provider)])
        self.assert_n_calls(0, [self.mock.ask])
  def setUp(self):
    self.setup_fake_filesystem()
    helpers.patch(self, [
        'clusterfuzz.common.execute',
        'clusterfuzz.binary_providers.sha_from_revision',
        'cmd_editor.editor.edit'
    ])
    self.testcase_dir = os.path.expanduser(os.path.join('~', 'test_dir'))
    testcase = mock.Mock(id=1234, build_url='', revision=54321, gn_args=None)
    self.mock_os_environment({'V8_SRC': '/chrome/source/dir'})
    binary_definition = mock.Mock(source_var='V8_SRC')
    self.builder = binary_providers.V8Builder(
        testcase, binary_definition, False, '/goma/dir', None, True)

    def edit(content, prefix, comment):  # pylint: disable=unused-argument
      return content + '\nedited'
    self.mock.edit.side_effect = edit
  def test_parameter_not_set_valid_source(self):
    """Tests functionality when build has never been downloaded."""

    self.mock_os_environment({'V8_SRC': self.chrome_source})
    testcase = mock.Mock(id=12345, build_url=self.build_url, revision=54321,
                         gn_args=None)
    binary_definition = mock.Mock(source_var='V8_SRC')
    provider = binary_providers.V8Builder(
        testcase, binary_definition, False, '/goma/dir', None, False)

    result = provider.get_build_directory()
    self.assertEqual(result, os.path.join(self.chrome_source, 'out',
                                          'clusterfuzz_12345_1a2s3d4f5g6h'))
    self.assert_exact_calls(self.mock.download_build_data,
                            [mock.call(provider)])
    self.assert_exact_calls(self.mock.build_target, [mock.call(provider)])
    self.assert_exact_calls(self.mock.checkout_source_by_sha,
                            [mock.call(provider)])
    self.assert_n_calls(0, [self.mock.ask])
Beispiel #19
0
def execute(testcase_id, current, download):
  """Execute the reproduce command."""

  print 'Reproduce %s (current=%s)' % (testcase_id, current)
  print 'Downloading testcase information...'

  response = get_testcase_info(testcase_id)
  goma_dir = ensure_goma()
  current_testcase = testcase.Testcase(response)

  if download:
    binary_provider = binary_providers.V8DownloadedBinary(
        current_testcase.id, current_testcase.build_url)
  else:
    binary_provider = binary_providers.V8Builder( # pylint: disable=redefined-variable-type
        current_testcase.id, current_testcase.build_url,
        current_testcase.revision, current, goma_dir, os.environ.get('V8_SRC'))

  reproduce_crash(binary_provider.get_binary_path(), current_testcase)
Beispiel #20
0
    def test_parameter_not_set_valid_source(self):
        """Tests functionality when build has never been downloaded."""

        self.mock_os_environment({'V8_SRC': self.chrome_source})
        testcase = mock.Mock(id=12345,
                             build_url=self.build_url,
                             revision=54321,
                             gn_args=None)
        definition = mock.Mock(source_var='V8_SRC')
        provider = binary_providers.V8Builder(
            testcase, definition, libs.make_options(testcase_id=testcase.id))

        result = provider.get_build_directory()
        self.assertEqual(
            result, os.path.join(self.chrome_source, 'out',
                                 'clusterfuzz_12345'))
        self.assert_exact_calls(self.mock.build_target, [mock.call(provider)])
        self.assert_exact_calls(self.mock.checkout_source_by_sha,
                                [mock.call(provider)])
Beispiel #21
0
    def setUp(self):
        self.setup_fake_filesystem()
        helpers.patch(self, [
            'clusterfuzz.common.execute',
            'clusterfuzz.binary_providers.sha_from_revision',
            'clusterfuzz.common.edit_if_needed',
        ])
        self.testcase_dir = os.path.expanduser(os.path.join('~', 'test_dir'))
        testcase = mock.Mock(id=1234,
                             build_url='',
                             revision=54321,
                             gn_args=None)
        self.mock_os_environment({'V8_SRC': '/chrome/source/dir'})
        self.definition = mock.Mock(source_var='V8_SRC')
        self.builder = binary_providers.V8Builder(
            testcase, self.definition, libs.make_options(goma_dir='/goma/dir'))

        self.mock.edit_if_needed.side_effect = (
            lambda content, prefix, comment, should_edit: content)
    def test_correct_calls(self):
        """Tests the correct checks and commands are run to build."""

        revision_num = 12345
        testcase_id = 54321
        chrome_source = '/chrome/source'
        goma_dir = '/goma/dir/location'
        builder = binary_providers.V8Builder(testcase_id, 'build_url',
                                             revision_num, False, goma_dir,
                                             chrome_source)
        builder.build_directory = '/chrome/source/out/clusterfuzz_54321'
        builder.build_target()

        self.assert_exact_calls(self.mock.execute, [
            mock.call('GYP_DEFINES=asan=1 gclient runhooks', chrome_source),
            mock.call('GYP_DEFINES=asan=1 gypfiles/gyp_v8', chrome_source),
            mock.call(
                'ninja -C /chrome/source/out/clusterfuzz_54321 -j 120 d8',
                chrome_source)
        ])
        self.assert_exact_calls(self.mock.setup_gn_args, [mock.call(builder)])
    def test_parameter_not_set_invalid_source(self):
        """Tests when build is not downloaded & no valid source passed."""

        chrome_source = os.path.join('chrome', 'src', 'dir')
        provider = binary_providers.V8Builder(12345, self.build_url, 54321,
                                              False, '', None)
        self.mock.ask.return_value = chrome_source

        result = provider.get_build_directory()
        self.assertEqual(
            result, os.path.join(chrome_source, 'out', 'clusterfuzz_12345'))
        self.assert_exact_calls(self.mock.download_build_data,
                                [mock.call(provider)])
        self.assert_exact_calls(self.mock.build_target, [mock.call(provider)])
        self.assert_exact_calls(self.mock.checkout_source_by_sha,
                                [mock.call(provider)])
        self.assert_exact_calls(self.mock.ask, [
            mock.call(('This is a V8 testcase, please define $V8_SRC or enter '
                       'your V8 source location here'),
                      'Please enter a valid directory', mock.ANY)
        ])