bpo-37362: test_gdb now ignores stderr (GH-14287)
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 e56a123fd0
)
Co-authored-by: Victor Stinner <vstinner@redhat.com>
This commit is contained in:
parent
f3e38ec7f0
commit
3523e0c47b
|
@ -214,43 +214,22 @@ class DebuggerTests(unittest.TestCase):
|
|||
elif script:
|
||||
args += [script]
|
||||
|
||||
# print args
|
||||
# print (' '.join(args))
|
||||
|
||||
# Use "args" to invoke gdb, capturing stdout, stderr:
|
||||
out, err = run_gdb(*args, PYTHONHASHSEED=PYTHONHASHSEED)
|
||||
|
||||
errlines = err.splitlines()
|
||||
unexpected_errlines = []
|
||||
for line in err.splitlines():
|
||||
print(line, file=sys.stderr)
|
||||
|
||||
# Ignore some benign messages on stderr.
|
||||
ignore_patterns = (
|
||||
'Function "%s" not defined.' % breakpoint,
|
||||
'Do you need "set solib-search-path" or '
|
||||
'"set sysroot"?',
|
||||
# BFD: /usr/lib/debug/(...): unable to initialize decompress
|
||||
# status for section .debug_aranges
|
||||
'BFD: ',
|
||||
# ignore all warnings
|
||||
'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)
|
||||
# bpo-34007: 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 err:
|
||||
raise unittest.SkipTest("gdb cannot walk the frame object"
|
||||
" because the Program Counter is"
|
||||
" not present")
|
||||
|
||||
# Ensure no unexpected error messages:
|
||||
self.assertEqual(unexpected_errlines, [])
|
||||
return out
|
||||
|
||||
def get_gdb_repr(self, source,
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
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.
|
Loading…
Reference in New Issue