def test_get_component_range_list_0_start_custom(self, mock_get_url_content, mock_get_config): """Test get_component_range_list with a '0' start_revision.""" mock_get_config.return_value = self.MockConfigOSSFuzz() self.mock.default_project_name.return_value = 'oss-fuzz' mock_get_url_content.side_effect = self.mock_get_url_content result = revisions.get_component_range_list(0, 1338, SRCMAP_JOB_TYPE) result_as_html = revisions.format_revision_list(result) expected_html = self._read_data_file('srcmap_expected_html_3.txt') self.assertEqual(result_as_html, expected_html)
def test_get_component_revision_list_src_map_text(self, mock_get_url_content, mock_get_config): """Test get_component_range_list for srcmap jobs (text only).""" mock_get_config.return_value = self.MockConfigOSSFuzz() self.mock.default_project_name.return_value = 'oss-fuzz' mock_get_url_content.side_effect = self.mock_get_url_content result = revisions.get_component_range_list(1337, 9001, SRCMAP_JOB_TYPE) result_as_html = revisions.format_revision_list(result, use_html=False) expected_html = self._read_data_file('srcmap_expected_text.txt') self.assertEqual(result_as_html, expected_html)
def test_get_component_range_list_same_hash(self, mock_get_url_content, mock_get_config): """Test get_component_range_list for 2 builds that have different revision numbers, but same revision hash after mapping.""" mock_get_config.return_value = self.MockConfigOSSFuzz() self.mock.default_project_name.return_value = 'oss-fuzz' mock_get_url_content.side_effect = self.mock_get_url_content result = revisions.get_component_range_list(1337, 1338, SRCMAP_JOB_TYPE) result_as_html = revisions.format_revision_list(result) expected_html = self._read_data_file('srcmap_expected_html_2.txt') self.assertEqual(result_as_html, expected_html)
def test_get_component_range_list_clank( self, mock_get_git_hash, mock_get_url_content, mock_get_config): """Test that get_component_range_list works properly for the Clank repo.""" mock_get_config.return_value = self.MockConfigChromium() self.mock.default_project_name.return_value = 'chromium' mock_get_url_content.side_effect = self.mock_get_url_content mock_get_git_hash.side_effect = self.mock_get_git_hash_for_git_commit_pos result = revisions.get_component_range_list(260548, 260552, ANDROID_JOB_TYPE) result_as_html = revisions.format_revision_list(result) expected_html = self._read_data_file('clank_expected_html.txt') self.assertEqual(result_as_html, expected_html)
def _get_revision_range_html(job_type, platform_id, start_revision, end_revision=None): """Return revision range html for a revision range and job type.""" if end_revision is None: end_revision = start_revision component_rev_list = revisions.get_component_range_list( start_revision, end_revision, job_type, platform_id=platform_id) if not component_rev_list: return ('%s:%s (No component revisions found!)' % (start_revision, end_revision)) return revisions.format_revision_list(component_rev_list)
def prepare_log_for_upload(symbolized_output, return_code): """Prepare log for upload.""" # Add revision information to the logs. app_revision = environment.get_value('APP_REVISION') job_name = environment.get_value('JOB_NAME') components = revisions.get_component_list(app_revision, job_name) component_revisions = (revisions.format_revision_list(components, use_html=False) or 'Not available.\n') revisions_header =\ f'Component revisions (build r{app_revision}):\n{component_revisions}\n' bot_name = environment.get_value('BOT_NAME') bot_header = f'Bot name: {bot_name}\n' if environment.is_android(): bot_header += f'Device serial: {environment.get_value("ANDROID_SERIAL")}\n' return_code_header = "Return code: %s\n\n" % return_code result = revisions_header + bot_header + return_code_header +\ symbolized_output return result.encode('utf-8')