aboutsummaryrefslogtreecommitdiff
path: root/lldb/test/API/commands/protocol/TestMCPUnixSocket.py
blob: ea9255cc60ef59ade497538524ce9548055b2bbe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
import tempfile
import unittest

from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import *

# To be safe and portable, Unix domain socket paths should be kept at or below
# 108 characters on Linux, and around 104 characters on macOS:
MAX_SOCKET_PATH_LENGTH = 104


class MCPUnixSocketCommandTestCase(TestBase):
    @skipIfWindows
    @skipIfRemote
    @no_debug_info_test
    def test_unix_socket(self):
        """
        Test if we can start an MCP protocol-server accepting unix sockets
        """

        temp_directory = tempfile.TemporaryDirectory()
        socket_file = os.path.join(temp_directory.name, "mcp.sock")

        if len(socket_file) >= MAX_SOCKET_PATH_LENGTH:
            self.skipTest(
                f"Socket path {socket_file} exceeds the {MAX_SOCKET_PATH_LENGTH} character limit"
            )

        self.expect(
            f"protocol-server start MCP accept://{socket_file}",
            startstr="MCP server started with connection listeners:",
            substrs=[f"unix-connect://{socket_file}"],
        )