[Lldb-commits] [lldb] r327924 - Modernize a test.

Davide Italiano via lldb-commits lldb-commits at lists.llvm.org
Mon Mar 19 18:31:35 PDT 2018


On Mon, Mar 19, 2018 at 4:15 PM, Jim Ingham via lldb-commits
<lldb-commits at lists.llvm.org> wrote:
> Author: jingham
> Date: Mon Mar 19 16:15:06 2018
> New Revision: 327924
>
> URL: http://llvm.org/viewvc/llvm-project?rev=327924&view=rev
> Log:
> Modernize a test.
>
> Modified:
>     lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py
>
> Modified: lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py
> URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py?rev=327924&r1=327923&r2=327924&view=diff
> ==============================================================================
> --- lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py (original)
> +++ lldb/trunk/packages/Python/lldbsuite/test/lang/cpp/incomplete-types/TestCppIncompleteTypes.py Mon Mar 19 16:15:06 2018
> @@ -48,35 +48,8 @@ class TestCppIncompleteTypes(TestBase):
>          # Get main source file
>          src_file = "main.cpp"
>          src_file_spec = lldb.SBFileSpec(src_file)
> -        self.assertTrue(src_file_spec.IsValid(), "Main source file")
> -
> -        # Get the path of the executable
> -        exe_path = self.getBuildArtifact(exe)
> -
> -        # Load the executable
> -        target = self.dbg.CreateTarget(exe_path)
> -        self.assertTrue(target.IsValid(), VALID_TARGET)
> -
> -        # Break on main function
> -        main_breakpoint = target.BreakpointCreateBySourceRegex(
> -            "break here", src_file_spec)
> -        self.assertTrue(
> -            main_breakpoint.IsValid() and main_breakpoint.GetNumLocations() >= 1,
> -            VALID_BREAKPOINT)
> -
> -        # Launch the process
> -        args = None
> -        env = None
> -        process = target.LaunchSimple(
> -            args, env, self.get_process_working_directory())
> -        self.assertTrue(process.IsValid(), PROCESS_IS_VALID)
> -
> -        # Get the thread of the process
> -        self.assertTrue(
> -            process.GetState() == lldb.eStateStopped,
> -            PROCESS_STOPPED)
> -        thread = lldbutil.get_stopped_thread(
> -            process, lldb.eStopReasonBreakpoint)
>
> +        (target, process, thread, main_breakpoint) = lldbutil.run_to_source_breakpoint(self,
> +                "break here", src_file_spec, exe_name = exe)
>          # Get frame for current thread
>          return thread.GetSelectedFrame()
>

Thanks. I was actually adding a new test and complaining to myself
that there was too much boilerplate.
This helper clearly makes things much better. It's probably worth
documenting it somewhere? What do you think?

Thanks!

--
Davide


More information about the lldb-commits mailing list