1 # lldb test suite imports
2 from lldbsuite
.test
.decorators
import *
3 from lldbsuite
.test
.lldbtest
import TestBase
5 # gdb-remote-specific imports
6 import lldbgdbserverutils
7 from gdbremote_testcase
import GdbRemoteTestCaseBase
10 class TestGdbRemoteHostInfo(GdbRemoteTestCaseBase
):
11 KNOWN_HOST_INFO_KEYS
= set(
17 "default_packet_timeout",
21 "maccatalyst_version",
30 "watchpoint_exceptions_received",
34 DARWIN_REQUIRED_HOST_INFO_KEYS
= set(
42 "watchpoint_exceptions_received",
46 def add_host_info_collection_packets(self
):
47 self
.test_sequence
.add_log_lines(
49 "read packet: $qHostInfo#9b",
52 "regex": r
"^\$(.+)#[0-9a-fA-F]{2}$",
53 "capture": {1: "host_info_raw"},
59 def parse_host_info_response(self
, context
):
60 # Ensure we have a host info response.
61 self
.assertIsNotNone(context
)
62 host_info_raw
= context
.get("host_info_raw")
63 self
.assertIsNotNone(host_info_raw
)
65 # Pull out key:value; pairs.
67 match
.group(1): match
.group(2)
68 for match
in re
.finditer(r
"([^:]+):([^;]+);", host_info_raw
)
73 print("\nqHostInfo response:")
74 pprint
.pprint(host_info_dict
)
76 # Validate keys are known.
77 for key
, val
in list(host_info_dict
.items()):
79 key
, self
.KNOWN_HOST_INFO_KEYS
, "unknown qHostInfo key: " + key
81 self
.assertIsNotNone(val
)
83 # Return the key:val pairs.
86 def get_qHostInfo_response(self
):
87 # Launch the debug monitor stub, attaching to the inferior.
88 server
= self
.connect_to_debug_monitor()
89 self
.assertIsNotNone(server
)
92 # Request qHostInfo and get response
93 self
.add_host_info_collection_packets()
94 context
= self
.expect_gdbremote_sequence()
95 self
.assertIsNotNone(context
)
97 # Parse qHostInfo response.
98 host_info
= self
.parse_host_info_response(context
)
99 self
.assertIsNotNone(host_info
)
103 "qHostInfo should have returned " "at least one key:val pair.",
107 def validate_darwin_minimum_host_info_keys(self
, host_info_dict
):
108 self
.assertIsNotNone(host_info_dict
)
111 for key
in self
.DARWIN_REQUIRED_HOST_INFO_KEYS
112 if key
not in host_info_dict
117 "qHostInfo is missing the following required " "keys: " + str(missing_keys
),
120 def test_qHostInfo_returns_at_least_one_key_val_pair(self
):
122 self
.get_qHostInfo_response()
125 def test_qHostInfo_contains_darwin_required_keys(self
):
127 host_info_dict
= self
.get_qHostInfo_response()
128 self
.validate_darwin_minimum_host_info_keys(host_info_dict
)