]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/tools/lldb-server/test/test_lldbgdbserverutils.py
Vendor import of lldb trunk r256945:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / tools / lldb-server / test / test_lldbgdbserverutils.py
1 from __future__ import print_function
2
3
4
5 import unittest2
6 import os.path
7 import re
8 import sys
9
10 from lldbgdbserverutils import *
11
12
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")
17
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")
21
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)
26
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")
30
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")
35
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)
40
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" })
44         try:
45             entry.assert_match(self, "$T11thread:970;", context=context)
46             self.fail()
47         except AssertionError:
48             # okay
49             return None