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()
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()
from support.build import gnatmake from support.gdb import GDBSession gnatmake('foo') # Run gnatdbg.setup twice, check that the pretty-printers still work gdb = GDBSession('foo', log_file='gdb-double-setup.log', load_gnatdbg=True) gdb.run_to(gdb.find_loc('foo.adb', 'BREAK')) gdb.test('python gnatdbg.setup()', '') gdb.print_expr('empty_string', 'Unbounded_String ("")') gdb.stop() # Run gnatdbg.setup without registering pretty-printers globally gdb = GDBSession('foo', log_file='gdb-local.log', load_gnatdbg=False) gdb.run_to(gdb.find_loc('foo.adb', 'BREAK')) gdb.test('python import gnatdbg; gnatdbg.setup(globally=False)', '') gdb.print_expr('empty_string', 'Unbounded_String ("")') # Re-load and re-run foo, just to make sure the new_objfile event is run. gdb.kill() gdb.run_to(gdb.find_loc('foo.adb', 'BREAK')) gdb.print_expr('empty_string', 'Unbounded_String ("")')
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)')
from support.build import gnatmake from support.gdb import GDBSession gdb = GDBSession() def dm(label): return 'DiscriminantMatcher({})'.format(label) def error(field_name): return ("ValueError(Invalid GNAT encoding for discriminant matcher: {})" .format(repr(field_name))) tests = [ # Regular cases ('O', dm('others')), ('S1', dm('1')), ('S1R2T3', dm('1 | 2 .. 3')), ('S1S2S3', dm('1 | 2 | 3')), ('R1T100', dm('1 .. 100')), # Erroneous cases ('', error), ('a', error), ('S', error), ('Sa', error), ('R', error), ('Ra', error),
from support.build import gnatmake from support.gdb import GDBSession gnatmake('main') gdb = GDBSession('main') gdb.run_to(gdb.find_loc('main.adb', 'break here')) gdb.test('source custom.py', '') gdb.print_expr( 'v', '(t => time, vec => main.time_vectors.vector of length 1 = {time})')