Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit a3345bd

Browse filesBrowse files
miss-islingtonvstinner
authored andcommitted
00438: Fix ThreadedVSOCKSocketStreamTest (pythonGH-119465) (pythonGH-119479) (python#119484)
Fix ThreadedVSOCKSocketStreamTest: if get_cid() returns the host address or the "any" address, use the local communication address (loopback): VMADDR_CID_LOCAL. On Linux 6.9, apparently, the /dev/vsock device is now available but get_cid() returns VMADDR_CID_ANY (-1). (cherry picked from commit c750061) Co-authored-by: Victor Stinner <vstinner@python.org> (cherry picked from commit e94dbe4) Co-authored-by: Victor Stinner <vstinner@python.org>
1 parent 45e3ea3 commit a3345bd
Copy full SHA for a3345bd

File tree

1 file changed

+6
-4
lines changed
Filter options

1 file changed

+6
-4
lines changed

‎Lib/test/test_socket.py

Copy file name to clipboardExpand all lines: Lib/test/test_socket.py
+6-4Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
# test unicode string and carriage return
4242
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
4343

44+
VMADDR_CID_LOCAL = 1
4445
VSOCKPORT = 1234
4546
AIX = platform.system() == "AIX"
4647

@@ -124,8 +125,8 @@ def _have_socket_qipcrtr():
124125

125126
def _have_socket_vsock():
126127
"""Check whether AF_VSOCK sockets are supported on this host."""
127-
ret = get_cid() is not None
128-
return ret
128+
cid = get_cid()
129+
return (cid is not None)
129130

130131

131132
def _have_socket_bluetooth():
@@ -487,8 +488,6 @@ def clientTearDown(self):
487488
@unittest.skipIf(fcntl is None, "need fcntl")
488489
@unittest.skipUnless(HAVE_SOCKET_VSOCK,
489490
'VSOCK sockets required for this test.')
490-
@unittest.skipUnless(get_cid() != 2,
491-
"This test can only be run on a virtual guest.")
492491
class ThreadedVSOCKSocketStreamTest(unittest.TestCase, ThreadableTest):
493492

494493
def __init__(self, methodName='runTest'):
@@ -509,6 +508,9 @@ def clientSetUp(self):
509508
self.cli = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM)
510509
self.addCleanup(self.cli.close)
511510
cid = get_cid()
511+
if cid in (socket.VMADDR_CID_HOST, socket.VMADDR_CID_ANY):
512+
# gh-119461: Use the local communication address (loopback)
513+
cid = VMADDR_CID_LOCAL
512514
self.cli.connect((cid, VSOCKPORT))
513515

514516
def testStream(self):

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.