Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit45db419

Browse files
authored
[3.11]gh-119461: Fix ThreadedVSOCKSocketStreamTest (#129171)
Fix ThreadedVSOCKSocketStreamTest: if get_cid() returns the hostaddress 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 butget_cid() returns VMADDR_CID_ANY (-1).(cherry picked from commite94dbe4)(cherry picked from commitc750061)(cherry picked from commitcbfe302)
1 parent49edb99 commit45db419

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

‎Lib/test/test_socket.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
# test unicode string and carriage return
4444
MSG='Michael Gilfix was here\u1234\r\n'.encode('utf-8')
4545

46+
VMADDR_CID_LOCAL=1
4647
VSOCKPORT=1234
4748
AIX=platform.system()=="AIX"
4849
WSL="microsoft-standard-WSL"inplatform.release()
@@ -127,8 +128,8 @@ def _have_socket_qipcrtr():
127128

128129
def_have_socket_vsock():
129130
"""Check whether AF_VSOCK sockets are supported on this host."""
130-
ret=get_cid()isnotNone
131-
returnret
131+
cid=get_cid()
132+
return(cidisnotNone)
132133

133134

134135
def_have_socket_bluetooth():
@@ -471,8 +472,6 @@ def clientTearDown(self):
471472
@unittest.skipIf(WSL,'VSOCK does not work on Microsoft WSL')
472473
@unittest.skipUnless(HAVE_SOCKET_VSOCK,
473474
'VSOCK sockets required for this test.')
474-
@unittest.skipUnless(get_cid()!=2,
475-
"This test can only be run on a virtual guest.")
476475
classThreadedVSOCKSocketStreamTest(unittest.TestCase,ThreadableTest):
477476

478477
def__init__(self,methodName='runTest'):
@@ -494,10 +493,16 @@ def clientSetUp(self):
494493
self.cli=socket.socket(socket.AF_VSOCK,socket.SOCK_STREAM)
495494
self.addCleanup(self.cli.close)
496495
cid=get_cid()
496+
ifcidin (socket.VMADDR_CID_HOST,socket.VMADDR_CID_ANY):
497+
# gh-119461: Use the local communication address (loopback)
498+
cid=VMADDR_CID_LOCAL
497499
self.cli.connect((cid,VSOCKPORT))
498500

499501
deftestStream(self):
500-
msg=self.conn.recv(1024)
502+
try:
503+
msg=self.conn.recv(1024)
504+
exceptPermissionErrorasexc:
505+
self.skipTest(repr(exc))
501506
self.assertEqual(msg,MSG)
502507

503508
def_testStream(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp