1 from __future__ import print_function
10 from lldbgdbserverutils import *
13 class TestLldbGdbServerUtils(unittest2.TestCase):
14 def test_entry_exact_payload_match(self):
15 entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")
16 entry.assert_match(self, "$OK#9a")
18 def test_entry_exact_payload_match_ignores_checksum(self):
19 entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")
20 entry.assert_match(self, "$OK#00")
22 def test_entry_creates_context(self):
23 entry = GdbRemoteEntry(is_send_to_remote=False, exact_payload="$OK#9a")
24 context = entry.assert_match(self, "$OK#9a")
25 self.assertIsNotNone(context)
27 def test_entry_regex_matches(self):
28 entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"), capture={ 1:"thread_id" })
29 context = entry.assert_match(self, "$QC980#00")
31 def test_entry_regex_saves_match(self):
32 entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$QC([0-9a-fA-F]+)#"), capture={ 1:"thread_id" })
33 context = entry.assert_match(self, "$QC980#00")
34 self.assertEqual(context["thread_id"], "980")
36 def test_entry_regex_expect_captures_success(self):
37 context = { "thread_id":"980" }
38 entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"), expect_captures={ 2:"thread_id" })
39 entry.assert_match(self, "$T11thread:980;", context=context)
41 def test_entry_regex_expect_captures_raises_on_fail(self):
42 context = { "thread_id":"980" }
43 entry = GdbRemoteEntry(is_send_to_remote=False, regex=re.compile(r"^\$T([0-9a-fA-F]{2})thread:([0-9a-fA-F]+)"), expect_captures={ 2:"thread_id" })
45 entry.assert_match(self, "$T11thread:970;", context=context)
47 except AssertionError: