diff options
Diffstat (limited to 'lldb/test/python_api')
42 files changed, 344 insertions, 1140 deletions
diff --git a/lldb/test/python_api/breakpoint/TestBreakpointAPI.py b/lldb/test/python_api/breakpoint/TestBreakpointAPI.py index 0a4e7fa5a79..764fe22c190 100644 --- a/lldb/test/python_api/breakpoint/TestBreakpointAPI.py +++ b/lldb/test/python_api/breakpoint/TestBreakpointAPI.py @@ -12,27 +12,10 @@ class BreakpointAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin @python_api_test - @dsym_test - def test_breakpoint_is_valid_with_dsym(self): + def test_breakpoint_is_valid(self): """Make sure that if an SBBreakpoint gets deleted its IsValid returns false.""" - self.buildDsym() - self.breakpoint_is_valid() - - @python_api_test - @dwarf_test - def test_breakpoint_is_valid_with_dwarf(self): - """Make sure that if an SBBreakpoint gets deleted its IsValid returns false.""" - self.buildDwarf() - self.breakpoint_is_valid () - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - - def breakpoint_is_valid(self): - """Get an SBBreakpoint object, delete it from the target and make sure it is no longer valid.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/class_members/TestSBTypeClassMembers.py b/lldb/test/python_api/class_members/TestSBTypeClassMembers.py index c3af671572a..1361c787839 100644 --- a/lldb/test/python_api/class_members/TestSBTypeClassMembers.py +++ b/lldb/test/python_api/class_members/TestSBTypeClassMembers.py @@ -12,26 +12,6 @@ class SBTypeMemberFunctionsTest(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Test SBType APIs to fetch member function types.""" - d = {'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.type_api(self.exe_name) - - @skipUnlessDarwin - @python_api_test - @dwarf_test - def test_with_dwarf(self): - """Test SBType APIs to fetch member function types.""" - d = {'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.type_api(self.exe_name) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -41,9 +21,14 @@ class SBTypeMemberFunctionsTest(TestBase): self.source = 'main.mm' self.line = line_number(self.source, '// set breakpoint here') - def type_api(self, exe_name): + @skipUnlessDarwin + @python_api_test + def test(self): """Test SBType APIs to fetch member function types.""" - exe = os.path.join(os.getcwd(), exe_name) + d = {'EXE': self.exe_name} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + exe = os.path.join(os.getcwd(), self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/debugger/TestDebuggerAPI.py b/lldb/test/python_api/debugger/TestDebuggerAPI.py index 42dcc24df95..add7eade3d4 100644 --- a/lldb/test/python_api/debugger/TestDebuggerAPI.py +++ b/lldb/test/python_api/debugger/TestDebuggerAPI.py @@ -4,7 +4,7 @@ Test Debugger APIs. import os import lldb -from lldbtest import TestBase, python_api_test +from lldbtest import * class DebuggerAPITestCase(TestBase): @@ -12,6 +12,7 @@ class DebuggerAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @python_api_test + @no_debug_info_test def test_debugger_api_boundary_condition(self): """Exercise SBDebugger APIs with boundary conditions.""" self.dbg.HandleCommand(None) diff --git a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py index 846e5feef1d..147ad8a1a1f 100644 --- a/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py +++ b/lldb/test/python_api/default-constructor/TestDefaultConstructorForAPIObjects.py @@ -22,6 +22,7 @@ class APIDefaultConstructorTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @python_api_test + @no_debug_info_test def test_SBAddress(self): obj = lldb.SBAddress() if self.TraceOn(): @@ -32,6 +33,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_address.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBBlock(self): obj = lldb.SBBlock() if self.TraceOn(): @@ -42,6 +44,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_block.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBBreakpoint(self): obj = lldb.SBBreakpoint() if self.TraceOn(): @@ -52,6 +55,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_breakpoint.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBBreakpointLocation(self): obj = lldb.SBBreakpointLocation() if self.TraceOn(): @@ -62,6 +66,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_breakpointlocation.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBBroadcaster(self): obj = lldb.SBBroadcaster() if self.TraceOn(): @@ -72,6 +77,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_broadcaster.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBCommandReturnObject(self): """SBCommandReturnObject object is valid after default construction.""" obj = lldb.SBCommandReturnObject() @@ -80,6 +86,7 @@ class APIDefaultConstructorTestCase(TestBase): self.assertTrue(obj) @python_api_test + @no_debug_info_test def test_SBCommunication(self): obj = lldb.SBCommunication() if self.TraceOn(): @@ -90,6 +97,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_communication.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBCompileUnit(self): obj = lldb.SBCompileUnit() if self.TraceOn(): @@ -100,6 +108,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_compileunit.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBDebugger(self): obj = lldb.SBDebugger() if self.TraceOn(): @@ -110,6 +119,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_debugger.fuzz_obj(obj) @python_api_test + @no_debug_info_test # darwin: This test passes with swig 3.0.2, fails w/3.0.5 other tests fail with 2.0.12 http://llvm.org/pr23488 def test_SBError(self): obj = lldb.SBError() @@ -121,6 +131,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_error.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBEvent(self): obj = lldb.SBEvent() # This is just to test that typemap, as defined in lldb.swig, works. @@ -145,6 +156,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_filespec.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBFrame(self): obj = lldb.SBFrame() if self.TraceOn(): @@ -155,6 +167,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_frame.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBFunction(self): obj = lldb.SBFunction() if self.TraceOn(): @@ -165,6 +178,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_function.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBInstruction(self): obj = lldb.SBInstruction() if self.TraceOn(): @@ -175,6 +189,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_instruction.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBInstructionList(self): obj = lldb.SBInstructionList() if self.TraceOn(): @@ -185,6 +200,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_instructionlist.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBLineEntry(self): obj = lldb.SBLineEntry() if self.TraceOn(): @@ -195,6 +211,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_lineentry.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBListener(self): obj = lldb.SBListener() if self.TraceOn(): @@ -205,6 +222,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_listener.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBModule(self): obj = lldb.SBModule() if self.TraceOn(): @@ -215,6 +233,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_module.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBProcess(self): obj = lldb.SBProcess() if self.TraceOn(): @@ -225,6 +244,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_process.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBSection(self): obj = lldb.SBSection() if self.TraceOn(): @@ -235,6 +255,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_section.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBStream(self): """SBStream object is valid after default construction.""" obj = lldb.SBStream() @@ -243,6 +264,7 @@ class APIDefaultConstructorTestCase(TestBase): self.assertTrue(obj) @python_api_test + @no_debug_info_test def test_SBStringList(self): obj = lldb.SBStringList() if self.TraceOn(): @@ -253,6 +275,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_stringlist.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBSymbol(self): obj = lldb.SBSymbol() if self.TraceOn(): @@ -263,6 +286,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_symbol.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBSymbolContext(self): obj = lldb.SBSymbolContext() if self.TraceOn(): @@ -273,6 +297,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_symbolcontext.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBSymbolContextList(self): """SBSymbolContextList object is valid after default construction.""" obj = lldb.SBSymbolContextList() @@ -281,6 +306,7 @@ class APIDefaultConstructorTestCase(TestBase): self.assertTrue(obj) @python_api_test + @no_debug_info_test def test_SBTarget(self): obj = lldb.SBTarget() if self.TraceOn(): @@ -291,6 +317,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_target.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBThread(self): obj = lldb.SBThread() if self.TraceOn(): @@ -301,6 +328,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_thread.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBType(self): try: obj = lldb.SBType() @@ -319,6 +347,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_type.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBTypeList(self): """SBTypeList object is valid after default construction.""" obj = lldb.SBTypeList() @@ -327,6 +356,7 @@ class APIDefaultConstructorTestCase(TestBase): self.assertTrue(obj) @python_api_test + @no_debug_info_test def test_SBValue(self): obj = lldb.SBValue() if self.TraceOn(): @@ -337,6 +367,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_value.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBValueList(self): obj = lldb.SBValueList() if self.TraceOn(): @@ -347,6 +378,7 @@ class APIDefaultConstructorTestCase(TestBase): sb_valuelist.fuzz_obj(obj) @python_api_test + @no_debug_info_test def test_SBWatchpoint(self): obj = lldb.SBWatchpoint() if self.TraceOn(): diff --git a/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py index 4a9cd7a258d..51da105ea7a 100644 --- a/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ b/lldb/test/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -13,14 +13,10 @@ class DisassembleRawDataTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @python_api_test + @no_debug_info_test def test_disassemble_raw_data(self): """Test disassembling raw bytes with the API.""" - self.disassemble_raw_data() - - def disassemble_raw_data(self): - """Test disassembling raw bytes with the API.""" # Create a target from the debugger. - target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "x86_64") self.assertTrue(target, VALID_TARGET) diff --git a/lldb/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py b/lldb/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py index 3a7a0cb2954..4bd4367e096 100644 --- a/lldb/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py +++ b/lldb/test/python_api/disassemble-raw-data/TestDisassemble_VST1_64.py @@ -14,14 +14,10 @@ class Disassemble_VST1_64(TestBase): @skipIf(True) # llvm.org/pr24575: all tests get ERRORs in dotest.py after this @python_api_test + @no_debug_info_test def test_disassemble_invalid_vst_1_64_raw_data(self): """Test disassembling invalid vst1.64 raw bytes with the API.""" - self.disassemble_invalid_vst_1_64_raw_data() - - def disassemble_invalid_vst_1_64_raw_data(self): - """Test disassembling invalid vst1.64 raw bytes with the API.""" # Create a target from the debugger. - target = self.dbg.CreateTargetWithFileAndTargetTriple ("", "thumbv7") self.assertTrue(target, VALID_TARGET) diff --git a/lldb/test/python_api/event/TestEvents.py b/lldb/test/python_api/event/TestEvents.py index 46841a809b5..cc744081518 100644 --- a/lldb/test/python_api/event/TestEvents.py +++ b/lldb/test/python_api/event/TestEvents.py @@ -12,64 +12,18 @@ class EventAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_listen_for_and_print_event_with_dsym(self): - """Exercise SBEvent API.""" - self.buildDsym() - self.do_listen_for_and_print_event() - - @python_api_test - @dwarf_test - @expectedFailureLinux("llvm.org/pr23730") # Flaky, fails ~1/10 cases - @skipIfLinux # skip to avoid crashes - def test_listen_for_and_print_event_with_dwarf(self): - """Exercise SBEvent API.""" - self.buildDwarf() - self.do_listen_for_and_print_event() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_wait_for_event_with_dsym(self): - """Exercise SBListener.WaitForEvent() API.""" - self.buildDsym() - self.do_wait_for_event() - - @python_api_test - @dwarf_test - def test_wait_for_event_with_dwarf(self): - """Exercise SBListener.WaitForEvent() API.""" - self.buildDwarf() - self.do_wait_for_event() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_add_listener_to_broadcaster_with_dsym(self): - """Exercise some SBBroadcaster APIs.""" - self.buildDsym() - self.do_add_listener_to_broadcaster() - - @skipIfFreeBSD # llvm.org/pr21325 - @python_api_test - @dwarf_test - @expectedFlakeyLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases - @expectedFailureWindows("llvm.org/pr24778") - def test_add_listener_to_broadcaster_with_dwarf(self): - """Exercise some SBBroadcaster APIs.""" - self.buildDwarf() - self.do_add_listener_to_broadcaster() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to of function 'c'. self.line = line_number('main.c', '// Find the line number of function "c" here.') - def do_listen_for_and_print_event(self): - """Create a listener and use SBEvent API to print the events received.""" + @python_api_test + @expectedFailureLinux("llvm.org/pr23730") # Flaky, fails ~1/10 cases + @skipIfLinux # skip to avoid crashes + def test_listen_for_and_print_event(self): + """Exercise SBEvent API.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") self.dbg.SetAsync(True) @@ -143,8 +97,10 @@ class EventAPITestCase(TestBase): # Wait until the 'MyListeningThread' terminates. my_thread.join() - def do_wait_for_event(self): - """Get the listener associated with the debugger and exercise WaitForEvent API.""" + @python_api_test + def test_wait_for_event(self): + """Exercise SBListener.WaitForEvent() API.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") self.dbg.SetAsync(True) @@ -212,8 +168,13 @@ class EventAPITestCase(TestBase): self.assertTrue(event, "My listening thread successfully received an event") - def do_add_listener_to_broadcaster(self): - """Get the broadcaster associated with the process and wait for broadcaster events.""" + @skipIfFreeBSD # llvm.org/pr21325 + @python_api_test + @expectedFlakeyLinux("llvm.org/pr23617") # Flaky, fails ~1/10 cases + @expectedFailureWindows("llvm.org/pr24778") + def test_add_listener_to_broadcaster(self): + """Exercise some SBBroadcaster APIs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") self.dbg.SetAsync(True) @@ -320,7 +281,6 @@ class EventAPITestCase(TestBase): self.assertTrue(self.state == 'stopped', "Both expected state changed events received") - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/python_api/findvalue_duplist/TestSBFrameFindValue.py b/lldb/test/python_api/findvalue_duplist/TestSBFrameFindValue.py index 41d782ea93a..a2a433f44ea 100644 --- a/lldb/test/python_api/findvalue_duplist/TestSBFrameFindValue.py +++ b/lldb/test/python_api/findvalue_duplist/TestSBFrameFindValue.py @@ -10,29 +10,12 @@ class SBFrameFindValueTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin @python_api_test - @dsym_test - def test_with_dsym_formatters_api(self): + def test_formatters_api(self): """Test that SBFrame::FindValue finds things but does not duplicate the entire variables list""" - self.buildDsym() + self.build() self.setTearDownCleanup() - self.commands() - @python_api_test - @dwarf_test - def test_with_dwarf_formatters_api(self): - """Test that SBFrame::FindValue finds things but does not duplicate the entire variables list""" - self.buildDwarf() - self.setTearDownCleanup() - self.commands() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - - def commands(self): - """Test that SBFrame::FindValue finds things but does not duplicate the entire variables list""" exe_name = "a.out" exe = os.path.join(os.getcwd(), exe_name) diff --git a/lldb/test/python_api/formatters/TestFormattersSBAPI.py b/lldb/test/python_api/formatters/TestFormattersSBAPI.py index 68a07a1ee36..804f504b3da 100644 --- a/lldb/test/python_api/formatters/TestFormattersSBAPI.py +++ b/lldb/test/python_api/formatters/TestFormattersSBAPI.py @@ -10,36 +10,17 @@ class SBFormattersAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_formatters_api(self): - """Test Python APIs for working with formatters""" - self.buildDsym() - self.setTearDownCleanup() - self.formatters() - - @python_api_test - @dwarf_test - def test_with_dwarf_formatters_api(self): - """Test Python APIs for working with formatters""" - self.buildDwarf() - self.setTearDownCleanup() - self.formatters() - - @python_api_test - def test_force_synth_off(self): - """Test that one can have the public API return non-synthetic SBValues if desired""" - self.buildDwarf(dictionary={'EXE':'no_synth'}) - self.setTearDownCleanup() - self.force_synth_off() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) self.line = line_number('main.cpp', '// Set break point at this line.') - def formatters(self): + @python_api_test + def test_formatters_api(self): + """Test Python APIs for working with formatters""" + self.build() + self.setTearDownCleanup() + """Test Python APIs for working with formatters""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) @@ -307,8 +288,12 @@ class SBFormattersAPITestCase(TestBase): self.expect("frame variable e2", substrs=["I am an empty Empty2"]) self.expect("frame variable e2", substrs=["I am an empty Empty2 {}"], matching=False) - def force_synth_off(self): + @python_api_test + def test_force_synth_off(self): """Test that one can have the public API return non-synthetic SBValues if desired""" + self.build(dictionary={'EXE':'no_synth'}) + self.setTearDownCleanup() + self.runCmd("file no_synth", CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/lldb/test/python_api/frame/TestFrames.py b/lldb/test/python_api/frame/TestFrames.py index bcde045a5a2..651921128c9 100644 --- a/lldb/test/python_api/frame/TestFrames.py +++ b/lldb/test/python_api/frame/TestFrames.py @@ -13,36 +13,11 @@ class FrameAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin @python_api_test - @dsym_test - def test_get_arg_vals_for_call_stack_with_dsym(self): - """Exercise SBFrame.GetVariables() API to get argument vals.""" - self.buildDsym() - self.do_get_arg_vals() - - @python_api_test - @dwarf_test @expectedFailureWindows("llvm.org/pr24778") - def test_get_arg_vals_for_call_stack_with_dwarf(self): + def test_get_arg_vals_for_call_stack(self): """Exercise SBFrame.GetVariables() API to get argument vals.""" - self.buildDwarf() - self.do_get_arg_vals() - - @python_api_test - def test_frame_api_boundary_condition(self): - """Exercise SBFrame APIs with boundary condition inputs.""" - self.buildDefault() - self.frame_api_boundary_condition() - - @python_api_test - def test_frame_api_IsEqual(self): - """Exercise SBFrame API IsEqual.""" - self.buildDefault() - self.frame_api_IsEqual() - - def do_get_arg_vals(self): - """Get argument vals for the call stack when stopped on a breakpoint.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -128,7 +103,10 @@ class FrameAPITestCase(TestBase): substrs = ["a((int)val=1, (char)ch='A')", "a((int)val=3, (char)ch='A')"]) - def frame_api_boundary_condition(self): + @python_api_test + def test_frame_api_boundary_condition(self): + """Exercise SBFrame APIs with boundary condition inputs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -164,8 +142,10 @@ class FrameAPITestCase(TestBase): frame.EvaluateExpression(None) - def frame_api_IsEqual(self): + @python_api_test + def test_frame_api_IsEqual(self): """Exercise SBFrame API IsEqual.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/frame/inlines/TestInlinedFrame.py b/lldb/test/python_api/frame/inlines/TestInlinedFrame.py index 217b87e8926..98bd8e60109 100644 --- a/lldb/test/python_api/frame/inlines/TestInlinedFrame.py +++ b/lldb/test/python_api/frame/inlines/TestInlinedFrame.py @@ -12,23 +12,7 @@ class InlinedFrameAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_stop_at_outer_inline_with_dsym(self): - """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" - self.buildDsym() - self.do_stop_at_outer_inline() - - @python_api_test - @dwarf_test - def test_stop_at_outer_inline_with_dwarf(self): - """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" - self.buildDwarf() - self.do_stop_at_outer_inline() - def setUp(self): - # Call super's setUp(). TestBase.setUp(self) # Find the line number to of function 'c'. @@ -36,8 +20,10 @@ class InlinedFrameAPITestCase(TestBase): self.first_stop = line_number(self.source, '// This should correspond to the first break stop.') self.second_stop = line_number(self.source, '// This should correspond to the second break stop.') - def do_stop_at_outer_inline(self): + @python_api_test + def test_stop_at_outer_inline(self): """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/function_symbol/TestDisasmAPI.py b/lldb/test/python_api/function_symbol/TestDisasmAPI.py index d7270ba72d5..c8e079fd299 100644 --- a/lldb/test/python_api/function_symbol/TestDisasmAPI.py +++ b/lldb/test/python_api/function_symbol/TestDisasmAPI.py @@ -12,21 +12,6 @@ class DisasmAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Exercise getting SBAddress objects, disassembly, and SBAddress APIs.""" - self.buildDsym() - self.disasm_and_address_api() - - @python_api_test - @dwarf_test - def test_with_dwarf(self): - """Exercise getting SBAddress objects, disassembly, and SBAddress APIs.""" - self.buildDwarf() - self.disasm_and_address_api() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -34,8 +19,10 @@ class DisasmAPITestCase(TestBase): self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.') self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.') - def disasm_and_address_api(self): + @python_api_test + def test(self): """Exercise getting SBAddress objects, disassembly, and SBAddress APIs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -119,7 +106,6 @@ class DisasmAPITestCase(TestBase): self.assertTrue(desc1 and desc2 and desc1 == desc2, "SBAddress.GetDescription() API of sa1 and sa2 should return the same string") - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/python_api/function_symbol/TestSymbolAPI.py b/lldb/test/python_api/function_symbol/TestSymbolAPI.py index 6a59ee361fb..b363c1aaaed 100644 --- a/lldb/test/python_api/function_symbol/TestSymbolAPI.py +++ b/lldb/test/python_api/function_symbol/TestSymbolAPI.py @@ -12,22 +12,6 @@ class SymbolAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Exercise some SBSymbol and SBAddress APIs.""" - self.buildDsym() - self.symbol_and_address_api() - - @python_api_test - @dwarf_test - @expectedFailureWindows("llvm.org/pr24778") - def test_with_dwarf(self): - """Exercise some SBSymbol and SBAddress APIs.""" - self.buildDwarf() - self.symbol_and_address_api() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -35,8 +19,11 @@ class SymbolAPITestCase(TestBase): self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.') self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.') - def symbol_and_address_api(self): + @python_api_test + @expectedFailureWindows("llvm.org/pr24778") + def test(self): """Exercise some SBSymbol and SBAddress APIs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/hello_world/TestHelloWorld.py b/lldb/test/python_api/hello_world/TestHelloWorld.py index e9cd7783a65..8e586c8dcdf 100644 --- a/lldb/test/python_api/hello_world/TestHelloWorld.py +++ b/lldb/test/python_api/hello_world/TestHelloWorld.py @@ -9,82 +9,7 @@ from lldbtest import * class HelloWorldTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_and_process_launch_api(self): - """Create target, breakpoint, launch a process, and then kill it. - - Use dsym info and process launch API. - """ - self.buildDsym(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.hello_world_python() - - @python_api_test - @dwarf_test - def test_with_dwarf_and_process_launch_api(self): - """Create target, breakpoint, launch a process, and then kill it. - - Use dwarf debug map and process launch API. - """ - self.buildDwarf(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.hello_world_python() - - @not_remote_testsuite_ready - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_and_attach_to_process_with_id_api(self): - """Create target, spawn a process, and attach to it with process id. - - Use dsym info and attach to process with id API. - """ - self.buildDsym(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.hello_world_attach_with_id_api() - - @python_api_test - @dwarf_test - @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly - @expectedFailureWindows("llvm.org/pr24600") - def test_with_dwarf_and_attach_to_process_with_id_api(self): - """Create target, spawn a process, and attach to it with process id. - - Use dwarf map (no dsym) and attach to process with id API. - """ - self.buildDwarf(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.hello_world_attach_with_id_api() - - @not_remote_testsuite_ready - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_and_attach_to_process_with_name_api(self): - """Create target, spawn a process, and attach to it with process name. - - Use dsym info and attach to process with name API. - """ - self.buildDsym(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.hello_world_attach_with_name_api() - - @python_api_test - @dwarf_test - @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly - @expectedFailureWindows("llvm.org/pr24600") - def test_with_dwarf_and_attach_to_process_with_name_api(self): - """Create target, spawn a process, and attach to it with process name. - - Use dwarf map (no dsym) and attach to process with name API. - """ - self.buildDwarf(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.hello_world_attach_with_name_api() - + def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -101,9 +26,11 @@ class HelloWorldTestCase(TestBase): # Call super's tearDown(). TestBase.tearDown(self) - def hello_world_python(self): + @python_api_test + def test_with_process_launch_api(self): """Create target, breakpoint, launch a process, and then kill it.""" - + self.build(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) target = self.dbg.CreateTarget(self.exe) breakpoint = target.BreakpointCreateByLocation("main.c", self.line1) @@ -142,9 +69,13 @@ class HelloWorldTestCase(TestBase): # The breakpoint should have a hit count of 1. self.assertTrue(breakpoint.GetHitCount() == 1, BREAKPOINT_HIT_ONCE) - def hello_world_attach_with_id_api(self): - """Create target, spawn a process, and attach to it by id.""" - + @python_api_test + @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly + @expectedFailureWindows("llvm.org/pr24600") + def test_with_attach_to_process_with_id_api(self): + """Create target, spawn a process, and attach to it with process id.""" + self.build(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) target = self.dbg.CreateTarget(self.exe) # Spawn a new process @@ -167,9 +98,13 @@ class HelloWorldTestCase(TestBase): substrs = ['main.c:%d' % self.line2, '(int)argc=3']) - def hello_world_attach_with_name_api(self): - """Create target, spawn a process, and attach to it by name.""" - + @python_api_test + @expectedFailurei386 # llvm.org/pr17384: lldb needs to be aware of linux-vdso.so to unwind stacks properly + @expectedFailureWindows("llvm.org/pr24600") + def test_with_attach_to_process_with_name_api(self): + """Create target, spawn a process, and attach to it with process name.""" + self.build(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) target = self.dbg.CreateTarget(self.exe) # Spawn a new process @@ -205,7 +140,6 @@ class HelloWorldTestCase(TestBase): substrs = ['main.c:%d' % self.line2, '(int)argc=3']) - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py b/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py index c57535c77c0..b617a617e87 100644 --- a/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py +++ b/lldb/test/python_api/interpreter/TestCommandInterpreterAPI.py @@ -9,29 +9,16 @@ class CommandInterpreterAPICase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_and_process_launch_api(self): - """Test the SBCommandInterpreter APIs.""" - self.buildDsym() - self.command_interpreter_api() - - @python_api_test - @dwarf_test - def test_with_dwarf_and_process_launch_api(self): - """Test the SBCommandInterpreter APIs.""" - self.buildDwarf() - self.command_interpreter_api() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break on inside main.cpp. self.line = line_number('main.c', 'Hello world.') - def command_interpreter_api(self): + @python_api_test + def test_with_process_launch_api(self): """Test the SBCommandInterpreter APIs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/lldbutil/frame/TestFrameUtils.py b/lldb/test/python_api/lldbutil/frame/TestFrameUtils.py index 22db4a4be36..4b0c460ad69 100644 --- a/lldb/test/python_api/lldbutil/frame/TestFrameUtils.py +++ b/lldb/test/python_api/lldbutil/frame/TestFrameUtils.py @@ -21,10 +21,7 @@ class FrameUtilsTestCase(TestBase): @python_api_test def test_frame_utils(self): """Test utility functions for the frame object.""" - self.buildDefault() - self.frame_utils() - - def frame_utils(self): + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/lldbutil/iter/TestLLDBIterator.py b/lldb/test/python_api/lldbutil/iter/TestLLDBIterator.py index 4d32d6d997d..124f7031597 100644 --- a/lldb/test/python_api/lldbutil/iter/TestLLDBIterator.py +++ b/lldb/test/python_api/lldbutil/iter/TestLLDBIterator.py @@ -22,22 +22,7 @@ class LLDBIteratorTestCase(TestBase): @python_api_test def test_lldb_iter_module(self): """Test module_iter works correctly for SBTarget -> SBModule.""" - self.buildDefault() - self.lldb_iter_module() - - @python_api_test - def test_lldb_iter_breakpoint(self): - """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" - self.buildDefault() - self.lldb_iter_breakpoint() - - @python_api_test - def test_lldb_iter_frame(self): - """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" - self.buildDefault() - self.lldb_iter_frame() - - def lldb_iter_module(self): + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -68,7 +53,10 @@ class LLDBIteratorTestCase(TestBase): self.assertTrue(yours[i] == mine[i], "UUID+FileSpec of yours[{0}] and mine[{0}] matches".format(i)) - def lldb_iter_breakpoint(self): + @python_api_test + def test_lldb_iter_breakpoint(self): + """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -97,7 +85,10 @@ class LLDBIteratorTestCase(TestBase): self.assertTrue(yours[i] == mine[i], "ID of yours[{0}] and mine[{0}] matches".format(i)) - def lldb_iter_frame(self): + @python_api_test + def test_lldb_iter_frame(self): + """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/lldbutil/iter/TestRegistersIterator.py b/lldb/test/python_api/lldbutil/iter/TestRegistersIterator.py index 4dc5dbe7aa6..32d660e5950 100644 --- a/lldb/test/python_api/lldbutil/iter/TestRegistersIterator.py +++ b/lldb/test/python_api/lldbutil/iter/TestRegistersIterator.py @@ -22,10 +22,7 @@ class RegistersIteratorTestCase(TestBase): @expectedFailureWindows # Test crashes def test_iter_registers(self): """Test iterator works correctly for lldbutil.iter_registers().""" - self.buildDefault() - self.iter_registers() - - def iter_registers(self): + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/lldbutil/process/TestPrintStackTraces.py b/lldb/test/python_api/lldbutil/process/TestPrintStackTraces.py index cd13d688e19..09945f5cbe5 100644 --- a/lldb/test/python_api/lldbutil/process/TestPrintStackTraces.py +++ b/lldb/test/python_api/lldbutil/process/TestPrintStackTraces.py @@ -23,12 +23,7 @@ class ThreadsStackTracesTestCase(TestBase): @python_api_test def test_stack_traces(self): """Test SBprocess and SBThread APIs with printing of the stack traces.""" - self.buildDefault() - self.break_and_print_stacktraces() - - def break_and_print_stacktraces(self): - """Break at main.cpp:68 and do a threads dump""" - + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/module_section/TestModuleAndSection.py b/lldb/test/python_api/module_section/TestModuleAndSection.py index 44a242da737..78e4b229bf9 100644 --- a/lldb/test/python_api/module_section/TestModuleAndSection.py +++ b/lldb/test/python_api/module_section/TestModuleAndSection.py @@ -16,22 +16,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): @python_api_test def test_module_and_section(self): """Test module and section APIs.""" - self.buildDefault() - self.module_and_section() - - @python_api_test - def test_module_and_section_boundary_condition(self): - """Test module and section APIs by passing None when it expects a Python string.""" - self.buildDefault() - self.module_and_section_boundary_condition() - - @python_api_test - def test_module_compile_unit_iter(self): - """Test module's compile unit iterator APIs.""" - self.buildDefault() - self.module_compile_unit_iter() - - def module_and_section(self): + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -68,7 +53,10 @@ class ModuleAndSectionAPIsTestCase(TestBase): print INDENT2 + str(sym) print INDENT2 + "symbol type: %s" % symbol_type_to_str(sym.GetType()) - def module_and_section_boundary_condition(self): + @python_api_test + def test_module_and_section_boundary_condition(self): + """Test module and section APIs by passing None when it expects a Python string.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -106,7 +94,10 @@ class ModuleAndSectionAPIsTestCase(TestBase): if sec1: sec1.FindSubSection(None) - def module_compile_unit_iter(self): + @python_api_test + def test_module_compile_unit_iter(self): + """Test module's compile unit iterator APIs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -131,7 +122,6 @@ class ModuleAndSectionAPIsTestCase(TestBase): for cu in exe_module.compile_unit_iter(): print cu - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/python_api/objc_type/TestObjCType.py b/lldb/test/python_api/objc_type/TestObjCType.py index ba3687a6508..9b8e915dd44 100644 --- a/lldb/test/python_api/objc_type/TestObjCType.py +++ b/lldb/test/python_api/objc_type/TestObjCType.py @@ -12,29 +12,16 @@ class ObjCSBTypeTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Test SBType for ObjC classes.""" - self.buildDsym() - self.objc_sbtype_test() - - @skipUnlessDarwin - @python_api_test - @dwarf_test - def test_with_dwarf(self): - """Test SBType for ObjC classes.""" - self.buildDwarf() - self.objc_sbtype_test() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) self.line = line_number("main.m", '// Break at this line') - def objc_sbtype_test(self): - """Exercise SBType and SBTypeList API.""" + @skipUnlessDarwin + @python_api_test + def test(self): + """Test SBType for ObjC classes.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/process/TestProcessAPI.py b/lldb/test/python_api/process/TestProcessAPI.py index 6bc255abfa6..0aaeca6299e 100644 --- a/lldb/test/python_api/process/TestProcessAPI.py +++ b/lldb/test/python_api/process/TestProcessAPI.py @@ -12,71 +12,16 @@ class ProcessAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_read_memory_with_dsym(self): - """Test Python SBProcess.ReadMemory() API.""" - self.buildDsym() - self.read_memory() - - @python_api_test - @dwarf_test - def test_read_memory_with_dwarf(self): - """Test Python SBProcess.ReadMemory() API.""" - self.buildDwarf() - self.read_memory() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_write_memory_with_dsym(self): - """Test Python SBProcess.WriteMemory() API.""" - self.buildDsym() - self.write_memory() - - @python_api_test - @dwarf_test - def test_write_memory_with_dwarf(self): - """Test Python SBProcess.WriteMemory() API.""" - self.buildDwarf() - self.write_memory() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_access_my_int_with_dsym(self): - """Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs.""" - self.buildDsym() - self.access_my_int() - - @python_api_test - @dwarf_test - def test_access_my_int_with_dwarf(self): - """Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs.""" - self.buildDwarf() - self.access_my_int() - - @python_api_test - def test_remote_launch(self): - """Test SBProcess.RemoteLaunch() API with a process not in eStateConnected, and it should fail.""" - self.buildDefault() - self.remote_launch_should_fail() - - @python_api_test - def test_get_num_supported_hardware_watchpoints(self): - """Test SBProcess.GetNumSupportedHardwareWatchpoints() API with a process.""" - self.buildDefault() - self.get_num_supported_hardware_watchpoints() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break inside main(). self.line = line_number("main.cpp", "// Set break point at this line and check variable 'my_char'.") - def read_memory(self): + @python_api_test + def test_read_memory(self): """Test Python SBProcess.ReadMemory() API.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -156,8 +101,10 @@ class ProcessAPITestCase(TestBase): if my_uint32 != 12345: self.fail("Result from SBProcess.ReadUnsignedFromMemory() does not match our expected output") - def write_memory(self): + @python_api_test + def test_write_memory(self): """Test Python SBProcess.WriteMemory() API.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -206,8 +153,10 @@ class ProcessAPITestCase(TestBase): exe=False, startstr = 'a') - def access_my_int(self): + @python_api_test + def test_access_my_int(self): """Test access 'my_int' using Python SBProcess.GetByteOrder() and other APIs.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -294,8 +243,10 @@ class ProcessAPITestCase(TestBase): for i in new_bytes: print "byte:", i - def remote_launch_should_fail(self): + @python_api_test + def test_remote_launch(self): """Test SBProcess.RemoteLaunch() API with a process not in eStateConnected, and it should fail.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") target = self.dbg.CreateTarget(exe) @@ -312,8 +263,10 @@ class ProcessAPITestCase(TestBase): success = process.RemoteLaunch(None, None, None, None, None, None, 0, False, error) self.assertTrue(not success, "RemoteLaunch() should fail for process state != eStateConnected") - def get_num_supported_hardware_watchpoints(self): + @python_api_test + def test_get_num_supported_hardware_watchpoints(self): """Test SBProcess.GetNumSupportedHardwareWatchpoints() API with a process.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) diff --git a/lldb/test/python_api/process/io/TestProcessIO.py b/lldb/test/python_api/process/io/TestProcessIO.py index 66ac0bdb0d8..9bd3b82a4f5 100644 --- a/lldb/test/python_api/process/io/TestProcessIO.py +++ b/lldb/test/python_api/process/io/TestProcessIO.py @@ -10,99 +10,77 @@ class ProcessIOTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_stdin_by_api_with_dsym(self): - """Exercise SBProcess.PutSTDIN().""" - self.buildDsym() - self.do_stdin_by_api() + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Get the full path to our executable to be debugged. + self.exe = os.path.join(os.getcwd(), "process_io") + self.local_input_file = os.path.join(os.getcwd(), "input.txt") + self.local_output_file = os.path.join(os.getcwd(), "output.txt") + self.local_error_file = os.path.join(os.getcwd(), "error.txt") + + self.input_file = os.path.join(self.get_process_working_directory(), "input.txt") + self.output_file = os.path.join(self.get_process_working_directory(), "output.txt") + self.error_file = os.path.join(self.get_process_working_directory(), "error.txt") + self.lines = ["Line 1", "Line 2", "Line 3"] @skipIfWindows # stdio manipulation unsupported on Windows @python_api_test - @dwarf_test - def test_stdin_by_api_with_dwarf(self): + def test_stdin_by_api(self): """Exercise SBProcess.PutSTDIN().""" - self.buildDwarf() - self.do_stdin_by_api() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_stdin_redirection_with_dsym(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR.""" - self.buildDsym() - self.do_stdin_redirection() + self.build() + self.create_target() + self.run_process(True) + output = self.process.GetSTDOUT(1000) + self.check_process_output(output, output) @skipIfWindows # stdio manipulation unsupported on Windows @python_api_test - @dwarf_test - def test_stdin_redirection_with_dwarf(self): + def test_stdin_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR.""" - self.buildDwarf() - self.do_stdin_redirection() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_stdout_redirection_with_dsym(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR.""" - self.buildDsym() - self.do_stdout_redirection() + self.build() + self.create_target() + self.redirect_stdin() + self.run_process(False) + output = self.process.GetSTDOUT(1000) + self.check_process_output(output, output) @skipIfWindows # stdio manipulation unsupported on Windows @python_api_test - @dwarf_test - def test_stdout_redirection_with_dwarf(self): + def test_stdout_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR.""" - self.buildDwarf() - self.do_stdout_redirection() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_stderr_redirection_with_dsym(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT.""" - self.buildDsym() - self.do_stderr_redirection() + self.build() + self.create_target() + self.redirect_stdout() + self.run_process(True) + output = self.read_output_file_and_delete() + error = self.process.GetSTDOUT(1000) + self.check_process_output(output, error) @skipIfWindows # stdio manipulation unsupported on Windows @python_api_test - @dwarf_test - def test_stderr_redirection_with_dwarf(self): + def test_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT.""" - self.buildDwarf() - self.do_stderr_redirection() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_stdout_stderr_redirection_with_dsym(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN.""" - self.buildDsym() - self.do_stdout_stderr_redirection() + self.build() + self.create_target() + self.redirect_stderr() + self.run_process(True) + output = self.process.GetSTDOUT(1000) + error = self.read_error_file_and_delete() + self.check_process_output(output, error) @skipIfWindows # stdio manipulation unsupported on Windows @python_api_test - @dwarf_test - def test_stdout_stderr_redirection_with_dwarf(self): + def test_stdout_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN.""" - self.buildDwarf() - self.do_stdout_stderr_redirection() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Get the full path to our executable to be debugged. - self.exe = os.path.join(os.getcwd(), "process_io") - self.local_input_file = os.path.join(os.getcwd(), "input.txt") - self.local_output_file = os.path.join(os.getcwd(), "output.txt") - self.local_error_file = os.path.join(os.getcwd(), "error.txt") - - self.input_file = os.path.join(self.get_process_working_directory(), "input.txt") - self.output_file = os.path.join(self.get_process_working_directory(), "output.txt") - self.error_file = os.path.join(self.get_process_working_directory(), "error.txt") - self.lines = ["Line 1", "Line 2", "Line 3"] + self.build() + self.create_target() + self.redirect_stdout() + self.redirect_stderr() + self.run_process(True) + output = self.read_output_file_and_delete() + error = self.read_error_file_and_delete() + self.check_process_output(output, error) # target_file - path on local file system or remote file system if running remote # local_file - path on local system @@ -168,61 +146,6 @@ class ProcessIOTestCase(TestBase): def redirect_stderr(self): '''Redirect STDERR (file descriptor 2) to use our error.txt file''' self.launch_info.AddOpenFileAction(2, self.error_file, False, True); - - def do_stdin_redirection(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR.""" - self.create_target() - self.redirect_stdin() - self.run_process(False) - output = self.process.GetSTDOUT(1000) - self.check_process_output(output, output) - - def do_stdout_redirection(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR.""" - self.create_target() - self.redirect_stdout() - self.run_process(True) - output = self.read_output_file_and_delete() - error = self.process.GetSTDOUT(1000) - self.check_process_output(output, error) - - def do_stderr_redirection(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT.""" - self.create_target() - self.redirect_stderr() - self.run_process(True) - output = self.process.GetSTDOUT(1000) - error = self.read_error_file_and_delete() - self.check_process_output(output, error) - - def do_stdout_stderr_redirection(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN.""" - self.create_target() - self.redirect_stdout() - self.redirect_stderr() - self.run_process(True) - output = self.read_output_file_and_delete() - error = self.read_error_file_and_delete() - self.check_process_output(output, error) - - def do_stdin_stdout_stderr_redirection(self): - """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN, STDOUT and STDERR.""" - # Make the input.txt file to use - self.create_target() - self.redirect_stdin() - self.redirect_stdout() - self.redirect_stderr() - self.run_process(True) - output = self.read_output_file_and_delete() - error = self.read_error_file_and_delete() - self.check_process_output(output, error) - - def do_stdin_by_api(self): - """Launch a process and use SBProcess.PutSTDIN() to write data to it.""" - self.create_target() - self.run_process(True) - output = self.process.GetSTDOUT(1000) - self.check_process_output(output, output) def run_process(self, put_stdin): '''Run the process to completion and optionally put lines to STDIN via the API if "put_stdin" is True''' diff --git a/lldb/test/python_api/rdar-12481949/Test-rdar-12481949.py b/lldb/test/python_api/rdar-12481949/Test-rdar-12481949.py index 49057851c96..7f9fb1ca27c 100644 --- a/lldb/test/python_api/rdar-12481949/Test-rdar-12481949.py +++ b/lldb/test/python_api/rdar-12481949/Test-rdar-12481949.py @@ -13,27 +13,15 @@ class Radar12481949DataFormatterTestCase(TestBase): # test for rdar://problem/12481949 mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @dsym_test - def test_with_dsym_and_run_command(self): - """Check that SBValue.GetValueAsSigned() does the right thing for a 32-bit -1.""" - self.buildDsym() - self.rdar12481949_commands() - - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Check that SBValue.GetValueAsSigned() does the right thing for a 32-bit -1.""" - self.buildDwarf() - self.rdar12481949_commands() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break at. self.line = line_number('main.cpp', '// Set break point at this line.') - def rdar12481949_commands(self): + def test_with_run_command(self): """Check that SBValue.GetValueAsSigned() does the right thing for a 32-bit -1.""" + self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) diff --git a/lldb/test/python_api/sbdata/TestSBData.py b/lldb/test/python_api/sbdata/TestSBData.py index cb4c6ae7aa9..f3fd65b1884 100644 --- a/lldb/test/python_api/sbdata/TestSBData.py +++ b/lldb/test/python_api/sbdata/TestSBData.py @@ -11,42 +11,16 @@ class SBDataAPICase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_and_run_command(self): - """Test the SBData APIs.""" - self.buildDsym() - self.data_api() - - @python_api_test - @dwarf_test - def test_with_dwarf_and_run_command(self): - """Test the SBData APIs.""" - self.buildDwarf() - self.data_api() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to break on inside main.cpp. self.line = line_number('main.cpp', '// set breakpoint here') - def assert_data(self, func, arg, expected): - """ Asserts func(SBError error, arg) == expected. """ - error = lldb.SBError() - result = func(error, arg) - if not error.Success(): - stream = lldb.SBStream() - error.GetDescription(stream) - self.assertTrue(error.Success(), - "%s(error, %s) did not succeed: %s" % (func.__name__, - arg, - stream.GetData())) - self.assertTrue(expected == result, "%s(error, %s) == %s != %s" % (func.__name__, arg, result, expected)) - - def data_api(self): + @python_api_test + def test_with_run_command(self): """Test the SBData APIs.""" + self.build() self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_file_and_line (self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True) @@ -357,6 +331,19 @@ class SBDataAPICase(TestBase): self.assertTrue( fabs(data2.double[1] - 6.28) < 0.5, 'read_data_helper failure: set double data2[1] = 6.28') self.assertTrue( fabs(data2.double[2] - 2.71) < 0.5, 'read_data_helper failure: set double data2[2] = 2.71') + def assert_data(self, func, arg, expected): + """ Asserts func(SBError error, arg) == expected. """ + error = lldb.SBError() + result = func(error, arg) + if not error.Success(): + stream = lldb.SBStream() + error.GetDescription(stream) + self.assertTrue(error.Success(), + "%s(error, %s) did not succeed: %s" % (func.__name__, + arg, + stream.GetData())) + self.assertTrue(expected == result, "%s(error, %s) == %s != %s" % (func.__name__, arg, result, expected)) + if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/python_api/sbvalue_persist/TestSBValuePersist.py b/lldb/test/python_api/sbvalue_persist/TestSBValuePersist.py index 165129fe1ce..a5881db1877 100644 --- a/lldb/test/python_api/sbvalue_persist/TestSBValuePersist.py +++ b/lldb/test/python_api/sbvalue_persist/TestSBValuePersist.py @@ -10,30 +10,12 @@ class SBValuePersistTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Test SBValue::Persist""" - self.buildDsym() - self.setTearDownCleanup() - self.doTest() - @python_api_test @expectedFailureWindows("llvm.org/pr24772") - @dwarf_test - def test_with_dwarf(self): + def test(self): """Test SBValue::Persist""" - self.buildDwarf() + self.build() self.setTearDownCleanup() - self.doTest() - - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - - def doTest(self): - """Test SBValue::Persist""" self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_source_regexp (self, "break here") diff --git a/lldb/test/python_api/section/TestSectionAPI.py b/lldb/test/python_api/section/TestSectionAPI.py index 6c7b4f53ea7..10870a89f0a 100755 --- a/lldb/test/python_api/section/TestSectionAPI.py +++ b/lldb/test/python_api/section/TestSectionAPI.py @@ -9,40 +9,16 @@ class SectionAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin @python_api_test - @dsym_test - def test_get_target_byte_size_with_dsym(self): - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('a.out') - - # find the .data section of the main module - data_section = self.find_data_section(target) - - self.assertEquals(data_section.target_byte_size, 1) - - @python_api_test - @dwarf_test - def test_get_target_byte_size_with_dwarf(self): + def test_get_target_byte_size(self): d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('b.out') - - # find the .data section of the main module - data_section = self.find_data_section(target) - - self.assertEquals(data_section.target_byte_size, 1) - - def create_simple_target(self, fn): - exe = os.path.join(os.getcwd(), fn) + exe = os.path.join(os.getcwd(), 'b.out') target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) - return target - def find_data_section(self, target): + # find the .data section of the main module mod = target.GetModuleAtIndex(0) data_section = None for s in mod.sections: @@ -59,9 +35,8 @@ class SectionAPITestCase(TestBase): break self.assertIsNotNone(data_section) - return data_section + self.assertEquals(data_section.target_byte_size, 1) - if __name__ == '__main__': import atexit lldb.SBDebugger.Initialize() diff --git a/lldb/test/python_api/signals/TestSignalsAPI.py b/lldb/test/python_api/signals/TestSignalsAPI.py index 7474f431344..f8c3db8e79b 100644 --- a/lldb/test/python_api/signals/TestSignalsAPI.py +++ b/lldb/test/python_api/signals/TestSignalsAPI.py @@ -16,7 +16,7 @@ class SignalsAPITestCase(TestBase): @skipIfWindows # Windows doesn't have signals def test_ignore_signal(self): """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" - self.buildDefault() + self.build() exe = os.path.join(os.getcwd(), "a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) diff --git a/lldb/test/python_api/symbol-context/TestSymbolContext.py b/lldb/test/python_api/symbol-context/TestSymbolContext.py index 5cf3e686733..a92315e71c3 100644 --- a/lldb/test/python_api/symbol-context/TestSymbolContext.py +++ b/lldb/test/python_api/symbol-context/TestSymbolContext.py @@ -12,30 +12,17 @@ class SymbolContextAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Exercise SBSymbolContext API extensively.""" - self.buildDsym() - self.symbol_context() - - @python_api_test - @dwarf_test - @expectedFailureWindows("llvm.org/pr24778") - def test_with_dwarf(self): - """Exercise SBSymbolContext API extensively.""" - self.buildDwarf() - self.symbol_context() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) # Find the line number to of function 'c'. self.line = line_number('main.c', '// Find the line number of function "c" here.') - def symbol_context(self): - """Get an SBSymbolContext object and call its many methods.""" + @python_api_test + @expectedFailureWindows("llvm.org/pr24778") + def test(self): + """Exercise SBSymbolContext API extensively.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/target/TestTargetAPI.py b/lldb/test/python_api/target/TestTargetAPI.py index 8163440cc4a..a9f3590123a 100644 --- a/lldb/test/python_api/target/TestTargetAPI.py +++ b/lldb/test/python_api/target/TestTargetAPI.py @@ -12,15 +12,13 @@ class TargetAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_find_global_variables_with_dsym(self): - """Exercise SBTaget.FindGlobalVariables() API.""" - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.find_global_variables('a.out') + def setUp(self): + # Call super's setUp(). + TestBase.setUp(self) + # Find the line number to of function 'c'. + self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.') + self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.') + self.line_main = line_number("main.c", "// Set a break at entry to main.") #rdar://problem/9700873 # Find global variable value fails for dwarf if inferior not started @@ -30,185 +28,95 @@ class TargetAPITestCase(TestBase): # the inferior process does not exist yet. The radar has been updated. #@unittest232.skip("segmentation fault -- skipping") @python_api_test - @dwarf_test - def test_find_global_variables_with_dwarf(self): + def test_find_global_variables(self): """Exercise SBTarget.FindGlobalVariables() API.""" d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) self.find_global_variables('b.out') - @skipUnlessDarwin @python_api_test - @dsym_test - def test_find_functions_with_dsym(self): - """Exercise SBTaget.FindFunctions() API.""" - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.find_functions('a.out') - - @python_api_test - @dwarf_test @expectedFailureWindows("llvm.org/pr24778") - def test_find_functions_with_dwarf(self): + def test_find_functions(self): """Exercise SBTarget.FindFunctions() API.""" d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) self.find_functions('b.out') - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_get_description_with_dsym(self): - """Exercise SBTaget.GetDescription() API.""" - self.buildDsym() - self.get_description() - @python_api_test - @dwarf_test - def test_get_description_with_dwarf(self): + def test_get_description(self): """Exercise SBTarget.GetDescription() API.""" - self.buildDwarf() + self.build() self.get_description() - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_launch_new_process_and_redirect_stdout_with_dsym(self): - """Exercise SBTaget.Launch() API.""" - self.buildDsym() - self.launch_new_process_and_redirect_stdout() - @python_api_test - @dwarf_test - def test_launch_new_process_and_redirect_stdout_with_dwarf(self): + def test_launch_new_process_and_redirect_stdout(self): """Exercise SBTarget.Launch() API.""" - self.buildDwarf() + self.build() self.launch_new_process_and_redirect_stdout() - @skipUnlessDarwin @python_api_test - @dsym_test - def test_resolve_symbol_context_with_address_with_dsym(self): - """Exercise SBTaget.ResolveSymbolContextForAddress() API.""" - self.buildDsym() - self.resolve_symbol_context_with_address() - - @python_api_test - @dwarf_test - def test_resolve_symbol_context_with_address_with_dwarf(self): + def test_resolve_symbol_context_with_address(self): """Exercise SBTarget.ResolveSymbolContextForAddress() API.""" - self.buildDwarf() + self.build() self.resolve_symbol_context_with_address() - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_get_platform_with_dsym(self): - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('a.out') - platform = target.platform - self.assertTrue(platform, VALID_PLATFORM) - @python_api_test - @dwarf_test - def test_get_platform_with_dwarf(self): + def test_get_platform(self): d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.create_simple_target('b.out') platform = target.platform self.assertTrue(platform, VALID_PLATFORM) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_get_data_byte_size_with_dsym(self): - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('a.out') - self.assertEquals(target.data_byte_size, 1) - @python_api_test - @dwarf_test - def test_get_data_byte_size_with_dwarf(self): + def test_get_data_byte_size(self): d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.create_simple_target('b.out') self.assertEquals(target.data_byte_size, 1) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_get_code_byte_size_with_dsym(self): - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('a.out') - self.assertEquals(target.code_byte_size, 1) - @python_api_test - @dwarf_test - def test_get_code_byte_size_with_dwarf(self): + def test_get_code_byte_size(self): d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.create_simple_target('b.out') self.assertEquals(target.code_byte_size, 1) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_resolve_file_address_with_dsym(self): - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('a.out') - self.resolve_file_address(target) - @python_api_test - @dwarf_test - def test_resolve_file_address_with_dwarf(self): + def test_resolve_file_address(self): d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.create_simple_target('b.out') - self.resolve_file_address(target) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_read_memory_with_dsym(self): - d = {'EXE': 'a.out'} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - target = self.create_simple_target('a.out') - self.read_memory(target) + # find the file address in the .data section of the main + # module + data_section = self.find_data_section(target) + data_section_addr = data_section.file_addr + + # resolve the above address, and compare the address produced + # by the resolution against the original address/section + res_file_addr = target.ResolveFileAddress(data_section_addr) + self.assertTrue(res_file_addr.IsValid()) + + self.assertEquals(data_section_addr, res_file_addr.file_addr) + + data_section2 = res_file_addr.section + self.assertIsNotNone(data_section2) + self.assertEquals(data_section.name, data_section2.name) @python_api_test - @dwarf_test - def test_read_memory_with_dwarf(self): + def test_read_memory(self): d = {'EXE': 'b.out'} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) target = self.create_simple_target('b.out') - self.read_memory(target) - def setUp(self): - # Call super's setUp(). - TestBase.setUp(self) - # Find the line number to of function 'c'. - self.line1 = line_number('main.c', '// Find the line number for breakpoint 1 here.') - self.line2 = line_number('main.c', '// Find the line number for breakpoint 2 here.') - self.line_main = line_number("main.c", "// Set a break at entry to main.") - - def read_memory(self, target): breakpoint = target.BreakpointCreateByLocation("main.c", self.line_main) self.assertTrue(breakpoint, VALID_BREAKPOINT) @@ -234,23 +142,6 @@ class TargetAPITestCase(TestBase): self.assertTrue(target, VALID_TARGET) return target - def resolve_file_address(self, target): - # find the file address in the .data section of the main - # module - data_section = self.find_data_section(target) - data_section_addr = data_section.file_addr - - # resolve the above address, and compare the address produced - # by the resolution against the original address/section - res_file_addr = target.ResolveFileAddress(data_section_addr) - self.assertTrue(res_file_addr.IsValid()) - - self.assertEquals(data_section_addr, res_file_addr.file_addr) - - data_section2 = res_file_addr.section - self.assertIsNotNone(data_section2) - self.assertEquals(data_section.name, data_section2.name) - def find_data_section(self, target): mod = target.GetModuleAtIndex(0) data_section = None diff --git a/lldb/test/python_api/thread/TestThreadAPI.py b/lldb/test/python_api/thread/TestThreadAPI.py index d5b146d07ab..8ace950a46e 100644 --- a/lldb/test/python_api/thread/TestThreadAPI.py +++ b/lldb/test/python_api/thread/TestThreadAPI.py @@ -12,98 +12,44 @@ class ThreadAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin @python_api_test - @dsym_test - def test_get_process_with_dsym(self): + def test_get_process(self): """Test Python SBThread.GetProcess() API.""" - self.buildDsym() + self.build() self.get_process() @python_api_test - @dwarf_test - def test_get_process_with_dwarf(self): - """Test Python SBThread.GetProcess() API.""" - self.buildDwarf() - self.get_process() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_get_stop_description_with_dsym(self): + def test_get_stop_description(self): """Test Python SBThread.GetStopDescription() API.""" - self.buildDsym() + self.build() self.get_stop_description() @python_api_test - @dwarf_test - def test_get_stop_description_with_dwarf(self): - """Test Python SBThread.GetStopDescription() API.""" - self.buildDwarf() - self.get_stop_description() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_run_to_address_with_dsym(self): - """Test Python SBThread.RunToAddress() API.""" - # We build a different executable than the default buildDwarf() does. - d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.run_to_address(self.exe_name) - - @python_api_test - @dwarf_test - def test_run_to_address_with_dwarf(self): + def test_run_to_address(self): """Test Python SBThread.RunToAddress() API.""" - # We build a different executable than the default buildDwarf() does. + # We build a different executable than the default build() does. d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) self.run_to_address(self.exe_name) - @skipUnlessDarwin @python_api_test - @dsym_test - def test_step_out_of_malloc_into_function_b_with_dsym(self): - """Test Python SBThread.StepOut() API to step out of a malloc call where the call site is at function b().""" - # We build a different executable than the default buildDsym() does. - d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.step_out_of_malloc_into_function_b(self.exe_name) - @expectedFailureFreeBSD # llvm.org/pr20476 - @python_api_test @expectedFailureWindows # Test crashes - @dwarf_test - def test_step_out_of_malloc_into_function_b_with_dwarf(self): + def test_step_out_of_malloc_into_function_b(self): """Test Python SBThread.StepOut() API to step out of a malloc call where the call site is at function b().""" - # We build a different executable than the default buildDwarf() does. + # We build a different executable than the default build() does. d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) self.step_out_of_malloc_into_function_b(self.exe_name) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_step_over_3_times_with_dsym(self): - """Test Python SBThread.StepOver() API.""" - # We build a different executable than the default buildDsym() does. - d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.step_over_3_times(self.exe_name) - @python_api_test - @dwarf_test - def test_step_over_3_times_with_dwarf(self): + def test_step_over_3_times(self): """Test Python SBThread.StepOver() API.""" - # We build a different executable than the default buildDwarf() does. + # We build a different executable than the default build() does. d = {'CXX_SOURCES': 'main2.cpp', 'EXE': self.exe_name} - self.buildDwarf(dictionary=d) + self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) self.step_over_3_times(self.exe_name) diff --git a/lldb/test/python_api/type/TestTypeList.py b/lldb/test/python_api/type/TestTypeList.py index 19f178e0f05..f790f5f6eee 100644 --- a/lldb/test/python_api/type/TestTypeList.py +++ b/lldb/test/python_api/type/TestTypeList.py @@ -12,25 +12,6 @@ class TypeAndTypeListTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Exercise SBType and SBTypeList API.""" - d = {'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.type_and_typelist_api(self.exe_name) - - @python_api_test - @dwarf_test - def test_with_dwarf(self): - """Exercise SBType and SBTypeList API.""" - d = {'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.type_and_typelist_api(self.exe_name) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -40,9 +21,13 @@ class TypeAndTypeListTestCase(TestBase): self.source = 'main.cpp' self.line = line_number(self.source, '// Break at this line') - def type_and_typelist_api(self, exe_name): + @python_api_test + def test(self): """Exercise SBType and SBTypeList API.""" - exe = os.path.join(os.getcwd(), exe_name) + d = {'EXE': self.exe_name} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + exe = os.path.join(os.getcwd(), self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/value/TestValueAPI.py b/lldb/test/python_api/value/TestValueAPI.py index 7c5443d3f62..3c67d69e225 100644 --- a/lldb/test/python_api/value/TestValueAPI.py +++ b/lldb/test/python_api/value/TestValueAPI.py @@ -12,26 +12,6 @@ class ValueAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Exercise some SBValue APIs.""" - d = {'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.value_api(self.exe_name) - - @expectedFailureWindows("llvm.org/pr24772") - @python_api_test - @dwarf_test - def test_with_dwarf(self): - """Exercise some SBValue APIs.""" - d = {'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.value_api(self.exe_name) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -40,9 +20,14 @@ class ValueAPITestCase(TestBase): # Find the line number to of function 'c'. self.line = line_number('main.c', '// Break at this line') - def value_api(self, exe_name): + @expectedFailureWindows("llvm.org/pr24772") + @python_api_test + def test(self): """Exercise some SBValue APIs.""" - exe = os.path.join(os.getcwd(), exe_name) + d = {'EXE': self.exe_name} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + exe = os.path.join(os.getcwd(), self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/value/change_values/TestChangeValueAPI.py b/lldb/test/python_api/value/change_values/TestChangeValueAPI.py index e5d2c5ab754..dd30c9d4087 100644 --- a/lldb/test/python_api/value/change_values/TestChangeValueAPI.py +++ b/lldb/test/python_api/value/change_values/TestChangeValueAPI.py @@ -12,26 +12,6 @@ class ChangeValueAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_change_value_with_dsym(self): - """Exercise the SBValue::SetValueFromCString API.""" - d = {'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.change_value_api(self.exe_name) - - @expectedFailureWindows("llvm.org/pr24772") - @python_api_test - @dwarf_test - def test_change_value_with_dwarf(self): - """Exercise the SBValue::SetValueFromCString API.""" - d = {'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.change_value_api(self.exe_name) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -42,9 +22,14 @@ class ChangeValueAPITestCase(TestBase): self.check_line = line_number('main.c', '// Stop here and check values') self.end_line = line_number ('main.c', '// Set a breakpoint here at the end') - def change_value_api(self, exe_name): - """Exercise some SBValue APIs.""" - exe = os.path.join(os.getcwd(), exe_name) + @expectedFailureWindows("llvm.org/pr24772") + @python_api_test + def test_change_value(self): + """Exercise the SBValue::SetValueFromCString API.""" + d = {'EXE': self.exe_name} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + exe = os.path.join(os.getcwd(), self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py b/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py index 6a1224bc106..2329c96fe61 100644 --- a/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py +++ b/lldb/test/python_api/value/linked_list/TestValueAPILinkedList.py @@ -13,25 +13,6 @@ class ValueAsLinkedListTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym(self): - """Exercise SBValue API linked_list_iter.""" - d = {'EXE': self.exe_name} - self.buildDsym(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.linked_list_api(self.exe_name) - - @python_api_test - @dwarf_test - def test_with_dwarf(self): - """Exercise SBValue API linked_list_iter.""" - d = {'EXE': self.exe_name} - self.buildDwarf(dictionary=d) - self.setTearDownCleanup(dictionary=d) - self.linked_list_api(self.exe_name) - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -40,9 +21,13 @@ class ValueAsLinkedListTestCase(TestBase): # Find the line number to break at. self.line = line_number('main.cpp', '// Break at this line') - def linked_list_api(self, exe_name): - """Exercise SBValue API linked_list-iter.""" - exe = os.path.join(os.getcwd(), exe_name) + @python_api_test + def test(self): + """Exercise SBValue API linked_list_iter.""" + d = {'EXE': self.exe_name} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + exe = os.path.join(os.getcwd(), self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/lldb/test/python_api/value_var_update/TestValueVarUpdate.py b/lldb/test/python_api/value_var_update/TestValueVarUpdate.py index 8c597bc9c38..76d4d64b542 100644 --- a/lldb/test/python_api/value_var_update/TestValueVarUpdate.py +++ b/lldb/test/python_api/value_var_update/TestValueVarUpdate.py @@ -10,23 +10,6 @@ class HelloWorldTestCase(TestBase): mydir = TestBase.compute_mydir(__file__) - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_with_dsym_and_process_launch_api(self): - """Test SBValue::GetValueDidChange""" - self.buildDsym(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.do_test() - - @python_api_test - @dwarf_test - def test_with_dwarf_and_process_launch_api(self): - """Test SBValue::GetValueDidChange""" - self.buildDwarf(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.do_test() - def setUp(self): # Call super's setUp(). TestBase.setUp(self) @@ -34,9 +17,11 @@ class HelloWorldTestCase(TestBase): self.exe = os.path.join(os.getcwd(), self.testMethodName) self.d = {'EXE': self.testMethodName} - def do_test(self): - """Create target, breakpoint, launch a process, and then kill it.""" - + @python_api_test + def test_with_process_launch_api(self): + """Test SBValue::GetValueDidChange""" + self.build(dictionary=self.d) + self.setTearDownCleanup(dictionary=self.d) target = self.dbg.CreateTarget(self.exe) breakpoint = target.BreakpointCreateBySourceRegex("break here", lldb.SBFileSpec("main.c")) diff --git a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py index 1fd4d441ccd..9e464ad363a 100644 --- a/lldb/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/lldb/test/python_api/watchpoint/TestSetWatchpoint.py @@ -20,25 +20,12 @@ class SetWatchpointAPITestCase(TestBase): # Find the line number to break inside main(). self.line = line_number(self.source, '// Set break point at this line.') - @skipUnlessDarwin @python_api_test - @dsym_test - def test_watch_val_with_dsym(self): - """Exercise SBValue.Watch() API to set a watchpoint.""" - self.buildDsym() - self.do_set_watchpoint() - - @python_api_test - @dwarf_test @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows - def test_watch_val_with_dwarf(self): + def test_watch_val(self): """Exercise SBValue.Watch() API to set a watchpoint.""" - self.buildDwarf() - self.do_set_watchpoint() - - def do_set_watchpoint(self): - """Use SBFrame.WatchValue() to set a watchpoint and verify that the program stops later due to the watchpoint.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index c58f2fd3e88..6b4197b3d48 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -20,25 +20,12 @@ class WatchpointIgnoreCountTestCase(TestBase): # Find the line number to break inside main(). self.line = line_number(self.source, '// Set break point at this line.') - @skipUnlessDarwin @python_api_test - @dsym_test - def test_set_watch_ignore_count_with_dsym(self): - """Test SBWatchpoint.SetIgnoreCount() API.""" - self.buildDsym() - self.do_watchpoint_ignore_count() - - @python_api_test - @dwarf_test @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows - def test_set_watch_ignore_count_with_dwarf(self): - """Test SBWatchpoint.SetIgnoreCount() API.""" - self.buildDwarf() - self.do_watchpoint_ignore_count() - - def do_watchpoint_ignore_count(self): + def test_set_watch_ignore_count(self): """Test SBWatchpoint.SetIgnoreCount() API.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/watchpoint/TestWatchpointIter.py b/lldb/test/python_api/watchpoint/TestWatchpointIter.py index ea202a55b25..8a6877930ee 100644 --- a/lldb/test/python_api/watchpoint/TestWatchpointIter.py +++ b/lldb/test/python_api/watchpoint/TestWatchpointIter.py @@ -20,25 +20,12 @@ class WatchpointIteratorTestCase(TestBase): # Find the line number to break inside main(). self.line = line_number(self.source, '// Set break point at this line.') - @skipUnlessDarwin @python_api_test - @dsym_test - def test_watch_iter_with_dsym(self): - """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" - self.buildDsym() - self.do_watchpoint_iter() - - @python_api_test - @dwarf_test @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows - def test_watch_iter_with_dwarf(self): + def test_watch_iter(self): """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" - self.buildDwarf() - self.do_watchpoint_iter() - - def do_watchpoint_iter(self): - """Use SBTarget.watchpoint_iter() to do Pythonic iteration on the available watchpoints.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index d643c8c5ee4..a1c0ce00bad 100644 --- a/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/lldb/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -25,25 +25,12 @@ class WatchpointConditionAPITestCase(TestBase): self.exe_name = self.testMethodName self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name} - @skipUnlessDarwin - @dsym_test - def test_watchpoint_cond_api_with_dsym(self): - """Test watchpoint condition API.""" - self.buildDsym(dictionary=self.d) - self.setTearDownCleanup(dictionary=self.d) - self.watchpoint_condition_api() - - @dwarf_test @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows - def test_watchpoint_cond_api_with_dwarf(self): + def test_watchpoint_cond_api(self): """Test watchpoint condition API.""" - self.buildDwarf(dictionary=self.d) + self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - self.watchpoint_condition_api() - - def watchpoint_condition_api(self): - """Do watchpoint condition API to set condition as 'global==5'.""" exe = os.path.join(os.getcwd(), self.exe_name) # Create a target by the debugger. diff --git a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index b6db8280c0e..9830dd19777 100644 --- a/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/lldb/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -22,25 +22,12 @@ class SetWatchlocationAPITestCase(TestBase): # This is for verifying that watch location works. self.violating_func = "do_bad_thing_with_location"; - @skipUnlessDarwin @python_api_test - @dsym_test - def test_watch_location_with_dsym(self): - """Exercise SBValue.WatchPointee() API to set a watchpoint.""" - self.buildDsym() - self.do_set_watchlocation() - - @python_api_test - @dwarf_test @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @expectedFailureWindows("llvm.org/pr24446") # WINDOWS XFAIL TRIAGE - Watchpoints not supported on Windows - def test_watch_location_with_dwarf(self): + def test_watch_location(self): """Exercise SBValue.WatchPointee() API to set a watchpoint.""" - self.buildDwarf() - self.do_set_watchlocation() - - def do_set_watchlocation(self): - """Use SBValue.WatchPointee() to set a watchpoint and verify that the program stops later due to the watchpoint.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. diff --git a/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index 2cb2f3889eb..d7635ae93c3 100644 --- a/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/lldb/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -22,41 +22,12 @@ class TargetWatchAddressAPITestCase(TestBase): # This is for verifying that watch location works. self.violating_func = "do_bad_thing_with_location"; - @skipUnlessDarwin @python_api_test - @dsym_test - def test_watch_address_with_dsym(self): - """Exercise SBTarget.WatchAddress() API to set a watchpoint.""" - self.buildDsym() - self.do_set_watchaddress() - - @python_api_test - @dwarf_test @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported @expectedFailureWindows("llvm.org/pr24446") - def test_watch_address_with_dwarf(self): + def test_watch_address(self): """Exercise SBTarget.WatchAddress() API to set a watchpoint.""" - self.buildDwarf() - self.do_set_watchaddress() - - @skipUnlessDarwin - @python_api_test - @dsym_test - def test_watch_address_with_invalid_watch_size_with_dsym(self): - """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" - self.buildDsym() - self.do_set_watchaddress_with_invalid_watch_size() - - @python_api_test - @dwarf_test - @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported - def test_watch_address_with_invalid_watch_size_with_dwarf(self): - """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" - self.buildDwarf() - self.do_set_watchaddress_with_invalid_watch_size() - - def do_set_watchaddress(self): - """Use SBTarget.WatchAddress() to set a watchpoint and verify that the program stops later due to the watchpoint.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. @@ -114,8 +85,11 @@ class TargetWatchAddressAPITestCase(TestBase): # This finishes our test. - def do_set_watchaddress_with_invalid_watch_size(self): - """Use SBTarget.WatchAddress() to set a watchpoint with invalid watch_size and verify we get a meaningful error message.""" + @python_api_test + @expectedFailureAndroid(archs=['arm', 'aarch64']) # Watchpoints not supported + def test_watch_address_with_invalid_watch_size(self): + """Exercise SBTarget.WatchAddress() API but pass an invalid watch_size.""" + self.build() exe = os.path.join(os.getcwd(), "a.out") # Create a target by the debugger. |