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

gh-119461: Fix ThreadedVSOCKSocketStreamTest#119465

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
vstinner merged 1 commit intopython:mainfromvstinner:vsock_local
May 23, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletionsLib/test/test_socket.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -160,8 +160,8 @@ def _have_socket_qipcrtr():

def _have_socket_vsock():
"""Check whether AF_VSOCK sockets are supported on this host."""
ret = get_cid() is not None
returnret
cid = get_cid()
return(cid is not None)


def _have_socket_bluetooth():
Expand DownExpand Up@@ -520,8 +520,6 @@ def clientTearDown(self):
@unittest.skipIf(WSL, 'VSOCK does not work on Microsoft WSL')
@unittest.skipUnless(HAVE_SOCKET_VSOCK,
'VSOCK sockets required for this test.')
@unittest.skipUnless(get_cid() != 2,
"This test can only be run on a virtual guest.")
class ThreadedVSOCKSocketStreamTest(unittest.TestCase, ThreadableTest):

def __init__(self, methodName='runTest'):
Expand All@@ -543,6 +541,9 @@ def clientSetUp(self):
self.cli = socket.socket(socket.AF_VSOCK, socket.SOCK_STREAM)
self.addCleanup(self.cli.close)
cid = get_cid()
if cid in (socket.VMADDR_CID_HOST, socket.VMADDR_CID_ANY):
# gh-119461: Use the local communication address (loopback)
cid = socket.VMADDR_CID_LOCAL
self.cli.connect((cid, VSOCKPORT))

def testStream(self):
Expand DownExpand Up@@ -2515,6 +2516,7 @@ def testVSOCKConstants(self):
socket.SO_VM_SOCKETS_BUFFER_MAX_SIZE
socket.VMADDR_CID_ANY
socket.VMADDR_PORT_ANY
socket.VMADDR_CID_LOCAL
socket.VMADDR_CID_HOST
socket.VM_SOCKETS_INVALID_VERSION
socket.IOCTL_VM_SOCKETS_GET_LOCAL_CID
Expand Down
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
Add ``socket.VMADDR_CID_LOCAL`` constant. Patch by Victor Stinner.
1 change: 1 addition & 0 deletionsModules/socketmodule.c
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -7596,6 +7596,7 @@ socket_exec(PyObject *m)
ADD_INT_CONST(m, "SO_VM_SOCKETS_BUFFER_MAX_SIZE", 2);
ADD_INT_CONST(m, "VMADDR_CID_ANY", 0xffffffff);
ADD_INT_CONST(m, "VMADDR_PORT_ANY", 0xffffffff);
ADD_INT_CONST(m, "VMADDR_CID_LOCAL", 1);
ADD_INT_CONST(m, "VMADDR_CID_HOST", 2);
ADD_INT_CONST(m, "VM_SOCKETS_INVALID_VERSION", 0xffffffff);
ADD_INT_CONST(m, "IOCTL_VM_SOCKETS_GET_LOCAL_CID", _IO(7, 0xb9));
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp