Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
3c5ce404
Commit
3c5ce404
authored
Sep 03, 2015
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
test_gdb: enhance regex used to parse the GDB version
parent
b50d3b2c
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
12 deletions
+31
-12
Lib/test/test_gdb.py
Lib/test/test_gdb.py
+31
-12
No files found.
Lib/test/test_gdb.py
View file @
3c5ce404
...
...
@@ -10,21 +10,36 @@ import sys
import
unittest
import
sysconfig
from
test
import
test_support
from
test.test_support
import
run_unittest
,
findfile
try
:
gdb_version
,
_
=
subprocess
.
Popen
([
"gdb"
,
"-nx"
,
"--version"
],
stdout
=
subprocess
.
PIPE
).
communicate
()
except
OSError
:
def
get_gdb_version
():
try
:
proc
=
subprocess
.
Popen
([
"gdb"
,
"-nx"
,
"--version"
],
stdout
=
subprocess
.
PIPE
,
universal_newlines
=
True
)
version
=
proc
.
communicate
()[
0
]
except
OSError
:
# This is what "no gdb" looks like. There may, however, be other
# errors that manifest this way too.
raise
unittest
.
SkipTest
(
"Couldn't find gdb on the path"
)
gdb_version_number
=
re
.
search
(
"^GNU gdb [^
\
d]*(
\
d+)
\
.(
\
d)"
,
gdb_version
)
gdb_major_version
=
int
(
gdb_version_number
.
group
(
1
))
gdb_minor_version
=
int
(
gdb_version_number
.
group
(
2
))
# Regex to parse:
# 'GNU gdb (GDB; SUSE Linux Enterprise 12) 7.7\n' -> 7.7
# 'GNU gdb (GDB) Fedora 7.9.1-17.fc22\n' -> 7.9
# 'GNU gdb 6.1.1 [FreeBSD]\n'
match
=
re
.
search
(
"^GNU gdb.*? (
\
d+)
\
.(
\
d)
"
, version)
if match is None:
raise Exception("
unable
to
parse
GDB
version
:
%
r" % version)
return (version, int(match.group(1)), int(match.group(2)))
gdb_version, gdb_major_version, gdb_minor_version = get_gdb_version()
if gdb_major_version < 7:
raise
unittest
.
SkipTest
(
"gdb versions before 7.0 didn't support python embedding"
" Saw:
\
n
"
+
gdb_version
)
raise unittest.SkipTest("
gdb
versions
before
7.0
didn
't support python "
"embedding. Saw %s.%s:
\
n
%s"
% (gdb_major_version, gdb_minor_version,
gdb_version))
if sys.platform.startswith("sunos"):
raise unittest.SkipTest("test doesn'
t
work
very
well
on
Solaris
")
...
...
@@ -781,6 +796,10 @@ class PyLocalsTests(DebuggerTests):
r".*\na = 1\nb = 2\nc = 3\n.*"
)
def
test_main
():
if
test_support
.
verbose
:
print
(
"GDB version %s.%s:"
%
(
gdb_major_version
,
gdb_minor_version
))
for
line
in
gdb_version
.
splitlines
():
print
(
" "
*
4
+
line
)
run_unittest
(
PrettyPrintTests
,
PyListTests
,
StackNavigationTests
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment