def test_get_run_results_sorted2(self):
        """ Get the results and sort them by filename and checkername. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))
        sortMode1 = SortMode(SortType.FILENAME, Order.ASC)
        sortMode2 = SortMode(SortType.CHECKER_NAME, Order.ASC)
        sort_types = [sortMode1, sortMode2]

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0,
                                                    sort_types, [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))

        for i in range(run_result_count - 1):
            bug1 = run_results[i]
            bug2 = run_results[i + 1]
            self.assertTrue(bug1.checkedFile <= bug2.checkedFile)
            self.assertTrue((bug1.checkedFile != bug2.checkedFile)
                            or (bug1.lastBugPosition.startLine <=
                                bug2.lastBugPosition.startLine)
                            or (bug1.checkerId <= bug2.checkerId))
    def test_get_diff_res_count_unresolved(self):
        """
        count the unresolved results with no filter
        """
        runs = self._cc_client.getRunData()
        self.assertIsNotNone(runs)
        self.assertNotEqual(len(runs), 0)
        self.assertGreaterEqual(len(runs), 2)

        base_run_id = runs[0].runId
        new_run_id = runs[1].runId

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

        base_run_res = self._cc_client.getAllRunResults(base_run_id, [], [])

        print_run_results(base_run_res)

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

        new_run_res = self._cc_client.getAllRunResults(new_run_id, [], [])

        print_run_results(new_run_res)

        diff_res = self._cc_client.getDiffResultCount(base_run_id, new_run_id,
                                                      DiffType.UNRESOLVED, [])
        self.assertEqual(diff_res, 23)
    def test_get_run_results_severity_sort(self):
        """ Get the results and sort them by severity and filename. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))
        sort_mode1 = SortMode(SortType.SEVERITY, Order.ASC)
        sort_mode2 = SortMode(SortType.FILENAME, Order.ASC)
        sort_types = [sort_mode1, sort_mode2]

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0,
                                                    sort_types, [])
        self.assertIsNotNone(run_results)

        for i in range(run_result_count - 1):
            bug1 = run_results[i]
            bug2 = run_results[i + 1]
            self.assertTrue(bug1.severity <= bug2.severity)
            self.assertTrue((bug1.severity != bug2.severity)
                            or (bug1.checkedFile <= bug2.checkedFile))

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))
    def test_get_run_results_severity_sort(self):
        """ Get the results and sort them by severity and filename. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))
        sort_mode1 = SortMode(SortType.SEVERITY, Order.ASC)
        sort_mode2 = SortMode(SortType.FILENAME, Order.ASC)
        sort_types = [sort_mode1, sort_mode2]

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count,
                                                    0, sort_types, [])
        self.assertIsNotNone(run_results)

        for i in range(run_result_count - 1):
            bug1 = run_results[i]
            bug2 = run_results[i + 1]
            self.assertTrue(bug1.severity <= bug2.severity)
            self.assertTrue((bug1.severity != bug2.severity) or
                            (bug1.checkedFile <= bug2.checkedFile))

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))
    def test_get_run_results_sorted2(self):
        """ Get the results and sort them by filename and checkername. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))
        sortMode1 = SortMode(SortType.FILENAME, Order.ASC)
        sortMode2 = SortMode(SortType.CHECKER_NAME, Order.ASC)
        sort_types = [sortMode1, sortMode2]

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0,
                                                    sort_types, [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))

        for i in range(run_result_count - 1):
            bug1 = run_results[i]
            bug2 = run_results[i + 1]
            self.assertTrue(bug1.checkedFile <= bug2.checkedFile)
            self.assertTrue((bug1.checkedFile != bug2.checkedFile) or
                            (bug1.lastBugPosition.startLine <=
                             bug2.lastBugPosition.startLine) or
                            (bug1.checkerId <= bug2.checkerId))
示例#6
0
    def test_get_run_results_checker_id_and_file_path(self):
        """ Test if all the bugs are found based
            on the test project configuration. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getAllRunResults(runid, [], [])
        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))

        found_all = True
        not_found = []
        for bug in self._testproject_data['bugs']:
            found = False
            for run_res in run_results:
                found |= ((run_res.checkedFile.endswith(bug['file'])) and
                          (run_res.lastBugPosition.startLine == bug['line'])
                          and (run_res.checkerId == bug['checker'])
                          and (run_res.bugHash == bug['hash']))
            found_all &= found
            if not found:
                not_found.append(bug)
        print_run_results(run_results)

        print('Not found bugs:')
        for bug in not_found:
            print(bug)

        self.assertTrue(found_all)
    def test_get_run_results_checker_id_and_file_path(self):
        """ Get all the run results and compare with the results
            in the project config. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count,
                                                    0, [], [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))

        not_found = find_all(run_results,
                             self._testproject_data['bugs'])
        if not_found:
            print('Not found bugs:')
            for bug in not_found:
                print(bug)

        self.assertTrue(len(not_found) == 0)
