def test_log_when_exception(self): """Tests to ensure the method prints before it exits.""" testcase = mock.Mock(id=12345, build_url='', revision=4567) binary_definition = mock.Mock(source_var='V8_SRC', binary_name='binary') builder = binary_providers.ChromiumBuilder( testcase, binary_definition, False, '/goma/dir', None, False) with self.assertRaises(SystemExit): builder.get_current_sha()
def setUp(self): helpers.patch(self, ['multiprocessing.cpu_count', 'clusterfuzz.binary_providers.sha_from_revision']) testcase = mock.Mock(id=12345, build_url='', revision=4567) binary_definition = mock.Mock(source_var='V8_SRC', binary_name='binary') self.builder = binary_providers.ChromiumBuilder( testcase, binary_definition, False, '/goma/dir', None, False) self.mock.cpu_count.return_value = 64
def test_not_specifying(self): """Test not specifying goma threads.""" self.builder = binary_providers.ChromiumBuilder( self.testcase, self.definition, libs.make_options(goma_threads=None, goma_load=None, goma_dir='dir')) self.assertEqual(self.builder.get_goma_cores(), 3200) self.assertEqual(self.builder.get_goma_load(), 128)
def setUp(self): helpers.patch(self, [ 'clusterfuzz.binary_providers.install_build_deps', 'clusterfuzz.binary_providers.sha_from_revision', 'clusterfuzz.common.execute', 'clusterfuzz.binary_providers.get_binary_name', 'clusterfuzz.binary_providers.GenericBuilder.get_source_dir_path' ]) self.mock.get_source_dir_path.return_value = '/src' self.builder = binary_providers.ChromiumBuilder( libs.make_testcase(revision=1234), libs.make_definition(binary_name=''), libs.make_options())
def setUp(self): helpers.patch(self, [ 'clusterfuzz.binary_providers.sha_from_revision', 'clusterfuzz.common.execute', 'clusterfuzz.binary_providers.ChromiumBuilder.setup_gn_args', 'clusterfuzz.binary_providers.ChromiumBuilder.get_build_directory']) self.mock.sha_from_revision.return_value = '1a2s3d4f5g' self.mock.get_build_directory.return_value = '/chromium/build/dir' self.testcase = mock.Mock(id=12345, build_url='', revision=4567) self.mock_os_environment({'V8_SRC': '/chrome/src'}) self.binary_definition = mock.Mock( source_var='V8_SRC', binary_name='binary', target='target') self.builder = binary_providers.ChromiumBuilder( self.testcase, self.binary_definition, False, '/goma/dir', None, False) self.builder.build_directory = '/chrome/src/out/clusterfuzz_builds'
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) testcase = mock.Mock(id=12345, build_url='', revision=4567) self.mock_os_environment({'V8_SRC': self.chrome_source}) binary_definition = mock.Mock(source_var='V8_SRC', binary_name='binary') self.builder = binary_providers.ChromiumBuilder( testcase, binary_definition, False, '/goma/dir') self.builder.git_sha = '1a2s3d4f'
def test_no_binary_name(self): """Test the functionality when no binary name is provided.""" helpers.patch(self, [ 'clusterfuzz.binary_providers.ChromiumBuilder.get_goma_cores']) self.mock.get_goma_cores.return_value = 120 stacktrace = [ {'content': 'not correct'}, {'content': '[Environment] A = b'}, {'content': ('Running command: path/to/binary --flag-1 --flag2 opt' ' /testcase/path')}] testcase = mock.Mock(id=12345, build_url='', revision=4567, stacktrace_lines=stacktrace) binary_definition = mock.Mock(source_var='V8_SRC', binary_name=None) builder = binary_providers.ChromiumBuilder( testcase, binary_definition, False, '/goma/dir', None, False) self.assertEqual(builder.binary_name, 'binary')
def test_get_goma_cores(self): """Ensure goma_cores is calculated correctly.""" helpers.patch(self, ['multiprocessing.cpu_count']) self.mock.cpu_count.return_value = 12 builder = binary_providers.ChromiumBuilder( self.testcase, self.binary_definition, False, '/goma/dir', None, False) builder.goma_dir = False result = builder.get_goma_cores() self.assertEqual(result, 9) builder.goma_dir = True result = builder.get_goma_cores() self.assertEqual(result, 600)
def setUp(self): helpers.patch(self, [ 'clusterfuzz.common.execute', 'clusterfuzz.common.check_confirm', 'clusterfuzz.binary_providers.ensure_sha', 'clusterfuzz.binary_providers.get_current_sha', 'clusterfuzz.binary_providers.sha_from_revision', 'clusterfuzz.binary_providers.is_repo_dirty', ]) self.chrome_source = '/usr/local/google/home/user/repos/chromium/src' self.testcase = mock.Mock(id=12345, build_url='', revision=4567) self.mock_os_environment({'V8_SRC': self.chrome_source}) definition = mock.Mock(source_var='V8_SRC', binary_name='binary') self.builder = binary_providers.ChromiumBuilder( self.testcase, definition, libs.make_options()) self.builder.git_sha = '1a2s3d4f'
def test_no_binary_name(self): """Test the functionality when no binary name is provided.""" stacktrace = [{ 'content': 'not correct' }, { 'content': '[Environment] A = b' }, { 'content': ('Running command: path/to/binary --flag-1 --flag2 opt' ' /testcase/path') }] testcase = mock.Mock(id=12345, build_url='', revision=4567, stacktrace_lines=stacktrace) definition = mock.Mock(source_var='V8_SRC', binary_name=None) builder = binary_providers.ChromiumBuilder(testcase, definition, libs.make_options()) self.assertEqual(builder.binary_name, 'binary')
def test_specifying_goma_load(self): """Ensures that if load are manually specified, they are used.""" self.builder = binary_providers.ChromiumBuilder( self.testcase, self.definition, libs.make_options(goma_load=100, goma_dir='dir')) self.assertEqual(self.builder.get_goma_load(), 100)