[Lldb-commits] [lldb] r307943 - Convert a few more tests to use run_to_source_breakpoint.

Jim Ingham via lldb-commits lldb-commits at lists.llvm.org
Thu Jul 13 12:46:21 PDT 2017


Author: jingham
Date: Thu Jul 13 12:46:21 2017
New Revision: 307943

URL: http://llvm.org/viewvc/llvm-project?rev=307943&view=rev
Log:
Convert a few more tests to use run_to_source_breakpoint.

Modified:
    lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
    lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py

Modified: lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py?rev=307943&r1=307942&r2=307943&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/expression_command/unwind_expression/TestUnwindExpression.py Thu Jul 13 12:46:21 2017
@@ -23,32 +23,8 @@ class UnwindFromExpressionTest(TestBase)
     def build_and_run_to_bkpt(self):
         self.build()
 
-        exe = os.path.join(os.getcwd(), "a.out")
-
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # Create the breakpoint.
-        breakpoint = target.BreakpointCreateBySourceRegex(
-            "// Set a breakpoint here to get started", self.main_spec)
-        self.assertTrue(breakpoint, VALID_BREAKPOINT)
-
-        # Launch the process, and do not stop at the entry point.
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-
-        if not process:
-            self.fail("SBTarget.LaunchProcess() failed")
-
-        if process.GetState() != lldb.eStateStopped:
-            self.fail("Process should be in the 'stopped' state, "
-                      "instead the actual state is: '%s'" %
-                      lldbutil.state_type_to_str(process.GetState()))
-
-        self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
-            process, breakpoint)
-        self.assertIsNotNone(
-            self.thread, "Expected one thread to be stopped at the breakpoint")
+        (target, process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 
+                "// Set a breakpoint here to get started", self.main_spec)
 
         # Next set a breakpoint in this function, set up Expression options to stop on
         # breakpoint hits, and call the function.

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py?rev=307943&r1=307942&r2=307943&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/address_breakpoints/TestBadAddressBreakpoints.py Thu Jul 13 12:46:21 2017
@@ -30,46 +30,13 @@ class BadAddressBreakpointTestCase(TestB
 
     def address_breakpoints(self):
         """Test that breakpoints set on a bad address say they are bad."""
-        exe = os.path.join(os.getcwd(), "a.out")
 
-        # Create a target by the debugger.
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # Now create a breakpoint on main.c by name 'c'.
-        breakpoint = target.BreakpointCreateBySourceRegex(
-            "Set a breakpoint here", lldb.SBFileSpec("main.c"))
-        self.assertTrue(breakpoint and
-                        breakpoint.GetNumLocations() == 1,
-                        VALID_BREAKPOINT)
-
-        # Get the breakpoint location from breakpoint after we verified that,
-        # indeed, it has one location.
-        location = breakpoint.GetLocationAtIndex(0)
-        self.assertTrue(location and
-                        location.IsEnabled(),
-                        VALID_BREAKPOINT_LOCATION)
-
-        launch_info = lldb.SBLaunchInfo(None)
-
-        error = lldb.SBError()
-
-        process = target.Launch(launch_info, error)
-        self.assertTrue(process, PROCESS_IS_VALID)
-
-        # Did we hit our breakpoint?
-        from lldbsuite.test.lldbutil import get_threads_stopped_at_breakpoint
-        threads = get_threads_stopped_at_breakpoint(process, breakpoint)
-        self.assertTrue(
-            len(threads) == 1,
-            "There should be a thread stopped at our breakpoint")
-
-        # The hit count for the breakpoint should be 1.
-        self.assertTrue(breakpoint.GetHitCount() == 1)
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, 
+                "Set a breakpoint here", lldb.SBFileSpec("main.c"))
 
         # Now see if we can read from 0.  If I can't do that, I don't have a good way to know
         # what an illegal address is...
-        error.Clear()
+        error = lldb.SBError()
 
         ptr = process.ReadPointerFromMemory(0x0, error)
 

Modified: lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py?rev=307943&r1=307942&r2=307943&view=diff
==============================================================================
--- lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py (original)
+++ lldb/trunk/packages/Python/lldbsuite/test/functionalities/breakpoint/consecutive_breakpoints/TestConsecutiveBreakpoints.py Thu Jul 13 12:46:21 2017
@@ -18,29 +18,9 @@ class ConsecutiveBreakpointsTestCase(Tes
 
     def prepare_test(self):
         self.build()
-        exe = os.path.join(os.getcwd(), "a.out")
 
-        # Create a target by the debugger.
-        self.target = self.dbg.CreateTarget(exe)
-        self.assertTrue(self.target, VALID_TARGET)
-
-        breakpoint1 = self.target.BreakpointCreateBySourceRegex(
-            "Set breakpoint here", lldb.SBFileSpec("main.cpp"))
-        self.assertTrue(
-            breakpoint1 and breakpoint1.GetNumLocations() == 1,
-            VALID_BREAKPOINT)
-
-        # Now launch the process, and do not stop at entry point.
-        self.process = self.target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-        self.assertIsNotNone(self.process, PROCESS_IS_VALID)
-
-        # We should be stopped at the first breakpoint
-        self.thread = lldbutil.get_one_thread_stopped_at_breakpoint(
-            self.process, breakpoint1)
-        self.assertIsNotNone(
-            self.thread,
-            "Expected one thread to be stopped at breakpoint 1")
+        (self.target, self.process, self.thread, bkpt) = lldbutil.run_to_source_breakpoint(
+                self, "Set breakpoint here", lldb.SBFileSpec("main.cpp"))
 
         # Set breakpoint to the next instruction
         frame = self.thread.GetFrameAtIndex(0)




More information about the lldb-commits mailing list