File: TestGdbRemoteExitCode.py

package info (click to toggle)
llvm-toolchain-11 1%3A11.0.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 995,808 kB
  • sloc: cpp: 4,767,656; ansic: 760,916; asm: 477,436; python: 170,940; objc: 69,804; lisp: 29,914; sh: 23,855; f90: 18,173; pascal: 7,551; perl: 7,471; ml: 5,603; awk: 3,489; makefile: 2,573; xml: 915; cs: 573; fortran: 503; javascript: 452
file content (126 lines) | stat: -rw-r--r-- 4,022 bytes parent folder | download | duplicates (2)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126

# lldb test suite imports
from lldbsuite.test.decorators import *
from lldbsuite.test.lldbtest import TestBase

# gdb-remote-specific imports
import lldbgdbserverutils
from gdbremote_testcase import GdbRemoteTestCaseBase


class TestGdbRemoteExitCode(GdbRemoteTestCaseBase):

    mydir = TestBase.compute_mydir(__file__)

    FAILED_LAUNCH_CODE = "E08"

    def get_launch_fail_reason(self):
        self.reset_test_sequence()
        self.test_sequence.add_log_lines(
            ["read packet: $qLaunchSuccess#00"],
            True)
        self.test_sequence.add_log_lines(
            [{"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
              "capture": {1: "launch_result"}}],
            True)
        context = self.expect_gdbremote_sequence()
        self.assertIsNotNone(context)
        return context.get("launch_result")[1:]

    def start_inferior(self):
        launch_args = self.install_and_create_launch_args()

        server = self.connect_to_debug_monitor()
        self.assertIsNotNone(server)

        self.add_no_ack_remote_stream()
        self.test_sequence.add_log_lines(
            ["read packet: %s" % lldbgdbserverutils.build_gdbremote_A_packet(
                launch_args)],
            True)
        self.test_sequence.add_log_lines(
            [{"direction": "send", "regex": r"^\$(.+)#[0-9a-fA-F]{2}$",
              "capture": {1: "A_result"}}],
            True)
        context = self.expect_gdbremote_sequence()
        self.assertIsNotNone(context)

        launch_result = context.get("A_result")
        self.assertIsNotNone(launch_result)
        if launch_result == self.FAILED_LAUNCH_CODE:
            fail_reason = self.get_launch_fail_reason()
            self.fail("failed to launch inferior: " + fail_reason)

    @debugserver_test
    @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
    def test_start_inferior_debugserver(self):
        self.init_debugserver_test()
        self.build()
        self.start_inferior()

    @llgs_test
    def test_start_inferior_llgs(self):
        self.init_llgs_test()
        self.build()
        self.start_inferior()

    def inferior_exit_0(self):
        launch_args = self.install_and_create_launch_args()

        server = self.connect_to_debug_monitor()
        self.assertIsNotNone(server)

        self.add_no_ack_remote_stream()
        self.add_verified_launch_packets(launch_args)
        self.test_sequence.add_log_lines(
            ["read packet: $vCont;c#a8",
             "send packet: $W00#00"],
            True)

        self.expect_gdbremote_sequence()

    @debugserver_test
    @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
    def test_inferior_exit_0_debugserver(self):
        self.init_debugserver_test()
        self.build()
        self.inferior_exit_0()

    @llgs_test
    def test_inferior_exit_0_llgs(self):
        self.init_llgs_test()
        self.build()
        self.inferior_exit_0()

    def inferior_exit_42(self):
        launch_args = self.install_and_create_launch_args()

        server = self.connect_to_debug_monitor()
        self.assertIsNotNone(server)

        RETVAL = 42

        # build launch args
        launch_args += ["retval:%d" % RETVAL]

        self.add_no_ack_remote_stream()
        self.add_verified_launch_packets(launch_args)
        self.test_sequence.add_log_lines(
            ["read packet: $vCont;c#a8",
             "send packet: $W{0:02x}#00".format(RETVAL)],
            True)

        self.expect_gdbremote_sequence()

    @debugserver_test
    @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
    def test_inferior_exit_42_debugserver(self):
        self.init_debugserver_test()
        self.build()
        self.inferior_exit_42()

    @llgs_test
    def test_inferior_exit_42_llgs(self):
        self.init_llgs_test()
        self.build()
        self.inferior_exit_42()