示例#8
0
    def test_get_run_results_checker_id_and_file_path(self):
        """ Get all the run results and compare with the results
            in the project config. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0,
                                                    [], [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))

        not_found = find_all(run_results, self._testproject_data['bugs'])
        if not_found:
            print('Not found bugs:')
            for bug in not_found:
                print(bug)

        self.assertTrue(len(not_found) == 0)
    def test_get_run_results_checker_id_and_file_path(self):
        """ Test if all the bugs are found based
            on the test project configuration. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))

        not_found = find_all(run_results,
                             self._testproject_data['bugs'])

        print_run_results(run_results)

        if not_found:
            print('Not found bugs:')
            for bug in not_found:
                print(bug)

        self.assertTrue(len(not_found) == 0)
    def test_get_diff_res_count_unresolved(self):
        """
        Count the unresolved results with no filter.
        """
        runs = self._cc_client.getRunData()
        self.assertIsNotNone(runs)
        self.assertNotEqual(len(runs), 0)
        self.assertGreaterEqual(len(runs), 2)

        base_run_id = runs[0].runId
        new_run_id = runs[1].runId

        base_count = self._cc_client.getRunResultCount(base_run_id, [])
        logging.debug("Base run id: %d", base_run_id)
        logging.debug("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, [])
        logging.debug("New run id: %d", new_run_id)
        logging.debug("New count: %d", new_count)

        new_run_res = get_all_run_results(self._cc_client, new_run_id)

        print_run_results(new_run_res)

        diff_res = self._cc_client.getDiffResultCount(base_run_id,
                                                      new_run_id,
                                                      DiffType.UNRESOLVED,
                                                      [])
        self.assertEqual(diff_res, 23)
    def test_get_run_results_checker_id_and_file_path(self):
        """ Get all the run results and compare with the results
            in the project config. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0,
                                                    [], [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))

        found_all = True
        for bug in self._testproject_data['bugs']:
            found = False
            for run_res in run_results:
                found |= (run_res.checkedFile.endswith(bug['file'])) and \
                         (run_res.lastBugPosition.startLine == bug['line']) and \
                         (run_res.checkerId == bug['checker']) and \
                         (run_res.bugHash == bug['hash'])
            found_all &= found

        self.assertTrue(found_all)
    def test_get_run_results_checker_id_and_file_path(self):
        """ Test if all the bugs are found based
            on the test project configuration. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))

        found_all = True
        not_found = []
        for bug in self._testproject_data['bugs']:
            found = False
            for run_res in run_results:
                found |= ((run_res.checkedFile.endswith(bug['file'])) and
                         (run_res.lastBugPosition.startLine == bug['line']) and
                         (run_res.checkerId == bug['checker']) and
                         (run_res.bugHash == bug['hash']))
            found_all &= found
            if not found:
                not_found.append(bug)
        print_run_results(run_results)

        print('Not found bugs:')
        for bug in not_found:
            print(bug)

        self.assertTrue(found_all)
    def test_get_run_results_checker_id_and_file_path(self):
        """ Get all the run results and compare with the results
            in the project config. """
        runid = self._runid
        logging.debug("Get all run results from the db for runid: " + str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0, [], [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))

        found_all = True
        for bug in self._testproject_data["bugs"]:
            found = False
            for run_res in run_results:
                found |= (
                    (run_res.checkedFile.endswith(bug["file"]))
                    and (run_res.lastBugPosition.startLine == bug["line"])
                    and (run_res.checkerId == bug["checker"])
                    and (run_res.bugHash == bug["hash"])
                )
            found_all &= found

        self.assertTrue(found_all)
    def test_get_run_results_no_filter(self):
        """ Get all the run results without any filtering. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' + str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getAllRunResults(runid, [], [])

        print_run_results(run_results)

        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))
    def test_get_run_results_no_filter(self):
        """ Get the run results without filtering just the
            result count is checked. """
        runid = self._runid
        logging.debug("Get all run results from the db for runid: " + str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = self._cc_client.getRunResults(runid, run_result_count, 0, [], [])
        self.assertIsNotNone(run_results)

        print_run_results(run_results)

        self.assertEqual(run_result_count, len(run_results))
    def test_get_run_results_checker_id_and_file_path(self):
        """ Test if all the bugs are found based
            on the test project configuration. """
        runid = self._runid
        logging.debug('Get all run results from the db for runid: ' +
                      str(runid))

        run_result_count = self._cc_client.getRunResultCount(runid, [])
        self.assertTrue(run_result_count)

        run_results = get_all_run_results(self._cc_client, runid)
        self.assertIsNotNone(run_results)
        self.assertEqual(run_result_count, len(run_results))

        not_found = find_all(run_results, self._testproject_data['bugs'])

        print_run_results(run_results)

        if not_found:
            print('Not found bugs:')
            for bug in not_found:
                print(bug)

        self.assertTrue(len(not_found) == 0)