[Lldb-commits] [lldb] 53eece0 - [lldb][NFC] Modernize test setup code in several lang/cpp tests

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 19 06:08:06 PST 2020


Author: Raphael Isemann
Date: 2020-02-19T15:07:26+01:00
New Revision: 53eece04bd15d9235b104e545d01184347e5f703

URL: https://github.com/llvm/llvm-project/commit/53eece04bd15d9235b104e545d01184347e5f703
DIFF: https://github.com/llvm/llvm-project/commit/53eece04bd15d9235b104e545d01184347e5f703.diff

LOG: [lldb][NFC] Modernize test setup code in several lang/cpp tests

All these tests can just call lldbutil.run_to_source_breakpoint
instead of reimplementing it.

Added: 
    

Modified: 
    lldb/test/API/lang/cpp/auto/TestCPPAuto.py
    lldb/test/API/lang/cpp/bool/TestCPPBool.py
    lldb/test/API/lang/cpp/breakpoint_in_member_func_w_non_primitive_params/TestBreakpointInMemberFuncWNonPrimitiveParams.py
    lldb/test/API/lang/cpp/call-function/TestCallCPPFunction.py
    lldb/test/API/lang/cpp/chained-calls/TestCppChainedCalls.py
    lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
    lldb/test/API/lang/cpp/char8_t/main.cpp
    lldb/test/API/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
    lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
    lldb/test/API/lang/cpp/stl/TestSTL.py
    lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
    lldb/test/API/lang/cpp/unicode-literals/TestUnicodeLiterals.py
    lldb/test/API/lang/cpp/unique-types/TestUniqueTypes.py
    lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
    lldb/test/API/lang/cpp/wchar_t/TestCxxWCharT.py
    lldb/test/API/lang/cpp/wchar_t/main.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/test/API/lang/cpp/auto/TestCPPAuto.py b/lldb/test/API/lang/cpp/auto/TestCPPAuto.py
index b0e7ff73e98d..0094db1c0681 100644
--- a/lldb/test/API/lang/cpp/auto/TestCPPAuto.py
+++ b/lldb/test/API/lang/cpp/auto/TestCPPAuto.py
@@ -18,13 +18,7 @@ class CPPAutoTestCase(TestBase):
     def test_with_run_command(self):
         """Test that auto types work in the expression parser"""
         self.build()
