diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2018-07-28 11:09:23 +0000 |
commit | f73363f1dd94996356cefbf24388f561891acf0b (patch) | |
tree | e3c31248bdb36eaec5fd833490d4278162dba2a0 /packages/Python/lldbsuite/test/python_api | |
parent | 160ee69dd7ae18978f4068116777639ea98dc951 (diff) |
Notes
Diffstat (limited to 'packages/Python/lldbsuite/test/python_api')
46 files changed, 241 insertions, 129 deletions
diff --git a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py index 4bd4781c7ef51..5e21471e7c15f 100644 --- a/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py +++ b/packages/Python/lldbsuite/test/python_api/breakpoint/TestBreakpointAPI.py @@ -23,7 +23,7 @@ class BreakpointAPITestCase(TestBase): def test_breakpoint_is_valid(self): """Make sure that if an SBBreakpoint gets deleted its IsValid returns false.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -57,7 +57,7 @@ class BreakpointAPITestCase(TestBase): Breakpoint's IsValid returns false.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py b/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py index a9e896f2579f8..074bbc76fd19a 100644 --- a/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py +++ b/packages/Python/lldbsuite/test/python_api/class_members/TestSBTypeClassMembers.py @@ -34,7 +34,7 @@ class SBTypeMemberFunctionsTest(TestBase): d = {'EXE': self.exe_name} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py index 97261c70ec969..deb0c7a9fcbb4 100644 --- a/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py +++ b/packages/Python/lldbsuite/test/python_api/disassemble-raw-data/TestDisassembleRawData.py @@ -31,6 +31,9 @@ class DisassembleRawDataTestCase(TestBase): elif re.match("mips", arch): target = self.dbg.CreateTargetWithFileAndTargetTriple("", "mips") raw_bytes = bytearray([0x03, 0xa0, 0xf0, 0x21]) + elif re.match("powerpc64le", arch): + target = self.dbg.CreateTargetWithFileAndTargetTriple("", "powerpc64le") + raw_bytes = bytearray([0x00, 0x00, 0x80, 0x38]) else: target = self.dbg.CreateTargetWithFileAndTargetTriple("", "x86_64") raw_bytes = bytearray([0x48, 0x89, 0xe5]) @@ -48,6 +51,9 @@ class DisassembleRawDataTestCase(TestBase): self.assertTrue(inst.GetMnemonic(target) == "move") self.assertTrue(inst.GetOperands(target) == '$' + "fp, " + '$' + "sp") + elif re.match("powerpc64le", arch): + self.assertTrue(inst.GetMnemonic(target) == "li") + self.assertTrue(inst.GetOperands(target) == "4, 0") else: self.assertTrue(inst.GetMnemonic(target) == "movq") self.assertTrue(inst.GetOperands(target) == diff --git a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py index e9ea0bd008795..8a9e456f3458d 100644 --- a/packages/Python/lldbsuite/test/python_api/event/TestEvents.py +++ b/packages/Python/lldbsuite/test/python_api/event/TestEvents.py @@ -15,6 +15,7 @@ from lldbsuite.test import lldbutil @skipIfLinux # llvm.org/pr25924, sometimes generating SIGSEGV +@skipIfDarwin class EventAPITestCase(TestBase): mydir = TestBase.compute_mydir(__file__) @@ -33,7 +34,7 @@ class EventAPITestCase(TestBase): def test_listen_for_and_print_event(self): """Exercise SBEvent API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(True) @@ -122,7 +123,7 @@ class EventAPITestCase(TestBase): def test_wait_for_event(self): """Exercise SBListener.WaitForEvent() API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(True) @@ -201,7 +202,7 @@ class EventAPITestCase(TestBase): def test_add_listener_to_broadcaster(self): """Exercise some SBBroadcaster APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.dbg.SetAsync(True) diff --git a/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py b/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py index 0a0ac2d057704..c066dc58003d9 100644 --- a/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py +++ b/packages/Python/lldbsuite/test/python_api/findvalue_duplist/TestSBFrameFindValue.py @@ -22,8 +22,7 @@ class SBFrameFindValueTestCase(TestBase): self.build() self.setTearDownCleanup() - exe_name = "a.out" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact("a.out") # Create the target target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py b/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py index 667bd58adcee0..8548506fdc463 100644 --- a/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py +++ b/packages/Python/lldbsuite/test/python_api/formatters/TestFormattersSBAPI.py @@ -28,10 +28,12 @@ class SBFormattersAPITestCase(TestBase): self.setTearDownCleanup() """Test Python APIs for working with formatters""" - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("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) + self, "main.cpp", self.line, num_expected_locations=1, + loc_exact=True) self.runCmd("run", RUN_SUCCEEDED) @@ -439,7 +441,8 @@ class SBFormattersAPITestCase(TestBase): self.build(dictionary={'EXE': 'no_synth'}) self.setTearDownCleanup() - self.runCmd("file no_synth", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("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/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py index a2d2cf12cdca0..85e915ad3a48a 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py +++ b/packages/Python/lldbsuite/test/python_api/frame/TestFrames.py @@ -24,7 +24,7 @@ class FrameAPITestCase(TestBase): def test_get_arg_vals_for_call_stack(self): """Exercise SBFrame.GetVariables() API to get argument vals.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -127,7 +127,7 @@ class FrameAPITestCase(TestBase): def test_frame_api_boundary_condition(self): """Exercise SBFrame APIs with boundary condition inputs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -169,7 +169,7 @@ class FrameAPITestCase(TestBase): def test_frame_api_IsEqual(self): """Exercise SBFrame API IsEqual.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py b/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py index 86585d8d02e22..1bd54c39fa0b1 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py +++ b/packages/Python/lldbsuite/test/python_api/frame/get-variables/TestGetVariables.py @@ -51,7 +51,7 @@ class TestGetVariables(TestBase): self.dbg.SetAsync(False) # Create a target by the debugger. - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py b/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py index caa2696be7cdb..8b8f81ff4c4b4 100644 --- a/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py +++ b/packages/Python/lldbsuite/test/python_api/frame/inlines/TestInlinedFrame.py @@ -32,7 +32,7 @@ class InlinedFrameAPITestCase(TestBase): def test_stop_at_outer_inline(self): """Exercise SBFrame.IsInlined() and SBFrame.GetFunctionName().""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py index 4511da94437bb..f657d19764ba8 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestDisasmAPI.py @@ -28,10 +28,11 @@ class DisasmAPITestCase(TestBase): 'main.c', '// Find the line number for breakpoint 2 here.') @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test(self): """Exercise getting SBAddress objects, disassembly, and SBAddress APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py index 9919375abb59a..6644b81ef2a9d 100644 --- a/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py +++ b/packages/Python/lldbsuite/test/python_api/function_symbol/TestSymbolAPI.py @@ -28,10 +28,11 @@ class SymbolAPITestCase(TestBase): 'main.c', '// Find the line number for breakpoint 2 here.') @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test(self): """Exercise some SBSymbol and SBAddress APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py index fb4e54aa0bc56..b0f09d2fa7b5a 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py +++ b/packages/Python/lldbsuite/test/python_api/hello_world/TestHelloWorld.py @@ -14,15 +14,12 @@ from lldbsuite.test import lldbutil class HelloWorldTestCase(TestBase): - + NO_DEBUG_INFO_TESTCASE = True mydir = TestBase.compute_mydir(__file__) def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Get the full path to our executable to be attached/debugged. - self.exe = os.path.join(os.getcwd(), self.testMethodName) - self.d = {'EXE': self.testMethodName} # Find a couple of the line numbers within main.c. self.line1 = line_number('main.c', '// Set break point at this line.') self.line2 = line_number('main.c', '// Waiting to be attached...') @@ -37,9 +34,12 @@ class HelloWorldTestCase(TestBase): @skipIfiOSSimulator 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) + # Get the full path to our executable to be attached/debugged. + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateByLocation("main.c", self.line1) @@ -82,12 +82,14 @@ class HelloWorldTestCase(TestBase): @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails 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) + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) # Spawn a new process - popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) + popen = self.spawnSubprocess(exe, ["abc", "xyz"]) self.addTearDownHook(self.cleanupSubprocesses) # Give the subprocess time to start and wait for user input @@ -112,12 +114,14 @@ class HelloWorldTestCase(TestBase): @expectedFailureAll(oslist=['ios', 'watchos', 'tvos', 'bridgeos'], bugnumber="<rdar://problem/34538611>") # old lldb-server has race condition, launching an inferior and then launching debugserver in quick succession sometimes fails 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) + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) # Spawn a new process - popen = self.spawnSubprocess(self.exe, ["abc", "xyz"]) + popen = self.spawnSubprocess(exe, ["abc", "xyz"]) self.addTearDownHook(self.cleanupSubprocesses) # Give the subprocess time to start and wait for user input @@ -127,7 +131,7 @@ class HelloWorldTestCase(TestBase): error = lldb.SBError() # Pass 'False' since we don't want to wait for new instance of # "hello_world" to be launched. - name = os.path.basename(self.exe) + name = os.path.basename(exe) # While we're at it, make sure that passing a None as the process name # does not hang LLDB. diff --git a/packages/Python/lldbsuite/test/python_api/hello_world/main.c b/packages/Python/lldbsuite/test/python_api/hello_world/main.c index 001e9c01e6e5e..32b0446517c54 100644 --- a/packages/Python/lldbsuite/test/python_api/hello_world/main.c +++ b/packages/Python/lldbsuite/test/python_api/hello_world/main.c @@ -1,5 +1,11 @@ #include <stdio.h> +#ifdef _MSC_VER +#include <windows.h> +#define sleep(x) Sleep((x) * 1000) +#else #include <unistd.h> +#endif + int main(int argc, char const *argv[]) { lldb_enable_attach(); diff --git a/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py b/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py index 7f5781f5cd8e1..2f31b0aebaa26 100644 --- a/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py +++ b/packages/Python/lldbsuite/test/python_api/interpreter/TestCommandInterpreterAPI.py @@ -24,7 +24,7 @@ class CommandInterpreterAPICase(TestBase): def test_with_process_launch_api(self): """Test the SBCommandInterpreter APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py index bcbaa68ed9280..4db6322e75134 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/frame/TestFrameUtils.py @@ -27,7 +27,7 @@ class FrameUtilsTestCase(TestBase): def test_frame_utils(self): """Test utility functions for the frame object.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py index ae7ec3dfc3ccc..6816b0d1ee953 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestLLDBIterator.py @@ -30,7 +30,7 @@ class LLDBIteratorTestCase(TestBase): def test_lldb_iter_module(self): """Test module_iter works correctly for SBTarget -> SBModule.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -66,7 +66,7 @@ class LLDBIteratorTestCase(TestBase): def test_lldb_iter_breakpoint(self): """Test breakpoint_iter works correctly for SBTarget -> SBBreakpoint.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -98,7 +98,7 @@ class LLDBIteratorTestCase(TestBase): def test_lldb_iter_frame(self): """Test iterator works correctly for SBProcess->SBThread->SBFrame.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py index a19cc5c375f5a..bd46749d6e648 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/iter/TestRegistersIterator.py @@ -30,7 +30,7 @@ class RegistersIteratorTestCase(TestBase): def test_iter_registers(self): """Test iterator works correctly for lldbutil.iter_registers().""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py index b447bb797a0fc..dcdade25d46f7 100644 --- a/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py +++ b/packages/Python/lldbsuite/test/python_api/lldbutil/process/TestPrintStackTraces.py @@ -37,7 +37,7 @@ class ThreadsStackTracesTestCase(TestBase): def test_stack_traces(self): """Test SBprocess and SBThread APIs with printing of the stack traces.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py index 79b988465d7e3..65b159974c085 100644 --- a/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py +++ b/packages/Python/lldbsuite/test/python_api/module_section/TestModuleAndSection.py @@ -26,7 +26,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): def test_module_and_section(self): """Test module and section APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -77,7 +77,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): 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") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -118,7 +118,7 @@ class ModuleAndSectionAPIsTestCase(TestBase): def test_module_compile_unit_iter(self): """Test module's compile unit iterator APIs.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -141,3 +141,29 @@ class ModuleAndSectionAPIsTestCase(TestBase): INDENT2 = INDENT * 2 for cu in exe_module.compile_unit_iter(): print(cu) + + @add_test_categories(['pyapi']) + def test_find_compile_units(self): + """Exercise SBModule.FindCompileUnits() API.""" + d = {'EXE': 'b.out'} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.find_compile_units(self.getBuildArtifact('b.out')) + + def find_compile_units(self, exe): + """Exercise SBModule.FindCompileUnits() API.""" + source_name_list = ["main.cpp", "b.cpp", "c.cpp"] + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + num_modules = target.GetNumModules() + for i in range(num_modules): + module = target.GetModuleAtIndex(i) + for source_name in source_name_list: + list = module.FindCompileUnits(lldb.SBFileSpec(source_name, False)) + for sc in list: + self.assertTrue( + sc.GetCompileUnit().GetFileSpec().GetFilename() == + source_name) diff --git a/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py index b7a683f25f623..6511ff865bd93 100644 --- a/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py +++ b/packages/Python/lldbsuite/test/python_api/name_lookup/TestNameLookup.py @@ -20,6 +20,7 @@ class TestNameLookup(TestBase): mydir = TestBase.compute_mydir(__file__) @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test_target(self): """Exercise SBTarget.FindFunctions() with various name masks. @@ -28,7 +29,7 @@ class TestNameLookup(TestBase): and that using a function basename with eFunctionNameTypeFull works for all C++ functions that are at the global namespace level.""" self.build(); - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py b/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py index 89dfebde1af70..fd3bfa858e125 100644 --- a/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py +++ b/packages/Python/lldbsuite/test/python_api/objc_type/TestObjCType.py @@ -28,7 +28,7 @@ class ObjCSBTypeTestCase(TestBase): def test(self): """Test SBType for ObjC classes.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py index 065c707448909..fc17e4a76c54e 100644 --- a/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py +++ b/packages/Python/lldbsuite/test/python_api/process/TestProcessAPI.py @@ -29,7 +29,7 @@ class ProcessAPITestCase(TestBase): def test_read_memory(self): """Test Python SBProcess.ReadMemory() API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -127,7 +127,7 @@ class ProcessAPITestCase(TestBase): def test_write_memory(self): """Test Python SBProcess.WriteMemory() API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -186,7 +186,7 @@ class ProcessAPITestCase(TestBase): 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") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -284,7 +284,7 @@ class ProcessAPITestCase(TestBase): 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") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -308,7 +308,7 @@ class ProcessAPITestCase(TestBase): 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") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) @@ -331,7 +331,7 @@ class ProcessAPITestCase(TestBase): def test_get_process_info(self): """Test SBProcess::GetProcessInfo() API with a locally launched process.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py b/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py index 71f77b3688096..e25083d6efb29 100644 --- a/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py +++ b/packages/Python/lldbsuite/test/python_api/process/io/TestProcessIO.py @@ -19,11 +19,13 @@ class ProcessIOTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) + + def setup_test(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.exe = self.getBuildArtifact("process_io") + self.local_input_file = self.getBuildArtifact("input.txt") + self.local_output_file = self.getBuildArtifact("output.txt") + self.local_error_file = self.getBuildArtifact("error.txt") self.input_file = os.path.join( self.get_process_working_directory(), "input.txt") @@ -38,6 +40,7 @@ class ProcessIOTestCase(TestBase): @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdin_by_api(self): """Exercise SBProcess.PutSTDIN().""" + self.setup_test() self.build() self.create_target() self.run_process(True) @@ -49,6 +52,7 @@ class ProcessIOTestCase(TestBase): @expectedFlakeyLinux(bugnumber="llvm.org/pr26437") def test_stdin_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDIN without specifying STDOUT or STDERR.""" + self.setup_test() self.build() self.create_target() self.redirect_stdin() @@ -62,6 +66,7 @@ class ProcessIOTestCase(TestBase): @skipIfDarwinEmbedded # debugserver can't create/write files on the device def test_stdout_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT without specifying STDIN or STDERR.""" + self.setup_test() self.build() self.create_target() self.redirect_stdout() @@ -76,6 +81,7 @@ class ProcessIOTestCase(TestBase): @skipIfDarwinEmbedded # debugserver can't create/write files on the device def test_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDERR without specifying STDIN or STDOUT.""" + self.setup_test() self.build() self.create_target() self.redirect_stderr() @@ -90,6 +96,7 @@ class ProcessIOTestCase(TestBase): @skipIfDarwinEmbedded # debugserver can't create/write files on the device def test_stdout_stderr_redirection(self): """Exercise SBLaunchInfo::AddOpenFileAction() for STDOUT and STDERR without redirecting STDIN.""" + self.setup_test() self.build() self.create_target() self.redirect_stdout() diff --git a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py index 6302711606c51..b03cebce48c1a 100644 --- a/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py +++ b/packages/Python/lldbsuite/test/python_api/process/read-mem-cstring/TestReadMemCString.py @@ -17,17 +17,19 @@ class TestReadMemCString(TestBase): def test_read_memory_c_string(self): """Test corner case behavior of SBProcess::ReadCStringFromMemory""" self.build() - self.dbg.SetAsync(False) + self.dbg.SetAsync(False) self.main_source = "main.c" - self.main_source_spec = lldb.SBFileSpec(self.main_source) - self.exe = os.path.join(os.getcwd(), "read-mem-cstring") + self.main_source_path = os.path.join(self.getSourceDir(), + self.main_source) + self.main_source_spec = lldb.SBFileSpec(self.main_source_path) + self.exe = self.getBuildArtifact("read-mem-cstring") (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint( self, 'breakpoint here', self.main_source_spec, None, self.exe) - frame = thread.GetFrameAtIndex(0) - + frame = thread.GetFrameAtIndex(0) + err = lldb.SBError() empty_str_addr = frame.FindVariable("empty_string").GetValueAsUnsigned(err) diff --git a/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py b/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py index a84d0004c18b8..1d042b69287f5 100644 --- a/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py +++ b/packages/Python/lldbsuite/test/python_api/rdar-12481949/Test-rdar-12481949.py @@ -26,7 +26,7 @@ class Radar12481949DataFormatterTestCase(TestBase): 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) + self.runCmd("file " + self.getBuildArtifact("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/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py index 0560ac502dcf7..a1a400a076b51 100644 --- a/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py +++ b/packages/Python/lldbsuite/test/python_api/sbdata/TestSBData.py @@ -25,7 +25,7 @@ class SBDataAPICase(TestBase): def test_byte_order_and_address_byte_size(self): """Test the SBData::SetData() to ensure the byte order and address byte size are obeyed""" - addr_data = '\x11\x22\x33\x44\x55\x66\x77\x88' + addr_data = b'\x11\x22\x33\x44\x55\x66\x77\x88' error = lldb.SBError() data = lldb.SBData() data.SetData(error, addr_data, lldb.eByteOrderBig, 4) @@ -45,7 +45,7 @@ class SBDataAPICase(TestBase): def test_with_run_command(self): """Test the SBData APIs.""" self.build() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("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/packages/Python/lldbsuite/test/python_api/sblaunchinfo/TestSBLaunchInfo.py b/packages/Python/lldbsuite/test/python_api/sblaunchinfo/TestSBLaunchInfo.py new file mode 100644 index 0000000000000..ee4a102fc145e --- /dev/null +++ b/packages/Python/lldbsuite/test/python_api/sblaunchinfo/TestSBLaunchInfo.py @@ -0,0 +1,31 @@ +""" +Test SBLaunchInfo +""" + +from __future__ import print_function + + +from lldbsuite.test.lldbtest import * + + +def lookup(info, key): + for i in range(info.GetNumEnvironmentEntries()): + KeyEqValue = info.GetEnvironmentEntryAtIndex(i) + Key, Value = KeyEqValue.split("=") + if Key == key: + return Value + return "" + +class TestSBLaunchInfo(TestBase): + + mydir = TestBase.compute_mydir(__file__) + NO_DEBUG_INFO_TESTCASE = True + + def test_environment_getset(self): + info = lldb.SBLaunchInfo(None) + info.SetEnvironmentEntries(["FOO=BAR"], False) + self.assertEquals(1, info.GetNumEnvironmentEntries()) + info.SetEnvironmentEntries(["BAR=BAZ"], True) + self.assertEquals(2, info.GetNumEnvironmentEntries()) + self.assertEquals("BAR", lookup(info, "FOO")) + self.assertEquals("BAZ", lookup(info, "BAR")) diff --git a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py index eab3cbb30ddc9..3d0c72146d5cc 100644 --- a/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py +++ b/packages/Python/lldbsuite/test/python_api/sbvalue_persist/TestSBValuePersist.py @@ -22,7 +22,7 @@ class SBValuePersistTestCase(TestBase): """Test SBValue::Persist""" self.build() self.setTearDownCleanup() - self.runCmd("file a.out", CURRENT_EXECUTABLE_SET) + self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET) lldbutil.run_break_set_by_source_regexp(self, "break here") diff --git a/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py b/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py index 5893dfb8f7f2f..088a66c71c5ca 100644 --- a/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py +++ b/packages/Python/lldbsuite/test/python_api/section/TestSectionAPI.py @@ -19,7 +19,7 @@ class SectionAPITestCase(TestBase): d = {'EXE': 'b.out'} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), 'b.out') + exe = self.getBuildArtifact('b.out') target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py b/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py index 76b1d603f55ff..482f4a829b204 100644 --- a/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py +++ b/packages/Python/lldbsuite/test/python_api/signals/TestSignalsAPI.py @@ -22,7 +22,7 @@ class SignalsAPITestCase(TestBase): def test_ignore_signal(self): """Test Python SBUnixSignals.Suppress/Stop/Notify() API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET) target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py index 85ecb69a91fca..2b783fb90e56a 100644 --- a/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/TestSymbolContext.py @@ -31,7 +31,7 @@ class SymbolContextAPITestCase(TestBase): def test(self): """Exercise SBSymbolContext API extensively.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -66,17 +66,14 @@ class SymbolContextAPITestCase(TestBase): module = context.GetModule() desc = lldbutil.get_description(module) self.expect(desc, "The module should match", exe=False, - substrs=[os.path.join(self.mydir, 'a.out')]) + substrs=[self.getBuildArtifact("a.out")]) compileUnit = context.GetCompileUnit() self.expect( str(compileUnit), "The compile unit should match", exe=False, - substrs=[ - os.path.join( - self.mydir, - 'main.c')]) + substrs=[self.getSourcePath('main.c')]) function = context.GetFunction() self.assertTrue(function) @@ -92,8 +89,7 @@ class SymbolContextAPITestCase(TestBase): lineEntry.GetFileSpec().GetDirectory(), "The line entry should have the correct directory", exe=False, - substrs=[ - self.mydir]) + substrs=[self.mydir]) self.expect( lineEntry.GetFileSpec().GetFilename(), "The line entry should have the correct filename", diff --git a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py index 429e9c4da34ad..8640abe5625bc 100644 --- a/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py +++ b/packages/Python/lldbsuite/test/python_api/symbol-context/two-files/TestSymbolContextTwoFiles.py @@ -21,8 +21,7 @@ class SymbolContextTwoFilesTestCase(TestBase): def test_lookup_by_address(self): """Test lookup by address in a module with multiple compilation units""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -44,8 +43,7 @@ class SymbolContextTwoFilesTestCase(TestBase): """This test verifies that we correctly handle the case when multiple compile unit contains DW_AT_ranges and DW_AT_ranges_base attributes.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") - + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py b/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py index adbdc524949d9..224dca77daa3e 100644 --- a/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py +++ b/packages/Python/lldbsuite/test/python_api/target/TestTargetAPI.py @@ -46,6 +46,14 @@ class TargetAPITestCase(TestBase): self.find_global_variables('b.out') @add_test_categories(['pyapi']) + def test_find_compile_units(self): + """Exercise SBTarget.FindCompileUnits() API.""" + d = {'EXE': 'b.out'} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + self.find_compile_units(self.getBuildArtifact('b.out')) + + @add_test_categories(['pyapi']) @expectedFailureAll(oslist=["windows"], bugnumber="llvm.org/pr24778") def test_find_functions(self): """Exercise SBTarget.FindFunctions() API.""" @@ -61,12 +69,7 @@ class TargetAPITestCase(TestBase): self.get_description() @add_test_categories(['pyapi']) - def test_launch_new_process_and_redirect_stdout(self): - """Exercise SBTarget.Launch() API.""" - self.build() - self.launch_new_process_and_redirect_stdout() - - @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr21765') def test_resolve_symbol_context_with_address(self): """Exercise SBTarget.ResolveSymbolContextForAddress() API.""" self.build() @@ -149,7 +152,7 @@ class TargetAPITestCase(TestBase): self.assertEqual(len(content), 1) def create_simple_target(self, fn): - exe = os.path.join(os.getcwd(), fn) + exe = self.getBuildArtifact(fn) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) return target @@ -175,7 +178,7 @@ class TargetAPITestCase(TestBase): def find_global_variables(self, exe_name): """Exercise SBTaget.FindGlobalVariables() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -216,8 +219,7 @@ class TargetAPITestCase(TestBase): # While we are at it, let's also exercise the similar # SBModule.FindGlobalVariables() API. for m in target.module_iter(): - if os.path.normpath(m.GetFileSpec().GetDirectory()) == os.getcwd( - ) and m.GetFileSpec().GetFilename() == exe_name: + if os.path.normpath(m.GetFileSpec().GetDirectory()) == self.getBuildDir() and m.GetFileSpec().GetFilename() == exe_name: value_list = m.FindGlobalVariables( target, 'my_global_var_of_char_type', 3) self.assertTrue(value_list.GetSize() == 1) @@ -225,9 +227,23 @@ class TargetAPITestCase(TestBase): value_list.GetValueAtIndex(0).GetValue() == "'X'") break + def find_compile_units(self, exe): + """Exercise SBTarget.FindCompileUnits() API.""" + source_name = "main.c" + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + list = target.FindCompileUnits(lldb.SBFileSpec(source_name, False)) + # Executable has been built just from one source file 'main.c', + # so we may check only the first element of list. + self.assertTrue( + list[0].GetCompileUnit().GetFileSpec().GetFilename() == source_name) + def find_functions(self, exe_name): """Exercise SBTaget.FindFunctions() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -243,7 +259,7 @@ class TargetAPITestCase(TestBase): def get_description(self): """Exercise SBTaget.GetDescription() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -269,9 +285,12 @@ class TargetAPITestCase(TestBase): substrs=['a.out', 'Target', 'Module', 'Breakpoint']) @not_remote_testsuite_ready - def launch_new_process_and_redirect_stdout(self): + @add_test_categories(['pyapi']) + @no_debug_info_test + def test_launch_new_process_and_redirect_stdout(self): """Exercise SBTaget.Launch() API with redirected stdout.""" - exe = os.path.join(os.getcwd(), "a.out") + self.build() + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -286,9 +305,12 @@ class TargetAPITestCase(TestBase): # Now launch the process, do not stop at entry point, and redirect stdout to "stdout.txt" file. # The inferior should run to completion after "process.Continue()" # call. - local_path = "stdout.txt" + local_path = self.getBuildArtifact("stdout.txt") + if os.path.exists(local_path): + os.remove(local_path) + if lldb.remote_platform: - stdout_path = lldbutil.append_to_process_working_directory( + stdout_path = lldbutil.append_to_process_working_directory(self, "lldb-stdout-redirect.txt") else: stdout_path = local_path @@ -314,26 +336,19 @@ class TargetAPITestCase(TestBase): # The 'stdout.txt' file should now exist. self.assertTrue( - os.path.isfile("stdout.txt"), + os.path.isfile(local_path), "'stdout.txt' exists due to redirected stdout via SBTarget.Launch() API.") # Read the output file produced by running the program. - with open('stdout.txt', 'r') as f: + with open(local_path, 'r') as f: output = f.read() - # Let's delete the 'stdout.txt' file as a cleanup step. - try: - os.remove("stdout.txt") - pass - except OSError: - pass - self.expect(output, exe=False, substrs=["a(1)", "b(2)", "a(3)"]) def resolve_symbol_context_with_address(self): """Exercise SBTaget.ResolveSymbolContextForAddress() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py b/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py index a1272cbcbce1f..11740b1cf4df5 100644 --- a/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py +++ b/packages/Python/lldbsuite/test/python_api/thread/TestThreadAPI.py @@ -51,6 +51,7 @@ class ThreadAPITestCase(TestBase): self.step_out_of_malloc_into_function_b(self.exe_name) @add_test_categories(['pyapi']) + @expectedFailureAll(oslist=["windows"], bugnumber='llvm.org/pr32343') def test_step_over_3_times(self): """Test Python SBThread.StepOver() API.""" # We build a different executable than the default build() does. @@ -78,7 +79,7 @@ class ThreadAPITestCase(TestBase): def get_process(self): """Test Python SBThread.GetProcess() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -105,7 +106,7 @@ class ThreadAPITestCase(TestBase): def get_stop_description(self): """Test Python SBThread.GetStopDescription() API.""" - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -134,7 +135,7 @@ class ThreadAPITestCase(TestBase): def step_out_of_malloc_into_function_b(self, exe_name): """Test Python SBThread.StepOut() API to step out of a malloc call where the call site is at function b().""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -181,7 +182,7 @@ class ThreadAPITestCase(TestBase): def step_over_3_times(self, exe_name): """Test Python SBThread.StepOver() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) @@ -227,7 +228,7 @@ class ThreadAPITestCase(TestBase): def run_to_address(self, exe_name): """Test Python SBThread.RunToAddress() API.""" - exe = os.path.join(os.getcwd(), exe_name) + exe = self.getBuildArtifact(exe_name) target = self.dbg.CreateTarget(exe) self.assertTrue(target, VALID_TARGET) diff --git a/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py b/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py index 5ab742dac7c75..40128d3ce94e3 100644 --- a/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py +++ b/packages/Python/lldbsuite/test/python_api/type/TestTypeList.py @@ -34,7 +34,7 @@ class TypeAndTypeListTestCase(TestBase): d = {'EXE': self.exe_name} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py index 632244e8b9e68..8a4af0cc2b946 100644 --- a/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/TestValueAPI.py @@ -33,7 +33,7 @@ class ValueAPITestCase(TestBase): d = {'EXE': self.exe_name} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -61,9 +61,23 @@ class ValueAPITestCase(TestBase): list = target.FindGlobalVariables('days_of_week', 1) days_of_week = list.GetValueAtIndex(0) self.assertTrue(days_of_week, VALID_VARIABLE) - self.assertTrue(days_of_week.GetNumChildren() == 7, VALID_VARIABLE) + self.assertEqual(days_of_week.GetNumChildren(), 7, VALID_VARIABLE) self.DebugSBValue(days_of_week) + # Use this to test the "child" and "children" accessors: + children = days_of_week.children + self.assertEqual(len(children), 7, VALID_VARIABLE) + for i in range(0, len(children)): + day = days_of_week.child[i] + list_day = children[i] + self.assertNotEqual(day, None) + self.assertNotEqual(list_day, None) + self.assertEqual(day.GetSummary(), list_day.GetSummary(), VALID_VARIABLE) + + # Spot check the actual value: + first_day = days_of_week.child[1] + self.assertEqual(first_day.GetSummary(), '"Monday"', VALID_VARIABLE) + # Get global variable 'weekdays'. list = target.FindGlobalVariables('weekdays', 1) weekdays = list.GetValueAtIndex(0) diff --git a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py index 64c7fde226704..18d39d9675c86 100644 --- a/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py +++ b/packages/Python/lldbsuite/test/python_api/value/change_values/TestChangeValueAPI.py @@ -38,7 +38,7 @@ class ChangeValueAPITestCase(TestBase): d = {'EXE': self.exe_name} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py b/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py index c4b1e282590c4..6fa72837484ee 100644 --- a/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py +++ b/packages/Python/lldbsuite/test/python_api/value/empty_class/TestValueAPIEmptyClass.py @@ -15,7 +15,7 @@ class ValueAPIEmptyClassTestCase(TestBase): @add_test_categories(['pyapi']) def test(self): self.build() - exe = os.path.join(os.getcwd(), 'a.out') + exe = self.getBuildArtifact("a.out") line = line_number('main.cpp', '// Break at this line') # Create a target by the debugger. diff --git a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py index d5f53d712e7da..1b009521d253a 100644 --- a/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py +++ b/packages/Python/lldbsuite/test/python_api/value/linked_list/TestValueAPILinkedList.py @@ -36,7 +36,7 @@ class ValueAsLinkedListTestCase(TestBase): d = {'EXE': self.exe_name} self.build(dictionary=d) self.setTearDownCleanup(dictionary=d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py b/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py index f4789877f34ea..a83fd6e123904 100644 --- a/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py +++ b/packages/Python/lldbsuite/test/python_api/value_var_update/TestValueVarUpdate.py @@ -20,16 +20,16 @@ class HelloWorldTestCase(TestBase): def setUp(self): # Call super's setUp(). TestBase.setUp(self) - # Get the full path to our executable to be attached/debugged. - self.exe = os.path.join(os.getcwd(), self.testMethodName) - self.d = {'EXE': self.testMethodName} @add_test_categories(['pyapi']) 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) + # Get the full path to our executable to be attached/debugged. + exe = self.getBuildArtifact(self.testMethodName) + d = {'EXE': exe} + self.build(dictionary=d) + self.setTearDownCleanup(dictionary=d) + target = self.dbg.CreateTarget(exe) breakpoint = target.BreakpointCreateBySourceRegex( "break here", lldb.SBFileSpec("main.c")) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py index cef8a0c4e81f9..0236d4b2c6d8e 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestSetWatchpoint.py @@ -36,7 +36,7 @@ class SetWatchpointAPITestCase(TestBase): def test_watch_val(self): """Exercise SBValue.Watch() API to set a watchpoint.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py index 0d1ef809d2919..603b7a805008c 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIgnoreCount.py @@ -36,7 +36,7 @@ class WatchpointIgnoreCountTestCase(TestBase): def test_set_watch_ignore_count(self): """Test SBWatchpoint.SetIgnoreCount() API.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py index ca5fca3acf9a0..b9fc7ceb1af62 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/TestWatchpointIter.py @@ -39,7 +39,7 @@ class WatchpointIteratorTestCase(TestBase): def test_watch_iter(self): """Exercise SBTarget.watchpoint_iter() API to iterate on the available watchpoints.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py index 4b0216d7a6025..bb32869543c71 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/condition/TestWatchpointConditionAPI.py @@ -42,7 +42,7 @@ class WatchpointConditionAPITestCase(TestBase): """Test watchpoint condition API.""" self.build(dictionary=self.d) self.setTearDownCleanup(dictionary=self.d) - exe = os.path.join(os.getcwd(), self.exe_name) + exe = self.getBuildArtifact(self.exe_name) # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py index e6bc9c0a76544..fdc8ac053d763 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestSetWatchlocation.py @@ -37,7 +37,7 @@ class SetWatchlocationAPITestCase(TestBase): def test_watch_location(self): """Exercise SBValue.WatchPointee() API to set a watchpoint.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) diff --git a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py index 80595060b42d0..d5862d274cebb 100644 --- a/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py +++ b/packages/Python/lldbsuite/test/python_api/watchpoint/watchlocation/TestTargetWatchAddress.py @@ -36,7 +36,7 @@ class TargetWatchAddressAPITestCase(TestBase): def test_watch_address(self): """Exercise SBTarget.WatchAddress() API to set a watchpoint.""" self.build() - exe = os.path.join(os.getcwd(), "a.out") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) @@ -112,7 +112,7 @@ class TargetWatchAddressAPITestCase(TestBase): 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") + exe = self.getBuildArtifact("a.out") # Create a target by the debugger. target = self.dbg.CreateTarget(exe) |