brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.4 KiB · 9edb97e Raw
48 lines · python
1import os2import tempfile3import unittest4 5from lldbsuite.test.decorators import *6from lldbsuite.test.lldbtest import *7 8# To be safe and portable, Unix domain socket paths should be kept at or below9# 108 characters on Linux, and around 104 characters on macOS:10MAX_SOCKET_PATH_LENGTH = 10411 12 13class MCPUnixSocketCommandTestCase(TestBase):14    @skipIfWindows15    @skipIfRemote16    @no_debug_info_test17    def test_unix_socket(self):18        """19        Test if we can start an MCP protocol-server accepting unix sockets20        """21 22        temp_directory = tempfile.TemporaryDirectory()23        socket_file = os.path.join(temp_directory.name, "mcp.sock")24 25        if len(socket_file) >= MAX_SOCKET_PATH_LENGTH:26            self.skipTest(27                f"Socket path {socket_file} exceeds the {MAX_SOCKET_PATH_LENGTH} character limit"28            )29 30        self.expect(31            f"protocol-server start MCP accept://{socket_file}",32            startstr="MCP server started with connection listeners:",33            substrs=[f"unix-connect://{socket_file}"],34        )35 36        self.expect(37            "protocol-server get MCP",38            startstr="MCP server connection listeners:",39            substrs=[f"unix-connect://{socket_file}"],40        )41 42        self.runCmd("protocol-server stop MCP", check=False)43        self.expect(44            "protocol-server get MCP",45            error=True,46            substrs=["MCP server is not running"],47        )48