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
a3c18d0f
Commit
a3c18d0f
authored
Sep 08, 2013
by
Victor Stinner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #18904: test_socket: add inheritance tests using fcntl and FD_CLOEXEC
parent
7ba6b0f9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
0 deletions
+30
-0
Lib/test/test_socket.py
Lib/test/test_socket.py
+30
-0
No files found.
Lib/test/test_socket.py
View file @
a3c18d0f
...
...
@@ -26,6 +26,10 @@ try:
import
multiprocessing
except
ImportError
:
multiprocessing
=
False
try
:
import
fcntl
except
ImportError
:
fcntl
=
None
HOST
=
support
.
HOST
MSG
=
'Michael Gilfix was here
\
u1234
\
r
\
n
'
.
encode
(
'utf-8'
)
## test unicode string and carriage return
...
...
@@ -4804,6 +4808,32 @@ class InheritanceTest(unittest.TestCase):
sock
.
set_inheritable
(
False
)
self
.
assertEqual
(
sock
.
get_inheritable
(),
False
)
if
fcntl
:
def
test_get_inheritable_cloexec
(
self
):
sock
=
socket
.
socket
()
with
sock
:
fd
=
sock
.
fileno
()
self
.
assertEqual
(
sock
.
get_inheritable
(),
False
)
# clear FD_CLOEXEC flag
flags
=
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
flags
&=
~
fcntl
.
FD_CLOEXEC
fcntl
.
fcntl
(
fd
,
fcntl
.
F_SETFD
,
flags
)
self
.
assertEqual
(
sock
.
get_inheritable
(),
True
)
def
test_set_inheritable_cloexec
(
self
):
sock
=
socket
.
socket
()
with
sock
:
fd
=
sock
.
fileno
()
self
.
assertEqual
(
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
&
fcntl
.
FD_CLOEXEC
,
fcntl
.
FD_CLOEXEC
)
sock
.
set_inheritable
(
True
)
self
.
assertEqual
(
fcntl
.
fcntl
(
fd
,
fcntl
.
F_GETFD
)
&
fcntl
.
FD_CLOEXEC
,
0
)
@
unittest
.
skipUnless
(
hasattr
(
socket
,
"socketpair"
),
"need socket.socketpair()"
)
def
test_socketpair
(
self
):
...
...
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