xref: /llvm-project/lldb/test/API/tools/lldb-server/inferior-crash/TestGdbRemoteAbort.py (revision 2238dcc39358353cac21df75c3c3286ab20b8f53)
1import gdbremote_testcase
2from lldbsuite.test.decorators import *
3from lldbsuite.test.lldbtest import *
4from lldbsuite.test import lldbutil
5
6
7class TestGdbRemoteAbort(gdbremote_testcase.GdbRemoteTestCaseBase):
8    @skipIfWindows  # No signal is sent on Windows.
9    # std::abort() on <= API 16 raises SIGSEGV - b.android.com/179836
10    @expectedFailureAndroid(api_levels=list(range(16 + 1)))
11    def test_inferior_abort_received_llgs(self):
12        self.build()
13
14        procs = self.prep_debug_monitor_and_inferior(inferior_args=["abort"])
15        self.assertIsNotNone(procs)
16
17        self.test_sequence.add_log_lines(
18            [
19                "read packet: $vCont;c#a8",
20                {
21                    "direction": "send",
22                    "regex": r"^\$T([0-9a-fA-F]{2}).*#[0-9a-fA-F]{2}$",
23                    "capture": {1: "hex_exit_code"},
24                },
25            ],
26            True,
27        )
28
29        context = self.expect_gdbremote_sequence()
30        self.assertIsNotNone(context)
31
32        hex_exit_code = context.get("hex_exit_code")
33        self.assertIsNotNone(hex_exit_code)
34        self.assertEqual(int(hex_exit_code, 16), lldbutil.get_signal_number("SIGABRT"))
35