Пример #1
0
    def test_diff_open_reports_date(self):
        """Test for diff results by open reports date."""
        run_id = self._update_runid

        def get_run_tags(tag_name):
            run_history_filter = RunHistoryFilter(tagNames=[tag_name])
            return self._cc_client.getRunHistory([run_id], None, None,
                                                 run_history_filter)

        get_all_tags = get_run_tags('t*')
        self.assertEqual(len(get_all_tags), 3)

        base_tags = get_run_tags('t1')
        self.assertEqual(len(base_tags), 1)
        base_tag_time = str_to_date(base_tags[0].time) + timedelta(0, 1)
        base_tag_timestamp = int(base_tag_time.timestamp())

        new_tags = get_run_tags('t2')
        self.assertEqual(len(new_tags), 1)
        new_tag_time = str_to_date(new_tags[0].time) + timedelta(0, 1)
        new_tag_timestamp = int(new_tag_time.timestamp())

        tag_filter = ReportFilter(openReportsDate=base_tag_timestamp)
        cmp_data = CompareData(runIds=[run_id],
                               diffType=DiffType.NEW,
                               openReportsDate=new_tag_timestamp)

        diff_res = self._cc_client.getRunResults([run_id],
                                                 500,
                                                 0,
                                                 [],
                                                 tag_filter,
                                                 cmp_data,
                                                 False)

        # 5 new core.CallAndMessage issues.
        self.assertEqual(len(diff_res), 5)

        cmp_data.diffType = DiffType.RESOLVED
        diff_res = self._cc_client.getRunResults([run_id],
                                                 500,
                                                 0,
                                                 [],
                                                 tag_filter,
                                                 cmp_data,
                                                 False)
        self.assertEqual(len(diff_res), 3)

        cmp_data.diffType = DiffType.UNRESOLVED
        diff_res = self._cc_client.getRunResults([run_id],
                                                 500,
                                                 0,
                                                 [],
                                                 tag_filter,
                                                 cmp_data,
                                                 False)
        self.assertEqual(len(diff_res), 26)
Пример #2
0
    def test_diff_run_tags(self):
        """Test for diff runs by run tags."""
        run_id = self._update_runid

        def get_run_tags(tag_name):
            run_history_filter = RunHistoryFilter(tagNames=[tag_name])
            return self._cc_client.getRunHistory([run_id], None, None,
                                                 run_history_filter)

        get_all_tags = get_run_tags('t*')
        self.assertEqual(len(get_all_tags), 3)

        base_tags = get_run_tags('t1')
        self.assertEqual(len(base_tags), 1)
        base_tag_id = base_tags[0].id

        new_tags = get_run_tags('t2')
        self.assertEqual(len(new_tags), 1)
        new_tag_id = new_tags[0].id

        tag_filter = ReportFilter(runTag=[base_tag_id])
        cmp_data = CompareData(runIds=[run_id],
                               diffType=DiffType.NEW,
                               runTag=[new_tag_id])

        diff_res = self._cc_client.getRunResults([run_id],
                                                 500,
                                                 0,
                                                 [],
                                                 tag_filter,
                                                 cmp_data,
                                                 False)

        # 5 new core.CallAndMessage issues.
        self.assertEqual(len(diff_res), 5)

        cmp_data.diffType = DiffType.RESOLVED
        diff_res = self._cc_client.getRunResults([run_id],
                                                 500,
                                                 0,
                                                 [],
                                                 tag_filter,
                                                 cmp_data,
                                                 False)
        self.assertEqual(len(diff_res), 3)

        cmp_data.diffType = DiffType.UNRESOLVED
        diff_res = self._cc_client.getRunResults([run_id],
                                                 500,
                                                 0,
                                                 [],
                                                 tag_filter,
                                                 cmp_data,
                                                 False)
        self.assertEqual(len(diff_res), 26)
Пример #3
0
    def test_get_diff_res_count_unresolved(self):
        """
        Count the unresolved results with no filter.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        base_count = self._cc_client.getRunResultCount([base_run_id], None,
                                                       None)
        print("Base run id: %d", base_run_id)
        print("Base count: %d", base_count)

        base_run_res = get_all_run_results(self._cc_client, base_run_id)

        print_run_results(base_run_res)

        new_count = self._cc_client.getRunResultCount([new_run_id], None, None)
        print("New run id: %d", new_run_id)
        print("New count: %d", new_count)

        new_run_res = get_all_run_results(self._cc_client, new_run_id)

        print_run_results(new_run_res)

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        diff_res = self._cc_client.getRunResultCount([base_run_id], None,
                                                     cmp_data)

        self.assertEqual(diff_res, 25)
Пример #4
0
    def test_get_diff_res_types_unresolved(self):
        """
        Test diff result types for unresolved results with no filter
        on the api.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        diff_res = \
            self._cc_client.getCheckerCounts([base_run_id],
                                             None,
                                             cmp_data,
                                             None,
                                             0)
        diff_dict = dict((res.name, res.count) for res in diff_res)

        test_res = {
            'unix.Malloc': 1,
            'cplusplus.NewDelete': 5,
            'deadcode.DeadStores': 6,
            'core.StackAddressEscape': 3,
            'core.DivideZero': 10
        }
        self.assertDictEqual(diff_dict, test_res)
Пример #5
0
    def test_get_diff_res_types_unresolved_filter(self):
        """
        Test diff result types for unresolved results with filter.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        diff_res_types_filter = self._testproject_data[
            self._clang_to_test]['diff_res_types_filter']

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        for level in diff_res_types_filter:
            for checker_name, test_result_count in level.items():
                checker_filter = ReportFilter(checkerName=[checker_name])
                diff_res = \
                    self._cc_client.getCheckerCounts([base_run_id],
                                                     checker_filter,
                                                     cmp_data,
                                                     None,
                                                     0)
                diff_dict = dict((res.name, res.count) for res in diff_res)

                # There should be only one result for each checker name.
                self.assertEqual(test_result_count, diff_dict[checker_name])
Пример #6
0
    def test_get_diff_res_count_unresolved_filter(self):
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        filter_severity_levels = [{
            "MEDIUM": 1
        }, {
            "LOW": 6
        }, {
            "HIGH": 18
        }, {
            "STYLE": 0
        }, {
            "CRITICAL": 0
        }]

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        for level in filter_severity_levels:
            for severity_level, test_result_count in level.items():
                sev = get_severity_level(severity_level)
                sev_filter = ReportFilter(severity=[sev])

                diff_result_count = self._cc_client.getRunResultCount(
                    [base_run_id], sev_filter, cmp_data)

                self.assertEqual(test_result_count, diff_result_count)
Пример #7
0
    def test_get_diff_res_count_new_no_base(self):
        """
        Count the new results with no filter and no baseline
        run ids.
        """
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.NEW)

        diff_res = self._cc_client.getRunResultCount([], None, cmp_data)
        # No differences.
        self.assertEqual(diff_res, 0)
Пример #8
0
    def test_get_diff_severity_counts_all_new(self):
        """
        Test diff result types for all unresolved checker counts.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.NEW)

        sev_res = self._cc_client.getSeverityCounts([base_run_id], None,
                                                    cmp_data)
        test_res = {Severity.HIGH: 4}
        self.assertDictEqual(sev_res, test_res)
Пример #9
0
    def test_get_diff_results_unresolved(self):
        """
        Get the unresolved results with no filter.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        diff_res = self._cc_client.getRunResults([base_run_id], 500, 0, [],
                                                 None, cmp_data, False)
        self.assertEqual(len(diff_res), 25)
Пример #10
0
    def test_get_diff_results_new(self):
        """
        Get the new results with no filter.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.NEW)

        diff_res = self._cc_client.getRunResults([base_run_id], 500, 0, [],
                                                 None, cmp_data, False)
        # 4 new core.NullDereference issues.
        self.assertEqual(len(diff_res), 4)
