]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py
Vendor import of lldb trunk r290819:
[FreeBSD/FreeBSD.git] / packages / Python / lldbsuite / test / python_api / signals / TestSignalsAPI.py
1 """
2 Test SBProcess APIs, including ReadMemory(), WriteMemory(), and others.
3 """
4
5 from __future__ import print_function
6
7
8 import os
9 import time
10 import lldb
11 from lldbsuite.test.decorators import *
12 from lldbsuite.test.lldbtest import *
13 from lldbsuite.test import lldbutil
14 from lldbsuite.test.lldbutil import get_stopped_thread, state_type_to_str
15
16
17 class SignalsAPITestCase(TestBase):
18     mydir = TestBase.compute_mydir(__file__)
19
20     @add_test_categories(['pyapi'])
21     @skipIfWindows  # Windows doesn't have signals
22     def test_ignore_signal(self):
23         """Test Python SBUnixSignals.Suppress/Stop/Notify() API."""
24         self.build()
25         exe = os.path.join(os.getcwd(), "a.out")
26         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
27
28         target = self.dbg.CreateTarget(exe)
29         self.assertTrue(target, VALID_TARGET)
30
31         line = line_number(
32             "main.cpp",
33             "// Set break point at this line and setup signal ignores.")
34         breakpoint = target.BreakpointCreateByLocation("main.cpp", line)
35         self.assertTrue(breakpoint, VALID_BREAKPOINT)
36
37         # Launch the process, and do not stop at the entry point.
38         process = target.LaunchSimple(
39             None, None, self.get_process_working_directory())
40
41         thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
42         self.assertTrue(
43             thread.IsValid(),
44             "There should be a thread stopped due to breakpoint")
45
46         unix_signals = process.GetUnixSignals()
47         sigint = unix_signals.GetSignalNumberFromName("SIGINT")
48         unix_signals.SetShouldSuppress(sigint, True)
49         unix_signals.SetShouldStop(sigint, False)
50         unix_signals.SetShouldNotify(sigint, False)
51
52         process.Continue()
53         self.assertTrue(
54             process.state == lldb.eStateExited,
55             "The process should have exited")
56         self.assertTrue(
57             process.GetExitStatus() == 0,
58             "The process should have returned 0")