Esempio n. 1
0
    def tear_down(self):
        if self.coverage_enabled:
            # Process coverage data with the same Python interpreter and
            # "coverage" package that was used to produce them. To achieve
            # this, spawn GDB just like testcases.
            gdb = GDBSession(log_file=os.path.join(self.coverage_dir,
                                                   'gdb.log'),
                             load_gnatdbg=False)
            gdb.import_coverage()
            gdb.execute('python import glob')

            # Consolidate coverage data for each testcase and generate both a
            # sumary textual report on the standard output and a detailed HTML
            # report.
            gdb.execute('''python
c = coverage.Coverage(data_file={data_file!r}, config_file={config_file!r})
c.combine(glob.glob({data_files_glob!r}))
c.html_report(directory={coverage_dir!r}, title='gnatdbg coverage report')
end'''.format(data_file=os.path.join(self.coverage_dir, '.coverage'),
              data_files_glob=os.path.join(self.coverage_dir, '*.coverage'),
              config_file=self.coverage_rcfile,
              coverage_dir=self.coverage_dir))

            html_index = os.path.join(self.coverage_dir, 'index.html')
            assert os.path.exists(html_index)
            print('Detailed HTML coverage report available at:'
                  ' {}'.format(html_index))

        super(Testsuite, self).tear_down()
Esempio n. 2
0
    def tear_down(self) -> None:
        ts_config: TestsuiteConfig = self.env.ts_config
        if ts_config.coverage:
            # Process coverage data with the same Python interpreter and
            # "coverage" package that was used to produce them. To achieve
            # this, spawn GDB just like testcases.
            gdb = GDBSession(log_file=os.path.join(ts_config.coverage_dir,
                                                   "gdb.log"),
                             load_gnatdbg=False)
            gdb.import_coverage()

            # Consolidate coverage data for each testcase and generate both a
            # sumary textual report on the standard output and a detailed HTML
            # report.
            script = os.path.join(self.working_dir, "coverage_script.py")
            with open(script, "w") as f:
                f.write("""
import glob

c = coverage.Coverage(data_file={data_file!r}, config_file={config_file!r})
c.combine(glob.glob({data_files_glob!r}))
c.html_report(directory={coverage_dir!r}, title="gnatdbg coverage report")
end""".format(data_file=os.path.join(ts_config.coverage_dir, ".coverage"),
                data_files_glob=os.path.join(ts_config.coverage_dir,
                                           "*.coverage"),
                config_file=ts_config.coverage_rcfile,
                coverage_dir=ts_config.coverage_dir))
            gdb.execute(f"source {script}")

            html_index = os.path.join(ts_config.coverage_dir, "index.html")
            assert os.path.exists(html_index)
            print("Detailed HTML coverage report available at:"
                  " {}".format(html_index))

        super().tear_down()
Esempio n. 3
0
from support.build import gnatmake
from support.gdb import GDBSession


gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('python import gnatdbg.debug')
gdb.execute('python gnatdbg.debug.PrintGDBTypeTreeCommand()')

gdb.test('dbgtype i', '%0 (integer : TYPE_CODE_INT) (4 bytes)')

gdb.test('dbgtype l', '%0 (foo.linked_list : TYPE_CODE_TYPEDEF):'
                      '  %1 (None : TYPE_CODE_PTR):'
                      '    %2 (foo.linked_list_record : TYPE_CODE_STRUCT):'
                      '      value: %3 (integer : TYPE_CODE_INT) (4 bytes)'
                      '      next: %0 (foo.linked_list : TYPE_CODE_TYPEDEF)')

gdb.test('dbgtype s', '%0 (foo__TsS : TYPE_CODE_ARRAY)[1 .. 13]:'
                      '  %1 (character : TYPE_CODE_CHAR)')
Esempio n. 4
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('set corrupted_string.reference := 0x1')

gdb.print_expr('empty_string', '""')
gdb.print_expr('some_string', '"Hello, world!"')
gdb.print_expr('binary_string', '"b["00"]""["ff"]"')
gdb.print_expr(
    'corrupted_string',
    '<error reading variable: Cannot access memory at address 0x1>')
Esempio n. 5
0
from support.build import gnatmake
from support.gdb import GDBSession

gnatmake('foo')
gdb = GDBSession('foo')
gdb.run_to(gdb.find_loc('foo.adb', 'BREAK'))

gdb.execute('set corrupted.value.c := 0x1')

gdb.print_expr('uninit', 'Big_Integer ([Uninitialized])')
gdb.print_expr('zero', 'Big_Integer (0)')
gdb.print_expr('neg_one', 'Big_Integer (-1)')
gdb.print_expr('neg_small', 'Big_Integer (-1000)')
gdb.print_expr('neg_big',
               'Big_Integer (-1234567890098765432112345678900987654321)')
gdb.print_expr('pos_one', 'Big_Integer (1)')
gdb.print_expr('pos_small', 'Big_Integer (1000)')
gdb.print_expr('pos_big',
               'Big_Integer (1234567890098765432112345678900987654321)')
gdb.print_expr('corrupted', 'Big_Integer ([Invalid])')