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
acd0fda1
Commit
acd0fda1
authored
Oct 23, 2010
by
Antoine Pitrou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix SOCK_CLOEXEC and SOCK_NONBLOCK tests on recent glibcs with old Linux kernels.
parent
8035bc5c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
Lib/test/test_socket.py
Lib/test/test_socket.py
+18
-0
No files found.
Lib/test/test_socket.py
View file @
acd0fda1
...
...
@@ -13,6 +13,7 @@ import queue
import
sys
import
os
import
array
import
platform
import
contextlib
from
weakref
import
proxy
import
signal
...
...
@@ -1827,11 +1828,24 @@ class ContextManagersTest(ThreadedTCPSocketTest):
self
.
assertTrue
(
sock
.
_closed
)
self
.
assertRaises
(
socket
.
error
,
sock
.
sendall
,
b'foo'
)
def
linux_version
():
try
:
# platform.release() is something like '2.6.33.7-desktop-2mnb'
version_string
=
platform
.
release
().
split
(
'-'
)[
0
]
return
tuple
(
map
(
int
,
version_string
.
split
(
'.'
)))
except
ValueError
:
return
0
,
0
,
0
@
unittest
.
skipUnless
(
hasattr
(
socket
,
"SOCK_CLOEXEC"
),
"SOCK_CLOEXEC not defined"
)
@
unittest
.
skipUnless
(
fcntl
,
"module fcntl not available"
)
class
CloexecConstantTest
(
unittest
.
TestCase
):
def
test_SOCK_CLOEXEC
(
self
):
v
=
linux_version
()
if
v
<
(
2
,
6
,
28
):
self
.
skipTest
(
"Linux kernel 2.6.28 or higher required, not %s"
%
"."
.
join
(
map
(
str
,
v
)))
s
=
socket
.
socket
(
socket
.
AF_INET
,
socket
.
SOCK_STREAM
|
socket
.
SOCK_CLOEXEC
)
self
.
assertTrue
(
s
.
type
&
socket
.
SOCK_CLOEXEC
)
...
...
@@ -1850,6 +1864,10 @@ class NonblockConstantTest(unittest.TestCase):
self
.
assertEqual
(
s
.
gettimeout
(),
None
)
def
test_SOCK_NONBLOCK
(
self
):
v
=
linux_version
()
if
v
<
(
2
,
6
,
28
):
self
.
skipTest
(
"Linux kernel 2.6.28 or higher required, not %s"
%
"."
.
join
(
map
(
str
,
v
)))
# a lot of it seems silly and redundant, but I wanted to test that
# changing back and forth worked ok
s
=
socket
.
socket
(
socket
.
AF_INET
,
...
...
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