Commit adcdb1e4 authored by Victor Stinner's avatar Victor Stinner Committed by GitHub

bpo-37362: test_gdb now ignores stderr (GH-14287) (GH-14297)

test_gdb no longer fails if it gets an "unexpected" message on
stderr: it now ignores stderr. The purpose of test_gdb is to test
that python-gdb.py commands work as expected, not to test gdb.

(cherry picked from commit e56a123f)
parent c421c66a
...@@ -215,43 +215,22 @@ class DebuggerTests(unittest.TestCase): ...@@ -215,43 +215,22 @@ class DebuggerTests(unittest.TestCase):
elif script: elif script:
args += [script] args += [script]
# print args
# print ' '.join(args)
# Use "args" to invoke gdb, capturing stdout, stderr: # Use "args" to invoke gdb, capturing stdout, stderr:
out, err = run_gdb(*args, PYTHONHASHSEED='0') out, err = run_gdb(*args, PYTHONHASHSEED='0')
errlines = err.splitlines() for line in err.splitlines():
unexpected_errlines = [] print >>sys.stderr, line
# Ignore some benign messages on stderr. # bpo-34007: Sometimes some versions of the shared libraries that
ignore_patterns = ( # are part of the traceback are compiled in optimised mode and the
'Function "%s" not defined.' % breakpoint, # Program Counter (PC) is not present, not allowing gdb to walk the
'Do you need "set solib-search-path" or ' # frames back. When this happens, the Python bindings of gdb raise
'"set sysroot"?', # an exception, making the test impossible to succeed.
# BFD: /usr/lib/debug/(...): unable to initialize decompress if "PC not saved" in err:
# status for section .debug_aranges raise unittest.SkipTest("gdb cannot walk the frame object"
'BFD: ', " because the Program Counter is"
# ignore all warnings " not present")
'warning: ',
)
for line in errlines:
if not line:
continue
# bpo34007: Sometimes some versions of the shared libraries that
# are part of the traceback are compiled in optimised mode and the
# Program Counter (PC) is not present, not allowing gdb to walk the
# frames back. When this happens, the Python bindings of gdb raise
# an exception, making the test impossible to succeed.
if "PC not saved" in line:
raise unittest.SkipTest("gdb cannot walk the frame object"
" because the Program Counter is"
" not present")
if not line.startswith(ignore_patterns):
unexpected_errlines.append(line)
# Ensure no unexpected error messages:
self.assertEqual(unexpected_errlines, [])
return out return out
def get_gdb_repr(self, source, def get_gdb_repr(self, source,
......
test_gdb no longer fails if it gets an "unexpected" message on stderr: it now
ignores stderr. The purpose of test_gdb is to test that python-gdb.py commands
work as expected, not to test gdb.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment