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 e5fb458

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 128192c commit e5fb458
Copy full SHA for e5fb458

File tree

Expand file treeCollapse file tree

1 file changed

+6
-4
lines changed
Filter options
Expand file treeCollapse file tree

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
@@ -39,6 +39,7 @@
3939
# test unicode string and carriage return
4040
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
4141

42+
VMADDR_CID_LOCAL = 1
4243
VSOCKPORT = 1234
4344
AIX = platform.system() == "AIX"
4445

@@ -122,8 +123,8 @@ def _have_socket_qipcrtr():
122123

123124
def _have_socket_vsock():
124125
"""Check whether AF_VSOCK sockets are supported on this host."""
125-
ret = get_cid() is not None
126-
return ret
126+
cid = get_cid()
127+
return (cid is not None)
127128

128129

129130
def _have_socket_bluetooth():
@@ -485,8 +486,6 @@ def clientTearDown(self):
485486
@unittest.skipIf(fcntl is None, "need fcntl")
486487
@unittest.skipUnless(HAVE_SOCKET_VSOCK,
487488
'VSOCK sockets required for this test.')
488-
@unittest.skipUnless(get_cid() != 2,
489-
"This test can only be run on a virtual guest.")
490489
class ThreadedVSOCKSocketStreamTest(unittest.TestCase, ThreadableTest):
491490

492491
def __init__(self, methodName='runTest'):
@@ -507,6 +506,9 @@ def clientSetUp(self):
507506
self.cli = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM)
508507
self.addCleanup(self.cli.close)
509508
cid = get_cid()
509+
if cid in (socket.VMADDR_CID_HOST, socket.VMADDR_CID_ANY):
510+
# gh-119461: Use the local communication address (loopback)
511+
cid = VMADDR_CID_LOCAL
510512
self.cli.connect((cid, VSOCKPORT))
511513

512514
def testStream(self):

0 commit comments

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