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 d98d6b1 commit c750061Copy full SHA for c750061
Lib/test/test_socket.py
@@ -47,6 +47,7 @@
47
# test unicode string and carriage return
48
MSG = 'Michael Gilfix was here\u1234\r\n'.encode('utf-8')
49
50
+VMADDR_CID_LOCAL = 1
51
VSOCKPORT = 1234
52
AIX = platform.system() == "AIX"
53
WSL = "microsoft-standard-WSL" in platform.release()
@@ -160,8 +161,8 @@ def _have_socket_qipcrtr():
160
161
162
def _have_socket_vsock():
163
"""Check whether AF_VSOCK sockets are supported on this host."""
- ret = get_cid() is not None
164
- return ret
+ cid = get_cid()
165
+ return (cid is not None)
166
167
168
def _have_socket_bluetooth():
@@ -520,8 +521,6 @@ def clientTearDown(self):
520
521
@unittest.skipIf(WSL, 'VSOCK does not work on Microsoft WSL')
522
@unittest.skipUnless(HAVE_SOCKET_VSOCK,
523
'VSOCK sockets required for this test.')
-@unittest.skipUnless(get_cid() != 2,
524
- "This test can only be run on a virtual guest.")
525
class ThreadedVSOCKSocketStreamTest(unittest.TestCase, ThreadableTest):
526
527
def __init__(self, methodName='runTest'):
@@ -543,6 +542,9 @@ def clientSetUp(self):
543
542
self.cli = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM)
544
self.addCleanup(self.cli.close)
545
cid = get_cid()
+ if cid in (socket.VMADDR_CID_HOST, socket.VMADDR_CID_ANY):
546
+ # gh-119461: Use the local communication address (loopback)
547
+ cid = VMADDR_CID_LOCAL
548
self.cli.connect((cid, VSOCKPORT))
549
550
def testStream(self):