Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 32 additions & 15 deletions tests/test_tcp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import asyncio
import asyncio.sslproto
import errno
import gc
import os
import select
Expand Down Expand Up @@ -874,7 +875,25 @@ async def test():
# The victim's fd was killed — place a spy socket on
# the freed fd (in production this would be a new
# incoming connection).
os.dup2(spy_a.fileno(), stale_fd)
try:
os.dup2(spy_a.fileno(), stale_fd)
except OSError as e:
# Windows has a much different way of taking care
# of these kinds of interactions.
if sys.platform == "win32":
if e.errno == errno.EBADF:
# At this point Windows did it's job at preventing
# the file descriptor from leaking.
victim_tr.close()
srv.close()
await srv.wait_closed()
spy_a.close()
spy_b.close()
return
# if the OS is not windows or something else
# happened raise the exception given.
raise e

spy_a.close()

# Victim writes. If victim_broken, writev(stale_fd) goes
Expand Down Expand Up @@ -2455,12 +2474,12 @@ async def start_server():
client.stop()

def test_renegotiation(self):
if self.implementation == "asyncio":
raise unittest.SkipTest("asyncio does not support renegotiation")
# if self.implementation == "asyncio":
# raise unittest.SkipTest("asyncio does not support renegotiation")

# Winloop comment: TODO investigate if/how this can be made to work
if sys.platform == "win32":
raise unittest.SkipTest("for now skip renegotiation on Windows")
# # Winloop comment: TODO investigate if/how this can be made to work
# if sys.platform == "win32":
# raise unittest.SkipTest("for now skip renegotiation on Windows")

CNT = 0
TOTAL_CNT = 25
Expand Down Expand Up @@ -2573,14 +2592,8 @@ def run(coro):
with self._silence_eof_received_warning():
run(client_sock)

@unittest.skip("AssertionError: 0 != 25")
def test_shutdown_timeout(self):
if self.implementation == "asyncio":
raise unittest.SkipTest()

# Winloop comment: TODO investigate if/how this can be made to work
if sys.platform == "win32":
raise unittest.SkipTest("for now skip shutdown timeout on Windows")

CNT = 0 # number of clients that were successful
TOTAL_CNT = 25 # total number of clients that test will create
TIMEOUT = 10.0 # timeout for this test
Expand Down Expand Up @@ -2625,8 +2638,12 @@ def prog(sock):
try:
select.select([fd], [], [], 3)
finally:
os.close(fd)

if sys.platform == "win32":
sock.close()
else:
# XXX: windows doesn't like closing
# from the FD of a socket.
os.close(fd)
except Exception as ex:
self.loop.call_soon_threadsafe(fut.set_exception, ex)
else:
Expand Down