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

Commitd80cbdd

Browse files
miss-islingtonvstinnergpsheadencukou
authored
[3.9]gh-119461: Fix ThreadedVSOCKSocketStreamTest (GH-129171) (GH-129440) (#130075)
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 commit45db419)(cherry picked from commite94dbe4)(cherry picked from commitc750061)(cherry picked from commitcbfe302)---Restore the skipUnless removed byGH-119465.This test can only pass on virtual machines, not actual machines.Actual machines see:``` self.cli.connect((cid, VSOCKPORT)) ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^OSError: [Errno 19] No such device```Reproduced on (Linux) Ubuntu 24.04.1 running 6.8.0-52-generic.(cherry picked from commit2bd9f9b)Co-authored-by: Victor Stinner <vstinner@python.org>Co-authored-by: Gregory P. Smith <greg@krypto.org>Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent8a417ed commitd80cbdd

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

‎Lib/test/test_socket.py

Lines changed: 12 additions & 5 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()isnotNone
126-
returnret
126+
cid=get_cid()
127+
return(cidisnotNone)
127128

128129

129130
def_have_socket_bluetooth():
@@ -485,8 +486,8 @@ def clientTearDown(self):
485486
@unittest.skipIf(fcntlisNone,"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.")
489+
@unittest.skipUnless(get_cid()!=2,# VMADDR_CID_HOST
490+
"This test can only be run on a virtual guest.")
490491
classThreadedVSOCKSocketStreamTest(unittest.TestCase,ThreadableTest):
491492

492493
def__init__(self,methodName='runTest'):
@@ -507,10 +508,16 @@ def clientSetUp(self):
507508
self.cli=socket.socket(socket.AF_VSOCK,socket.SOCK_STREAM)
508509
self.addCleanup(self.cli.close)
509510
cid=get_cid()
511+
ifcidin (socket.VMADDR_CID_HOST,socket.VMADDR_CID_ANY):
512+
# gh-119461: Use the local communication address (loopback)
513+
cid=VMADDR_CID_LOCAL
510514
self.cli.connect((cid,VSOCKPORT))
511515

512516
deftestStream(self):
513-
msg=self.conn.recv(1024)
517+
try:
518+
msg=self.conn.recv(1024)
519+
exceptPermissionErrorasexc:
520+
self.skipTest(repr(exc))
514521
self.assertEqual(msg,MSG)
515522

516523
def_testStream(self):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp