• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2
3import gdbremote_testcase
4import lldbgdbserverutils
5from lldbsuite.test.decorators import *
6from lldbsuite.test.lldbtest import *
7from lldbsuite.test import lldbutil
8
9
10class TestGdbRemoteKill(gdbremote_testcase.GdbRemoteTestCaseBase):
11
12    mydir = TestBase.compute_mydir(__file__)
13    @skipIfDarwinEmbedded # <rdar://problem/34539270> lldb-server tests not updated to work on ios etc yet
14
15    def attach_commandline_kill_after_initial_stop(self):
16        reg_expr = r"^\$[XW][0-9a-fA-F]+([^#]*)#[0-9A-Fa-f]{2}"
17        procs = self.prep_debug_monitor_and_inferior()
18        self.test_sequence.add_log_lines([
19            "read packet: $k#6b",
20            {"direction": "send", "regex": reg_expr},
21        ], True)
22
23        if self.stub_sends_two_stop_notifications_on_kill:
24            # Add an expectation for a second X result for stubs that send two
25            # of these.
26            self.test_sequence.add_log_lines([
27                {"direction": "send", "regex": reg_expr},
28            ], True)
29
30        self.expect_gdbremote_sequence()
31
32        # Wait a moment for completed and now-detached inferior process to
33        # clear.
34        time.sleep(self.DEFAULT_SLEEP)
35
36        if not lldb.remote_platform:
37            # Process should be dead now. Reap results.
38            poll_result = procs["inferior"].poll()
39            self.assertIsNotNone(poll_result)
40
41        # Where possible, verify at the system level that the process is not
42        # running.
43        self.assertFalse(
44            lldbgdbserverutils.process_is_running(
45                procs["inferior"].pid, False))
46
47    @debugserver_test
48    def test_attach_commandline_kill_after_initial_stop_debugserver(self):
49        self.init_debugserver_test()
50        self.build()
51        self.set_inferior_startup_attach()
52        self.attach_commandline_kill_after_initial_stop()
53
54    @llgs_test
55    def test_attach_commandline_kill_after_initial_stop_llgs(self):
56        self.init_llgs_test()
57        self.build()
58        self.set_inferior_startup_attach()
59        self.attach_commandline_kill_after_initial_stop()
60