]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py
Vendor import of lldb release_39 branch r276489:
[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
9 import os, 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 class SignalsAPITestCase(TestBase):
17     mydir = TestBase.compute_mydir(__file__)
18
19     @add_test_categories(['pyapi'])
20     @skipIfWindows # Windows doesn't have signals
21     def test_ignore_signal(self):
22         """Test Python SBUnixSignals.Suppress/Stop/Notify() API."""
23         self.build()
24         exe = os.path.join(os.getcwd(), "a.out")
25         self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
26
27         target = self.dbg.CreateTarget(exe)
28         self.assertTrue(target, VALID_TARGET)
29
30         line = line_number("main.cpp", "// Set break point at this line and setup signal ignores.")
31         breakpoint = target.BreakpointCreateByLocation("main.cpp", line)
32         self.assertTrue(breakpoint, VALID_BREAKPOINT)
33
34         # Launch the process, and do not stop at the entry point.
35         process = target.LaunchSimple (None, None, self.get_process_working_directory())
36
37         thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint)
38         self.assertTrue(thread.IsValid(), "There should be a thread stopped due to breakpoint")
39
40         unix_signals = process.GetUnixSignals()
41         sigint = unix_signals.GetSignalNumberFromName("SIGINT")
42         unix_signals.SetShouldSuppress(sigint, True)
43         unix_signals.SetShouldStop(sigint, False)
44         unix_signals.SetShouldNotify(sigint, False)
45
46         process.Continue()
47         self.assertTrue(process.state == lldb.eStateExited, "The process should have exited")
48         self.assertTrue(process.GetExitStatus() == 0, "The process should have returned 0")