Ejemplo n.º 1
0
 def test_convert(self):
     """Test convert."""
     expected = [
         show.Line(1, 'a', False),
         show.Line(2, 'b', True),
         show.Line(3, 'c', True),
         show.Line(4, 'd', False),
         show.Line(5, 'e', False),
     ]
     self.assertEqual(
         expected, show.convert_to_lines('a\nb\nc\nd\ne', ['b', 'c'], 'd'))
Ejemplo n.º 2
0
 def _test_special_type(self, crash_type):
     expected = [
         show.Line(1, 'a', False),
         show.Line(2, 'ERROR: something', True),
         show.Line(3, 'c', False),
         show.Line(4, 'SUMMARY: test', False),
         show.Line(5, 'e', False),
     ]
     self.assertEqual(
         expected,
         show.convert_to_lines('a\nERROR: something\nc\nSUMMARY: test\ne',
                               ['dontcare'], crash_type))
Ejemplo n.º 3
0
 def _make(self, array):
     """Create either Line from a tuple or Gap from an int."""
     preview_lines_with_gaps = []
     line_number = 1
     for line in array:
         if isinstance(line, basestring):
             preview_lines_with_gaps.append(
                 show.Line(line_number, line, line.startswith('t-')))
             line_number += 1
         else:
             line_number += line
             preview_lines_with_gaps.append(show.Gap(line))
     return preview_lines_with_gaps
Ejemplo n.º 4
0
    def test_unreproducible_get(self):
        """Test valid unreproducible testcase."""
        self.mock.get_last_crash_time.return_value = datetime.datetime(
            2000, 1, 1)

        testcase = data_types.Testcase()
        testcase.job_type = 'windows_asan_chrome'
        testcase.crash_type = 'crash_type1\ncrash_type2'
        testcase.crash_address = 'crash_address'
        testcase.crash_state = 'crash_state'
        testcase.crash_revision = 123
        testcase.regression = None
        testcase.fixed = None
        testcase.fuzzed_keys = None
        testcase.minimized_keys = None
        testcase.timestamp = datetime.datetime(1970, 1, 1)
        testcase.project_name = 'chromium'
        testcase.one_time_crasher_flag = True
        testcase.put()

        job = data_types.Job()
        job.name = 'windows_asan_chrome'
        job.custom_binary_revision = 1234
        job.put()

        self.mock.can_user_access_testcase.return_value = True
        self.mock.get_issue_url.return_value = 'issue_url'
        self.mock.get_stacktrace.return_value = 'crash_stacktrace'
        self.mock.filter_stacktrace.return_value = 'crash_stacktrace'
        self.mock.get_environment.return_value = ({'HELP_URL': 'help_url'})
        self.mock.generate_csrf_token.return_value = 'csrf'

        result = show.get_testcase_detail_by_id(2)
        expected_subset = {
            'id': 2,
            'crash_type': 'crash_type1 crash_type2',
            'crash_address': 'crash_address',
            'crash_state': 'crash_state',
            'crash_state_lines': ['crash_state'],
            'crash_revision': 123,
            'csrf_token': 'csrf',
            'external_user': True,
            'footer': '',
            'fixed': 'NO',
            'issue_url': 'issue_url',
            'metadata': {},
            'minimized_testcase_size': '',
            'needs_refresh': True,
            'original_testcase_size': '',
            'privileged_user': False,
            'regression': 'Pending',
            'security_severity': None,
            'show_impact': False,
            'show_blame': True,
            'auto_delete_timestamp': 947289600.0,
            'auto_close_timestamp': None,
            'memory_tool_display_label': 'Sanitizer',
            'memory_tool_display_value': 'address (ASAN)',
            'last_tested': 'name: 0:revision<br />',
            'is_admin_or_not_oss_fuzz': True,
            'has_issue_tracker': True,
            'reproduction_help_url': 'help_url',
        }

        self.maxDiff = None  # pylint: disable=invalid-name
        self.assertDictContainsSubset(expected_subset, result)
        self.assertEqual(result['testcase'].key.id(), testcase.key.id())

        self.assertDictContainsSubset(
            {'lines': [show.Line(1, 'crash_stacktrace', False)]},
            result['crash_stacktrace'])
        self.assertDictContainsSubset(
            {'lines': [show.Line(1, 'crash_stacktrace', False)]},
            result['second_crash_stacktrace'])
        self.assertDictContainsSubset(
            {'lines': [show.Line(1, 'crash_stacktrace', False)]},
            result['last_tested_crash_stacktrace'])