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
e88ed050
Commit
e88ed050
authored
Dec 14, 2016
by
Xavier de Gaye
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #28683: Fix the tests that bind() a unix socket and raise PermissionError
on Android for a non-root user.
parent
1351c31a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
8 deletions
+33
-8
Lib/test/support/__init__.py
Lib/test/support/__init__.py
+10
-0
Lib/test/test_asyncore.py
Lib/test/test_asyncore.py
+3
-1
Lib/test/test_pathlib.py
Lib/test/test_pathlib.py
+2
-1
Lib/test/test_socket.py
Lib/test/test_socket.py
+15
-6
Misc/NEWS
Misc/NEWS
+3
-0
No files found.
Lib/test/support/__init__.py
View file @
e88ed050
...
...
@@ -96,6 +96,7 @@ __all__ = [
"setswitchinterval"
,
"android_not_root"
,
# network
"HOST"
,
"IPV6_ENABLED"
,
"find_unused_port"
,
"bind_port"
,
"open_urlresource"
,
"bind_unix_socket"
,
# processes
'temp_umask'
,
"reap_children"
,
# logging
...
...
@@ -708,6 +709,15 @@ def bind_port(sock, host=HOST):
port
=
sock
.
getsockname
()[
1
]
return
port
def
bind_unix_socket
(
sock
,
addr
):
"""Bind a unix socket, raising SkipTest if PermissionError is raised."""
assert
sock
.
family
==
socket
.
AF_UNIX
try
:
sock
.
bind
(
addr
)
except
PermissionError
:
sock
.
close
()
raise
unittest
.
SkipTest
(
'cannot bind AF_UNIX sockets'
)
def
_is_ipv6_enabled
():
"""Check whether IPv6 is enabled on this host."""
if
socket
.
has_ipv6
:
...
...
Lib/test/test_asyncore.py
View file @
e88ed050
...
...
@@ -95,7 +95,9 @@ def bind_af_aware(sock, addr):
if
HAS_UNIX_SOCKETS
and
sock
.
family
==
socket
.
AF_UNIX
:
# Make sure the path doesn't exist.
support
.
unlink
(
addr
)
sock
.
bind
(
addr
)
support
.
bind_unix_socket
(
sock
,
addr
)
else
:
sock
.
bind
(
addr
)
class
HelperFunctionTests
(
unittest
.
TestCase
):
...
...
Lib/test/test_pathlib.py
View file @
e88ed050
...
...
@@ -1888,7 +1888,8 @@ class _BasePathTest(object):
try
:
sock
.
bind
(
str
(
P
))
except
OSError
as
e
:
if
"AF_UNIX path too long"
in
str
(
e
):
if
(
isinstance
(
e
,
PermissionError
)
or
"AF_UNIX path too long"
in
str
(
e
)):
self
.
skipTest
(
"cannot bind Unix socket: "
+
str
(
e
))
self
.
assertTrue
(
P
.
is_socket
())
self
.
assertFalse
(
P
.
is_fifo
())
...
...
Lib/test/test_socket.py
View file @
e88ed050
...
...
@@ -278,8 +278,14 @@ class ThreadableTest:
def
clientRun
(
self
,
test_func
):
self
.
server_ready
.
wait
()
self
.
clientSetUp
()
self
.
client_ready
.
set
()
try
:
self
.
clientSetUp
()
except
BaseException
as
e
:
self
.
queue
.
put
(
e
)
self
.
clientTearDown
()
return
finally
:
self
.
client_ready
.
set
()
if
self
.
server_crashed
:
self
.
clientTearDown
()
return
...
...
@@ -520,8 +526,11 @@ class ConnectedStreamTestMixin(SocketListeningTestMixin,
self
.
serv_conn
=
self
.
cli
def
clientTearDown
(
self
):
self
.
serv_conn
.
close
()
self
.
serv_conn
=
None
try
:
self
.
serv_conn
.
close
()
self
.
serv_conn
=
None
except
AttributeError
:
pass
super
().
clientTearDown
()
...
...
@@ -540,7 +549,7 @@ class UnixSocketTestBase(SocketTestBase):
def
bindSock
(
self
,
sock
):
path
=
tempfile
.
mktemp
(
dir
=
self
.
dir_path
)
s
ock
.
bind
(
path
)
s
upport
.
bind_unix_socket
(
sock
,
path
)
self
.
addCleanup
(
support
.
unlink
,
path
)
class
UnixStreamBase
(
UnixSocketTestBase
):
...
...
@@ -4631,7 +4640,7 @@ class TestUnixDomain(unittest.TestCase):
def
bind
(
self
,
sock
,
path
):
# Bind the socket
try
:
s
ock
.
bind
(
path
)
s
upport
.
bind_unix_socket
(
sock
,
path
)
except
OSError
as
e
:
if
str
(
e
)
==
"AF_UNIX path too long"
:
self
.
skipTest
(
...
...
Misc/NEWS
View file @
e88ed050
...
...
@@ -47,6 +47,9 @@ Windows
Tests
-----
- Issue #28683: Fix the tests that bind() a unix socket and raise
PermissionError on Android for a non-root user.
- Issue #26939: Add the support.setswitchinterval() function to fix
test_functools hanging on the Android armv7 qemu emulator.
...
...
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