-        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-
-        line = line_number('main.cpp', '// break here')
-        lldbutil.run_break_set_by_file_and_line(
-            self, "main.cpp", line, num_expected_locations=-1, loc_exact=False)
-
-        self.runCmd("process launch", RUN_SUCCEEDED)
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
 
         self.expect_expr('auto f = 123456; f', result_type='int', result_value='123456')
         self.expect(

diff  --git a/lldb/test/API/lang/cpp/bool/TestCPPBool.py b/lldb/test/API/lang/cpp/bool/TestCPPBool.py
index 0a4a3343f00c..bff3e86f54cf 100644
--- a/lldb/test/API/lang/cpp/bool/TestCPPBool.py
+++ b/lldb/test/API/lang/cpp/bool/TestCPPBool.py
@@ -13,13 +13,7 @@ class CPPBoolTestCase(TestBase):
     def test_with_run_command(self):
         """Test that bool types work in the expression parser"""
         self.build()
-        self.runCmd("file " + self.getBuildArtifact("a.out"), CURRENT_EXECUTABLE_SET)
-
-        line = line_number('main.cpp', '// breakpoint 1')
-        lldbutil.run_break_set_by_file_and_line(
-            self, "main.cpp", line, num_expected_locations=-1, loc_exact=False)
-
-        self.runCmd("process launch", RUN_SUCCEEDED)
+        lldbutil.run_to_source_breakpoint(self, "// breakpoint 1", lldb.SBFileSpec("main.cpp"))
 
         self.expect_expr("bool second_bool = my_bool; second_bool", result_type="bool", result_value="false")
         self.expect_expr("my_bool = true", result_type="bool", result_value="true")

diff  --git a/lldb/test/API/lang/cpp/breakpoint_in_member_func_w_non_primitive_params/TestBreakpointInMemberFuncWNonPrimitiveParams.py b/lldb/test/API/lang/cpp/breakpoint_in_member_func_w_non_primitive_params/TestBreakpointInMemberFuncWNonPrimitiveParams.py
index 1e46f73cb298..41bb8673c3a0 100644
--- a/lldb/test/API/lang/cpp/breakpoint_in_member_func_w_non_primitive_params/TestBreakpointInMemberFuncWNonPrimitiveParams.py
+++ b/lldb/test/API/lang/cpp/breakpoint_in_member_func_w_non_primitive_params/TestBreakpointInMemberFuncWNonPrimitiveParams.py
@@ -19,8 +19,7 @@ class TestBreakpointInMemberFuncWNonPrimitiveParams(TestBase):
     @add_test_categories(["gmodules"])
     def test_breakpint_in_member_func_w_non_primitie_params(self):
         self.build()
-
-        (self.target, self.process, _, bkpt) = lldbutil.run_to_source_breakpoint(self, '// break here',
+        lldbutil.run_to_source_breakpoint(self, '// break here',
                 lldb.SBFileSpec("main.cpp", False))
 
         self.runCmd("b a.cpp:11");

diff  --git a/lldb/test/API/lang/cpp/call-function/TestCallCPPFunction.py b/lldb/test/API/lang/cpp/call-function/TestCallCPPFunction.py
index 3327eed1b292..6924ad2f255f 100644
--- a/lldb/test/API/lang/cpp/call-function/TestCallCPPFunction.py
+++ b/lldb/test/API/lang/cpp/call-function/TestCallCPPFunction.py
@@ -19,12 +19,7 @@ def setUp(self):
     def test_with_run_command(self):
         """Test calling a function by basename"""
         self.build()
-        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.runCmd("process launch", RUN_SUCCEEDED)
+        lldbutil.run_to_source_breakpoint(self, "// breakpoint", lldb.SBFileSpec("main.cpp"))
 
         # The stop reason of the thread should be breakpoint.
         self.expect("thread list",

diff  --git a/lldb/test/API/lang/cpp/chained-calls/TestCppChainedCalls.py b/lldb/test/API/lang/cpp/chained-calls/TestCppChainedCalls.py
index e5470fc1aea9..1813a0f2a002 100644
--- a/lldb/test/API/lang/cpp/chained-calls/TestCppChainedCalls.py
+++ b/lldb/test/API/lang/cpp/chained-calls/TestCppChainedCalls.py
@@ -10,38 +10,7 @@ class TestCppChainedCalls(TestBase):
 
     def test_with_run_command(self):
         self.build()
-
-        # 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("a.out")
-
-        # 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)
-        lldbutil.get_stopped_thread(process, lldb.eStopReasonBreakpoint)
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
 
         # Test chained calls
         self.expect_expr("get(set(true))", result_type="bool", result_value="true")

diff  --git a/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py b/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
index 6867a78419e5..b39a069f5f21 100644
--- a/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
+++ b/lldb/test/API/lang/cpp/char8_t/TestCxxChar8_t.py
@@ -18,16 +18,7 @@ class CxxChar8_tTestCase(TestBase):
     def test(self):
         """Test that C++ supports char8_t correctly."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-
-        # Create a target by the debugger.
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # FIXME: We should be able to test this with target variable, but the
-        # data formatter output is broken.
-        lldbutil.run_break_set_by_symbol(self, 'main')
-        self.runCmd("run", RUN_SUCCEEDED)
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
 
         self.expect_expr("a", result_type="char8_t", result_summary="0x61 u8'a'")
         self.expect_expr("ab", result_type="const char8_t *", result_summary='u8"你好"')

diff  --git a/lldb/test/API/lang/cpp/char8_t/main.cpp b/lldb/test/API/lang/cpp/char8_t/main.cpp
index b73ba0c4e610..d109751cc231 100644
--- a/lldb/test/API/lang/cpp/char8_t/main.cpp
+++ b/lldb/test/API/lang/cpp/char8_t/main.cpp
@@ -2,4 +2,6 @@ char8_t a  = u8'a';
 const char8_t* ab = u8"你好";
 char8_t abc[9] = u8"你好";
 
-int main (int argc, char const *argv[]) { return 0; }
+int main (int argc, char const *argv[]) {
+  return 0; // break here
+}

diff  --git a/lldb/test/API/lang/cpp/overloaded-functions/TestOverloadedFunctions.py b/lldb/test/API/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
index ad969ef3d088..60207b1978f1 100644
--- a/lldb/test/API/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
+++ b/lldb/test/API/lang/cpp/overloaded-functions/TestOverloadedFunctions.py
@@ -12,24 +12,10 @@ class OverloadedFunctionsTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        TestBase.setUp(self)
-        self.line = line_number('main.cpp', '// breakpoint')
-
     def test_with_run_command(self):
         """Test that functions with the same name are resolved correctly"""
         self.build()
-        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.runCmd("process launch", RUN_SUCCEEDED)
-
-        # The stop reason of the thread should be breakpoint.
-        self.expect("thread list",
-                    STOPPED_DUE_TO_BREAKPOINT,
-                    substrs=['stopped', 'stop reason = breakpoint'])
+        lldbutil.run_to_source_breakpoint(self, "// breakpoint", lldb.SBFileSpec("main.cpp"))
 
         self.expect("expression -- Dump(myB)",
                     startstr="(int) $0 = 2")

diff  --git a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
index 4b422674134c..d358757d8837 100644
--- a/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
+++ b/lldb/test/API/lang/cpp/static_methods/TestCPPStaticMethods.py
@@ -12,24 +12,10 @@ class CPPStaticMethodsTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        TestBase.setUp(self)
-        self.line = line_number('main.cpp', '// Break at this line')
-
     def test_with_run_command(self):
         """Test that static methods are properly distinguished from regular methods"""
         self.build()
-        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.runCmd("process launch", RUN_SUCCEEDED)
-
-        # The stop reason of the thread should be breakpoint.
-        self.expect("thread list",
-                    STOPPED_DUE_TO_BREAKPOINT,
-                    substrs=['stopped', 'stop reason = breakpoint'])
+        lldbutil.run_to_source_breakpoint(self, "// Break at this line", lldb.SBFileSpec("main.cpp"))
 
         self.expect("expression -- A::getStaticValue()",
                     startstr="(int) $0 = 5")

diff  --git a/lldb/test/API/lang/cpp/stl/TestSTL.py b/lldb/test/API/lang/cpp/stl/TestSTL.py
index 276c13ff3090..e796df698f97 100644
--- a/lldb/test/API/lang/cpp/stl/TestSTL.py
+++ b/lldb/test/API/lang/cpp/stl/TestSTL.py
@@ -15,40 +15,12 @@ class STLTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number to break inside main().
-        self.source = 'main.cpp'
-        self.line = line_number(
-            self.source, '// Set break point at this line.')
-
     @skipIf
     @expectedFailureAll(bugnumber="llvm.org/PR36713")
     def test(self):
         """Test some expressions involving STL data types."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-
-        # The following two lines, if uncommented, will enable loggings.
-        #self.ci.HandleCommand("log enable -f /tmp/lldb.log lldb default", res)
-        # self.assertTrue(res.Succeeded())
-
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-        lldbutil.run_break_set_by_file_and_line(
-            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
-
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # Stop at 'std::string hello_world ("Hello World!");'.
-        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-                    substrs=['main.cpp:%d' % self.line,
-                             'stop reason = breakpoint'])
-
-        # The breakpoint should have a hit count of 1.
-        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-                    substrs=[' resolved, hit count = 1'])
+        lldbutil.run_to_source_breakpoint(self, "// Set break point at this line", lldb.SBFileSpec("main.cpp"))
 
         # Now try some expressions....
 
@@ -71,28 +43,7 @@ def test(self):
     def test_SBType_template_aspects(self):
         """Test APIs for getting template arguments from an SBType."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-
-        # Create a target by the debugger.
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # Create the breakpoint inside function 'main'.
-        breakpoint = target.BreakpointCreateByLocation(self.source, self.line)
-        self.assertTrue(breakpoint, VALID_BREAKPOINT)
-
-        # Now launch the process, and do not stop at entry point.
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-        self.assertTrue(process, PROCESS_IS_VALID)
-
-        # Get Frame #0.
-        self.assertEquals(process.GetState(), lldb.eStateStopped)
-        thread = lldbutil.get_stopped_thread(
-            process, lldb.eStopReasonBreakpoint)
-        self.assertTrue(
-            thread.IsValid(),
-            "There should be a thread stopped due to breakpoint condition")
+        (_, _, thread, _) = lldbutil.run_to_source_breakpoint(self, "// Set break point at this line", lldb.SBFileSpec("main.cpp"))
         frame0 = thread.GetFrameAtIndex(0)
 
         # Get the type for variable 'associative_array'.

diff  --git a/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py b/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
index 8e719f5371e3..62714fc3bdf7 100644
--- a/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
+++ b/lldb/test/API/lang/cpp/stl/TestStdCXXDisassembly.py
@@ -16,43 +16,12 @@ class StdCXXDisassembleTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    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.')
-
     @skipIfWindows
     @expectedFailureNetBSD
     def test_stdcxx_disasm(self):
         """Do 'disassemble' on each and every 'Code' symbol entry from the std c++ lib."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-        # rdar://problem/8543077
-        # test/stl: clang built binaries results in the breakpoint locations = 3,
-        # is this a problem with clang generated debug info?
-        #
-        # Break on line 13 of main.cpp.
-        lldbutil.run_break_set_by_file_and_line(
-            self, "main.cpp", self.line, num_expected_locations=1, loc_exact=True)
-
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # Now let's get the target as well as the process objects.
-        target = self.dbg.GetSelectedTarget()
-        process = target.GetProcess()
-
-        # The process should be in a 'stopped' state.
-        self.expect(
-            str(process),
-            STOPPED_DUE_TO_BREAKPOINT,
-            exe=False,
-            substrs=[
-                "stopped",
-                "a.out",
-            ])
+        (target, process, thread, bkpt) = lldbutil.run_to_source_breakpoint(self, "// Set break point at this line", lldb.SBFileSpec("main.cpp"))
 
         # Disassemble the functions on the call stack.
         self.runCmd("thread backtrace")

diff  --git a/lldb/test/API/lang/cpp/unicode-literals/TestUnicodeLiterals.py b/lldb/test/API/lang/cpp/unicode-literals/TestUnicodeLiterals.py
index c1bd892447a9..931890e9056c 100644
--- a/lldb/test/API/lang/cpp/unicode-literals/TestUnicodeLiterals.py
+++ b/lldb/test/API/lang/cpp/unicode-literals/TestUnicodeLiterals.py
@@ -30,48 +30,24 @@ class UnicodeLiteralsTestCase(TestBase):
 
     def test_expr1(self):
         """Test that the expression parser returns proper Unicode strings."""
-        self.build()
         self.rdar12991846(expr=1)
 
     def test_expr2(self):
         """Test that the expression parser returns proper Unicode strings."""
-        self.build()
         self.rdar12991846(expr=2)
 
     def test_expr3(self):
         """Test that the expression parser returns proper Unicode strings."""
-        self.build()
         self.rdar12991846(expr=3)
 
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number to break for main.cpp.
-        self.source = 'main.cpp'
-        self.line = line_number(
-            self.source, '// Set break point at this line.')
-
     def rdar12991846(self, expr=None):
         """Test that the expression parser returns proper Unicode strings."""
         if self.getArchitecture() in ['i386']:
             self.skipTest(
                 "Skipping because this test is known to crash on i386")
 
-        exe = self.getBuildArtifact("a.out")
-
-        # Create a target by the debugger.
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # Break on the struct declration statement in main.cpp.
-        lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line)
-
-        # Now launch the process, and do not stop at entry point.
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-
-        if not process:
-            self.fail("SBTarget.Launch() failed")
+        self.build()
+        lldbutil.run_to_source_breakpoint(self, "// Set break point at this line", lldb.SBFileSpec("main.cpp"))
 
         if expr == 1:
             self.expect('expression L"hello"', substrs=['hello'])

diff  --git a/lldb/test/API/lang/cpp/unique-types/TestUniqueTypes.py b/lldb/test/API/lang/cpp/unique-types/TestUniqueTypes.py
index 78121c14970b..1d206504ecfb 100644
--- a/lldb/test/API/lang/cpp/unique-types/TestUniqueTypes.py
+++ b/lldb/test/API/lang/cpp/unique-types/TestUniqueTypes.py
@@ -13,32 +13,10 @@ class UniqueTypesTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number inside main.cpp.
-        self.line = line_number(
-            "main.cpp",
-            "// Set breakpoint here to verify that std::vector 'longs' and 'shorts' have unique types.")
-
     def test(self):
         """Test for unique types of std::vector<long> and std::vector<short>."""
         self.build()
-
-        compiler = self.getCompiler()
-        compiler_basename = os.path.basename(compiler)
-
-        exe = self.getBuildArtifact("a.out")
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-        lldbutil.run_break_set_by_file_and_line(
-            self, "main.cpp", self.line, num_expected_locations=-1, loc_exact=True)
-
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # The stop reason of the thread should be breakpoint.
-        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-                    substrs=['stopped',
-                             'stop reason = breakpoint'])
+        lldbutil.run_to_source_breakpoint(self, "// Set breakpoint here", lldb.SBFileSpec("main.cpp"))
 
         # Do a "frame variable --show-types longs" and verify "long" is in each
         # line of output.

