Skip to content

Commit adcdb1e

Browse files
authored
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 e56a123)
1 parent c421c66 commit adcdb1e

2 files changed

Lines changed: 16 additions & 34 deletions

File tree

Lib/test/test_gdb.py

Lines changed: 13 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -215,43 +215,22 @@ def get_stack_trace(self, source=None, script=None,
215215
elif script:
216216
args += [script]
217217

218-
# print args
219-
# print ' '.join(args)
220-
221218
# Use "args" to invoke gdb, capturing stdout, stderr:
222219
out, err = run_gdb(*args, PYTHONHASHSEED='0')
223220

224-
errlines = err.splitlines()
225-
unexpected_errlines = []
226-
227-
# Ignore some benign messages on stderr.
228-
ignore_patterns = (
229-
'Function "%s" not defined.' % breakpoint,
230-
'Do you need "set solib-search-path" or '
231-
'"set sysroot"?',
232-
# BFD: /usr/lib/debug/(...): unable to initialize decompress
233-
# status for section .debug_aranges
234-
'BFD: ',
235-
# ignore all warnings
236-
'warning: ',
237-
)
238-
for line in errlines:
239-
if not line:
240-
continue
241-
# bpo34007: Sometimes some versions of the shared libraries that
242-
# are part of the traceback are compiled in optimised mode and the
243-
# Program Counter (PC) is not present, not allowing gdb to walk the
244-
# frames back. When this happens, the Python bindings of gdb raise
245-
# an exception, making the test impossible to succeed.
246-
if "PC not saved" in line:
247-
raise unittest.SkipTest("gdb cannot walk the frame object"
248-
" because the Program Counter is"
249-
" not present")
250-
if not line.startswith(ignore_patterns):
251-
unexpected_errlines.append(line)
252-
253-
# Ensure no unexpected error messages:
254-
self.assertEqual(unexpected_errlines, [])
221+
for line in err.splitlines():
222+
print >>sys.stderr, line
223+
224+
# bpo-34007: Sometimes some versions of the shared libraries that
225+
# are part of the traceback are compiled in optimised mode and the
226+
# Program Counter (PC) is not present, not allowing gdb to walk the
227+
# frames back. When this happens, the Python bindings of gdb raise
228+
# an exception, making the test impossible to succeed.
229+
if "PC not saved" in err:
230+
raise unittest.SkipTest("gdb cannot walk the frame object"
231+
" because the Program Counter is"
232+
" not present")
233+
255234
return out
256235

257236
def get_gdb_repr(self, source,
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
test_gdb no longer fails if it gets an "unexpected" message on stderr: it now
2+
ignores stderr. The purpose of test_gdb is to test that python-gdb.py commands
3+
work as expected, not to test gdb.

0 commit comments

Comments
 (0)