Ejemplo n.º 1
0
    def test(self):
        instance = os.path.join(self.aux_root, "three_paths.c")
        aa_file = os.path.join(self.aux_root, "aa_three_paths_inner_if_both_blocks.spc")
        specs_dir = os.path.join(self.aux_root, "cex_three_paths", "inner_both_blocks")
        with patch.object(self.logger, "info") as mock_info:
            c = generate_coverage.CollectFromExistingExecutions(
                instance=instance,
                cex_dir=specs_dir,
                heap_size=None,
                timelimit=None,
                logger=self.logger,
                aa_file=aa_file,
                start_time=self.start_time,
                timer=generate_coverage.Timer(),
            )
            lines_covered, lines_to_cover = c.collect_coverage()
            expected_calls = [
                call("Coverage after collecting 1 executions:"),
                call("Lines covered: 4"),
                call("Total lines to cover: 10"),
                call(""),
                call("Coverage after collecting 2 executions:"),
                call("Lines covered: 5"),
                call("Total lines to cover: 10"),
                call(""),
                call("Total lines covered: 5"),
                call("Total lines to cover: 10"),
            ]
            self.assertEqual(mock_info.mock_calls, expected_calls)

        self.assertEqual(lines_covered, {12, 13, 14, 15, 18})
        self.assertEqual(lines_to_cover, {12, 13, 14, 15, 16, 18, 19, 22, 23, 24})
    def test(self):
        instance = os.path.join(self.aux_root, 'three_paths.c')
        aa_file = os.path.join(self.aux_root,
                               'aa_three_paths_inner_if_both_blocks.spc')
        specs_dir = os.path.join(self.aux_root, 'cex_three_paths',
                                 'inner_both_blocks')
        with patch.object(self.logger, 'info') as mock_info:
            c = generate_coverage.CollectFromExistingExecutions(
                instance=instance,
                cex_dir=specs_dir,
                heap_size=None,
                timelimit=None,
                logger=self.logger,
                aa_file=aa_file,
                start_time=self.start_time,
                timer=generate_coverage.Timer())
            lines_covered, lines_to_cover = \
                c.collect_coverage()
            expected_calls = [
                call('Coverage after collecting 1 executions:'),
                call('Lines covered: 4'),
                call('Total lines to cover: 10'),
                call(''),
                call('Coverage after collecting 2 executions:'),
                call('Lines covered: 5'),
                call('Total lines to cover: 10'),
                call(''),
                call('Total lines covered: 5'),
                call('Total lines to cover: 10')
            ]
            self.assertEqual(mock_info.mock_calls, expected_calls)

        self.assertEqual(lines_covered, set([3, 4, 5, 6, 9]))
        self.assertEqual(lines_to_cover,
                         set([3, 4, 5, 6, 7, 9, 10, 13, 14, 15]))
Ejemplo n.º 3
0
    def test(self):
        instance = os.path.join(self.aux_root, "three_paths.c")
        aa_file = os.path.join(self.aux_root,
                               "aa_three_paths_else_return_not_covered.spc")
        specs_dir = os.path.join(self.aux_root, "cex_three_paths",
                                 "outer_else_block")

        with patch.object(self.logger, "info") as mock_info:
            c = generate_coverage.CollectFromExistingExecutions(
                instance=instance,
                cex_dir=specs_dir,
                heap_size=None,
                timelimit=None,
                logger=self.logger,
                aa_file=aa_file,
                start_time=self.start_time,
                timer=generate_coverage.Timer(),
            )
            lines_covered, lines_to_cover = c.collect_coverage()
            expected_calls = [
                call("Coverage after collecting 1 executions:"),
                call("Lines covered: 3"),
                call("Total lines to cover: 10"),
                call(""),
                call("Total lines covered: 3"),
                call("Total lines to cover: 10"),
            ]
            self.assertEqual(mock_info.mock_calls, expected_calls)

        self.assertEqual(lines_covered, set([3, 4, 13]))
        self.assertEqual(lines_to_cover,
                         set([3, 4, 5, 6, 7, 9, 10, 13, 14, 15]))
Ejemplo n.º 4
0
    def test(self):
        instance = os.path.join(self.aux_root, 'three_paths.c')
        aa_file = os.path.join(self.aux_root,
                               'aa_three_paths_else_return_not_covered.spc')
        specs_dir = os.path.join(self.aux_root, 'cex_three_paths',
                                 'outer_else_block')

        with patch.object(self.logger, 'info') as mock_info:
            self.logger.setLevel(logging.DEBUG)
            c = generate_coverage.CollectFromExistingExecutions(
                instance=instance,
                cex_dir=specs_dir,
                heap_size=None,
                timelimit=None,
                logger=self.logger,
                aa_file=aa_file,
                start_time=self.start_time)
            lines_covered, lines_to_cover = \
                c.collect_coverage()
            expected_calls = [
                call('Coverage after collecting 1 executions:'),
                call('Lines covered: 3'),
                call('Total lines to cover: 10'),
                call(''),
                call('Total lines covered: 3'),
                call('Total lines to cover: 10')
            ]
            self.assertEqual(mock_info.mock_calls, expected_calls)

        self.assertEqual(lines_covered, set([3, 4, 13]))
        self.assertEqual(lines_to_cover,
                         set([3, 4, 5, 6, 7, 9, 10, 13, 14, 15]))