diff  --git a/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py b/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
index ca754f470dae..d6b6899012ec 100644
--- a/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
+++ b/lldb/test/API/lang/cpp/unsigned_types/TestUnsignedTypes.py
@@ -14,38 +14,10 @@ class UnsignedTypesTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    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.')
-
     def test(self):
         """Test that variables with unsigned types display correctly."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
-
-        # GCC puts a breakpoint on the last line of a multi-line expression, so
-        # if GCC is the target compiler, we cannot rely on an exact line match.
-        need_exact = "gcc" not in self.getCompiler()
-        # Break on line 19 in main() after the variables are assigned values.
-        lldbutil.run_break_set_by_file_and_line(
-            self,
-            "main.cpp",
-            self.line,
-            num_expected_locations=-1,
-            loc_exact=need_exact)
-
-        self.runCmd("run", RUN_SUCCEEDED)
-
-        # The stop reason of the thread should be breakpoint.
-        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
-                    substrs=['stopped', 'stop reason = breakpoint'])
-
-        # The breakpoint should have a hit count of 1.
-        self.expect("breakpoint list -f", BREAKPOINT_HIT_ONCE,
-                    substrs=[' resolved, hit count = 1'])
+        lldbutil.run_to_source_breakpoint(self, "// Set break point at this line", lldb.SBFileSpec("main.cpp"))
 
         # Test that unsigned types display correctly.
         self.expect(

diff  --git a/lldb/test/API/lang/cpp/wchar_t/TestCxxWCharT.py b/lldb/test/API/lang/cpp/wchar_t/TestCxxWCharT.py
index b59d71e8e8ef..bb041ef44b91 100644
--- a/lldb/test/API/lang/cpp/wchar_t/TestCxxWCharT.py
+++ b/lldb/test/API/lang/cpp/wchar_t/TestCxxWCharT.py
@@ -14,32 +14,10 @@ class CxxWCharTTestCase(TestBase):
 
     mydir = TestBase.compute_mydir(__file__)
 
-    def setUp(self):
-        # Call super's setUp().
-        TestBase.setUp(self)
-        # Find the line number to break for main.cpp.
-        self.source = 'main.cpp'
-        self.line = line_number(
-            self.source, '// Set break point at this line.')
-
     def test(self):
         """Test that C++ supports wchar_t correctly."""
         self.build()
-        exe = self.getBuildArtifact("a.out")
-
-        # Create a target by the debugger.
-        target = self.dbg.CreateTarget(exe)
-        self.assertTrue(target, VALID_TARGET)
-
-        # Break on the struct declration statement in main.cpp.
-        lldbutil.run_break_set_by_file_and_line(self, "main.cpp", self.line)
-
-        # Now launch the process, and do not stop at entry point.
-        process = target.LaunchSimple(
-            None, None, self.get_process_working_directory())
-
-        if not process:
-            self.fail("SBTarget.Launch() failed")
+        lldbutil.run_to_source_breakpoint(self, "// break here", lldb.SBFileSpec("main.cpp"))
 
         # Check that we correctly report templates on wchar_t
         self.expect("frame variable foo_y",

diff  --git a/lldb/test/API/lang/cpp/wchar_t/main.cpp b/lldb/test/API/lang/cpp/wchar_t/main.cpp
index 4d6a1072d695..420fe0c56697 100644
--- a/lldb/test/API/lang/cpp/wchar_t/main.cpp
+++ b/lldb/test/API/lang/cpp/wchar_t/main.cpp
@@ -30,5 +30,5 @@ int main (int argc, char const *argv[])
   	wchar_t array[200], * array_source = L"Hey, I'm a super wchar_t string, éõñž";
     wchar_t wchar_zero = (wchar_t)0;
   	memcpy(array, array_source, 39 * sizeof(wchar_t));
-    return 0; // Set break point at this line.
+    return 0; // break here
 }


        


More information about the lldb-commits mailing list