1 """Test the lldb public C++ api breakpoint callbacks."""
6 from lldbsuite
.test
.decorators
import *
7 from lldbsuite
.test
.lldbtest
import *
8 from lldbsuite
.test
import lldbutil
12 class SBBreakpointCallbackCase(TestBase
):
13 NO_DEBUG_INFO_TESTCASE
= True
17 self
.generateSource("driver.cpp")
18 self
.generateSource("listener_test.cpp")
19 self
.generateSource("test_breakpoint_callback.cpp")
20 self
.generateSource("test_breakpoint_location_callback.cpp")
21 self
.generateSource("test_listener_event_description.cpp")
22 self
.generateSource("test_listener_event_process_state.cpp")
23 self
.generateSource("test_listener_resume.cpp")
24 self
.generateSource("test_stop-hook.cpp")
25 self
.generateSource("test_concurrent_unwind.cpp")
28 # clang-cl does not support throw or catch (llvm.org/pr24538)
30 @skipIfHostIncompatibleWithTarget
31 def test_python_stop_hook(self
):
32 """Test that you can run a python command in a stop-hook when stdin is File based."""
33 self
.build_and_test("driver.cpp test_stop-hook.cpp", "test_python_stop_hook")
36 # clang-cl does not support throw or catch (llvm.org/pr24538)
38 @skipIfHostIncompatibleWithTarget
39 def test_breakpoint_callback(self
):
40 """Test the that SBBreakpoint callback is invoked when a breakpoint is hit."""
42 "driver.cpp test_breakpoint_callback.cpp", "test_breakpoint_callback"
46 # clang-cl does not support throw or catch (llvm.org/pr24538)
48 @skipIfHostIncompatibleWithTarget
49 def test_breakpoint_location_callback(self
):
50 """Test the that SBBreakpointLocation callback is invoked when a breakpoint is hit."""
52 "driver.cpp test_breakpoint_location_callback.cpp",
53 "test_breakpoint_location_callback",
57 # clang-cl does not support throw or catch (llvm.org/pr24538)
59 @expectedFlakeyFreeBSD
60 @skipIfHostIncompatibleWithTarget
61 def test_sb_api_listener_event_description(self
):
62 """Test the description of an SBListener breakpoint event is valid."""
64 "driver.cpp listener_test.cpp test_listener_event_description.cpp",
65 "test_listener_event_description",
69 # clang-cl does not support throw or catch (llvm.org/pr24538)
71 @expectedFlakeyFreeBSD
72 @skipIfHostIncompatibleWithTarget
73 def test_sb_api_listener_event_process_state(self
):
74 """Test that a registered SBListener receives events when a process
78 "driver.cpp listener_test.cpp test_listener_event_process_state.cpp",
79 "test_listener_event_process_state",
83 # clang-cl does not support throw or catch (llvm.org/pr24538)
85 @expectedFlakeyFreeBSD
86 @skipIf(oslist
=["linux"]) # flakey
87 @skipIfHostIncompatibleWithTarget
88 def test_sb_api_listener_resume(self
):
89 """Test that a process can be resumed from a non-main thread."""
91 "driver.cpp listener_test.cpp test_listener_resume.cpp",
92 "test_listener_resume",
96 # clang-cl does not support throw or catch (llvm.org/pr24538)
98 @skipIfHostIncompatibleWithTarget
99 def test_concurrent_unwind(self
):
100 """Test that you can run a python command in a stop-hook when stdin is File based."""
102 "driver.cpp test_concurrent_unwind.cpp",
103 "test_concurrent_unwind",
104 inferior_source
="deep_stack.cpp",
107 def build_and_test(self
, sources
, test_name
, inferior_source
="inferior.cpp"):
108 """Build LLDB test from sources, and run expecting 0 exit code"""
110 # These tests link against host lldb API.
111 # Compiler's target triple must match liblldb triple
112 # because remote is disabled, we can assume that the os is the same
113 # still need to check architecture
114 if self
.getLldbArchitecture() != self
.getArchitecture():
116 "This test is only run if the target arch is the same as the lldb binary arch"
119 self
.inferior
= "inferior_program"
120 self
.buildProgram(inferior_source
, self
.inferior
)
121 self
.addTearDownHook(lambda: os
.remove(self
.getBuildArtifact(self
.inferior
)))
123 self
.buildDriver(sources
, test_name
)
124 self
.addTearDownHook(lambda: os
.remove(self
.getBuildArtifact(test_name
)))
126 test_exe
= self
.getBuildArtifact(test_name
)
127 exe
= [test_exe
, self
.getBuildArtifact(self
.inferior
)]
129 # check_call will raise a CalledProcessError if the executable doesn't
130 # return exit code 0 to indicate success. We can let this exception go
131 # - the test harness will recognize it as a test failure.
132 subprocess
.check_call(exe
)
134 def build_program(self
, sources
, program
):
135 return self
.buildDriver(sources
, program
)