8000
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent f3daf43 commit 711d800Copy full SHA for 711d800
Lib/test/test_socket.py
@@ -43,6 +43,7 @@
43
# test unicode string and carriage return
44
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
45
46
+VMADDR_CID_LOCAL = 1
47
VSOCKPORT = 1234
48
AIX = platform.system() == "AIX"
49
WSL = "microsoft-standard-WSL" in platform.release()
@@ -127,8 +128,8 @@ def _have_socket_qipcrtr():
127
128
129
def _have_socket_vsock():
130
"""Check whether AF_VSOCK sockets are supported on this host."""
- ret = get_cid() is not None
131
- return ret
+ cid = get_cid()
132
+ return (cid is not None)
133
134
135
def _have_socket_bluetooth():
@@ -471,8 +472,6 @@ def clientTearDown(self):
471
472
@unittest.skipIf(WSL, 'VSOCK does not work on Microsoft WSL')
473
@unittest.skipUnless(HAVE_SOCKET_VSOCK,
474
'VSOCK sockets required for this test.')
-@unittest.skipUnless(get_cid() != 2,
475
- "This test can only be run on a virtual guest.")
476
class ThreadedVSOCKSocketStreamTest(unittest.TestCase, ThreadableTest):
477
478
def __init__(self, methodName='runTest'):
@@ -494,6 +493,9 @@ def clientSetUp(self):
494
493
self.cli = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM)
495
self.addCleanup(self.cli.close)
496
cid = get_cid()
+ if cid in (socket.VMADDR_CID_HOST, socket.VMADDR_CID_ANY):
497
+ # gh-119461: Use the local communication address (loopback)
498
+ cid = VMADDR_CID_LOCAL
499
self.cli.connect((cid, VSOCKPORT))
500
501
def testStream(self):