1"""Test the lldb public C++ api breakpoint callbacks. """ 2 3import os, re, StringIO 4import unittest2 5from lldbtest import * 6import lldbutil 7import subprocess 8 9class SBBreakpointCallbackCase(TestBase): 10 11 mydir = os.path.join("api", "multithreaded") 12 13 def setUp(self): 14 TestBase.setUp(self) 15 self.lib_dir = os.environ["LLDB_LIB_DIR"] 16 self.inferior = 'inferior_program' 17 if self.getArchitecture() != "i386": 18 self.buildProgram('inferior.cpp', self.inferior) 19 self.addTearDownHook(lambda: os.remove(self.inferior)) 20 21 @unittest2.expectedFailure # llvm.org/pr16000: SBBreakpoint.SetCallback() does nothing 22 @skipIfi386 23 @skipIfLinuxClang # buildbot clang version unable to use libstdc++ with c++11 24 def test_breakpoint_callback(self): 25 """Test the that SBBreakpoint callback is invoked when a breakpoint is hit. """ 26 self.build_and_test('driver.cpp test_breakpoint_callback.cpp', 27 'test_breakpoint_callback') 28 29 @skipIfi386 30 @skipIfLinuxClang # buildbot clang version unable to use libstdc++ with c++11 31 def test_sb_api_listener_event_description(self): 32 """ Test the description of an SBListener breakpoint event is valid.""" 33 self.build_and_test('driver.cpp listener_test.cpp test_listener_event_description.cpp', 34 'test_listener_event_description') 35 pass 36 37 @skipIfi386 38 @skipIfLinuxClang # buildbot clang version unable to use libstdc++ with c++11 39 def test_sb_api_listener_event_process_state(self): 40 """ Test that a registered SBListener receives events when a process 41 changes state. 42 """ 43 self.build_and_test('driver.cpp listener_test.cpp test_listener_event_process_state.cpp', 44 'test_listener_event_process_state') 45 pass 46 47 48 @skipIfi386 49 @skipIfLinuxClang # buildbot clang version unable to use libstdc++ with c++11 50 @skipIfLinux # llvm.org/pr16016 assertion failure in ProcessPOSIX.cpp. 51 def test_sb_api_listener_resume(self): 52 """ Test that a process can be resumed from a non-main thread. """ 53 self.build_and_test('driver.cpp listener_test.cpp test_listener_resume.cpp', 54 'test_listener_resume') 55 pass 56 57 def build_and_test(self, sources, test_name, args = None): 58 """ Build LLDB test from sources, and run expecting 0 exit code """ 59 self.buildDriver(sources, test_name) 60 self.addTearDownHook(lambda: os.remove(test_name)) 61 62 exe = [os.path.join(os.getcwd(), test_name), self.inferior] 63 64 if self.TraceOn(): 65 print "Running test %s" % " ".join(exe) 66 67 check_call(exe, env={self.dylibPath : self.getLLDBLibraryEnvVal()}) 68 69 70 71 def build_program(self, sources, program): 72 return self.buildDriver(sources, program) 73 74if __name__ == '__main__': 75 import atexit 76 lldb.SBDebugger.Initialize() 77 atexit.register(lambda: lldb.SBDebugger.Terminate()) 78 unittest2.main() 79