Пример #11
0
    def test_get_diff_new_review_status_counts(self):
        """
        Test diff result types for all unresolved checker counts.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.NEW)

        res = self._cc_client.getReviewStatusCounts([base_run_id], None,
                                                    cmp_data)

        test_res = {ReviewStatus.UNREVIEWED: 4}
        self.assertDictEqual(res, test_res)
Пример #12
0
    def test_get_diff_res_types_resolved(self):
        """
        Test diff result types for resolved results.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.RESOLVED)

        diff_res = self._cc_client.getCheckerCounts([base_run_id], None,
                                                    cmp_data, None, 0)
        diff_dict = dict((res.name, res.count) for res in diff_res)

        test_res = {'core.CallAndMessage': 5}
        self.assertDictEqual(diff_dict, test_res)
Пример #13
0
    def test_get_diff_checker_counts(self):
        """
        Test diff result types for new results.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.NEW)

        diff_res = self._cc_client.getCheckerCounts([base_run_id], None,
                                                    cmp_data, None, 0)
        diff_dict = dict((res.name, res.count) for res in diff_res)

        # core.CallAndMessage is the new checker.
        test_res = {"core.NullDereference": 4}
        self.assertDictEqual(diff_dict, test_res)
Пример #14
0
    def test_get_diff_checker_counts_core_resolved(self):
        """
        Test diff result types for resolved core checker counts.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        report_filter = ReportFilter(checkerName=["*core*"])
        cmp_data = CompareData(runIds=[new_run_id], diffType=DiffType.RESOLVED)
        diff_res = self._cc_client.getCheckerCounts([base_run_id],
                                                    report_filter, cmp_data,
                                                    None, 0)
        diff_dict = dict((res.name, res.count) for res in diff_res)

        # Resolved core checkers.
        test_res = {'core.CallAndMessage': 5}
        self.assertDictEqual(diff_dict, test_res)
Пример #15
0
    def test_get_diff_severity_counts_all_unresolved(self):
        """
        Test diff result types for all unresolved checker counts.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        sev_res = self._cc_client.getSeverityCounts([base_run_id],
                                                    None,
                                                    cmp_data)
        test_res = {Severity.HIGH: 15,
                    Severity.LOW: 6,
                    Severity.MEDIUM: 1,
                    Severity.UNSPECIFIED: 3}
        self.assertDictEqual(sev_res, test_res)
Пример #16
0
    def test_get_diff_checker_counts_core_unresolved(self):
        """
        Test diff result types for resolved unix checker counts.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        report_filter = ReportFilter(checkerName=["*core*"])
        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)
        diff_res = self._cc_client.getCheckerCounts([base_run_id],
                                                    report_filter, cmp_data,
                                                    None, 0)
        diff_dict = dict((res.name, res.count) for res in diff_res)

        # Unresolved core checkers.
        test_res = {'core.StackAddressEscape': 3, 'core.DivideZero': 10}
        self.assertDictContainsSubset(test_res, diff_dict)
Пример #17
0
    def test_get_diff_checker_counts_all_unresolved(self):
        """
        Test diff result types for all unresolved checker counts.
        """
        base_run_id = self._base_runid
        new_run_id = self._new_runid

        cmp_data = CompareData(runIds=[new_run_id],
                               diffType=DiffType.UNRESOLVED)

        diff_res = self._cc_client.getCheckerCounts([base_run_id], None,
                                                    cmp_data, None, 0)
        diff_dict = dict((res.name, res.count) for res in diff_res)

        # All unresolved checkers.
        test_res = {
            'unix.Malloc': 1,
            'cplusplus.NewDelete': 5,
            'deadcode.DeadStores': 6,
            'core.StackAddressEscape': 3,
            'core.DivideZero': 10
        }
        self.assertDictContainsSubset(diff_dict, test_res)