Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / test / API / api / multithreaded / TestMultithreaded.py
blob631079b1d1db62519caa828f2b65391577786671
1 """Test the lldb public C++ api breakpoint callbacks."""
3 # __package__ = "lldbsuite.test"
6 import os
7 from lldbsuite.test.decorators import *
8 from lldbsuite.test.lldbtest import *
9 from lldbsuite.test import lldbutil
12 @skipIfNoSBHeaders
13 class SBBreakpointCallbackCase(TestBase):
14 NO_DEBUG_INFO_TESTCASE = True
16 def setUp(self):
17 TestBase.setUp(self)
18 self.generateSource("driver.cpp")
19 self.generateSource("listener_test.cpp")
20 self.generateSource("test_breakpoint_callback.cpp")
21 self.generateSource("test_breakpoint_location_callback.cpp")
22 self.generateSource("test_listener_event_description.cpp")
23 self.generateSource("test_listener_event_process_state.cpp")
24 self.generateSource("test_listener_resume.cpp")
25 self.generateSource("test_stop-hook.cpp")
27 @skipIfRemote
28 # clang-cl does not support throw or catch (llvm.org/pr24538)
29 @skipIfWindows
30 def test_python_stop_hook(self):
31 """Test that you can run a python command in a stop-hook when stdin is File based."""
32 self.build_and_test("driver.cpp test_stop-hook.cpp", "test_python_stop_hook")
34 @skipIfRemote
35 # clang-cl does not support throw or catch (llvm.org/pr24538)
36 @skipIfWindows
37 def test_breakpoint_callback(self):
38 """Test the that SBBreakpoint callback is invoked when a breakpoint is hit."""
39 self.build_and_test(
40 "driver.cpp test_breakpoint_callback.cpp", "test_breakpoint_callback"
43 @skipIfRemote
44 # clang-cl does not support throw or catch (llvm.org/pr24538)
45 @skipIfWindows
46 def test_breakpoint_location_callback(self):
47 """Test the that SBBreakpointLocation callback is invoked when a breakpoint is hit."""
48 self.build_and_test(
49 "driver.cpp test_breakpoint_location_callback.cpp",
50 "test_breakpoint_location_callback",
53 @skipIfRemote
54 # clang-cl does not support throw or catch (llvm.org/pr24538)
55 @skipIfWindows
56 @expectedFlakeyFreeBSD
57 def test_sb_api_listener_event_description(self):
58 """Test the description of an SBListener breakpoint event is valid."""
59 self.build_and_test(
60 "driver.cpp listener_test.cpp test_listener_event_description.cpp",
61 "test_listener_event_description",
64 @skipIfRemote
65 # clang-cl does not support throw or catch (llvm.org/pr24538)
66 @skipIfWindows
67 @expectedFlakeyFreeBSD
68 def test_sb_api_listener_event_process_state(self):
69 """Test that a registered SBListener receives events when a process
70 changes state.
71 """
72 self.build_and_test(
73 "driver.cpp listener_test.cpp test_listener_event_process_state.cpp",
74 "test_listener_event_process_state",
77 @skipIfRemote
78 # clang-cl does not support throw or catch (llvm.org/pr24538)
79 @skipIfWindows
80 @expectedFlakeyFreeBSD
81 @skipIf(oslist=["linux"]) # flakey
82 def test_sb_api_listener_resume(self):
83 """Test that a process can be resumed from a non-main thread."""
84 self.build_and_test(
85 "driver.cpp listener_test.cpp test_listener_resume.cpp",
86 "test_listener_resume",
89 def build_and_test(self, sources, test_name, args=None):
90 """Build LLDB test from sources, and run expecting 0 exit code"""
92 # These tests link against host lldb API.
93 # Compiler's target triple must match liblldb triple
94 # because remote is disabled, we can assume that the os is the same
95 # still need to check architecture
96 if self.getLldbArchitecture() != self.getArchitecture():
97 self.skipTest(
98 "This test is only run if the target arch is the same as the lldb binary arch"
101 self.inferior = "inferior_program"
102 self.buildProgram("inferior.cpp", self.inferior)
103 self.addTearDownHook(lambda: os.remove(self.getBuildArtifact(self.inferior)))
105 self.buildDriver(sources, test_name)
106 self.addTearDownHook(lambda: os.remove(self.getBuildArtifact(test_name)))
108 test_exe = self.getBuildArtifact(test_name)
109 self.signBinary(test_exe)
110 exe = [test_exe, self.getBuildArtifact(self.inferior)]
112 env = {self.dylibPath: self.getLLDBLibraryEnvVal()}
113 if "LLDB_DEBUGSERVER_PATH" in os.environ:
114 env["LLDB_DEBUGSERVER_PATH"] = os.environ["LLDB_DEBUGSERVER_PATH"]
115 try:
116 if self.TraceOn():
117 print("Running test %s" % " ".join(exe))
118 check_call(exe, env=env)
119 else:
120 with open(os.devnull, "w") as fnull:
121 check_call(exe, env=env, stdout=fnull, stderr=fnull)
122 except subprocess.CalledProcessError as e:
123 self.fail(e)
125 def build_program(self, sources, program):
126 return self.buildDriver(sources, program)