[Lldb-commits] [lldb] r111677 - in /lldb/trunk/test: lldbtest.py load_unload/TestLoadUnload.py order/TestOrderFile.py persistent_variables/TestPersistentVariables.py set_values/TestSetValues.py stl/TestSTL.py struct_types/TestStructTypes.py

Johnny Chen johnny.chen at apple.com
Fri Aug 20 14:03:10 PDT 2010


Author: johnny
Date: Fri Aug 20 16:03:09 2010
New Revision: 111677

URL: http://llvm.org/viewvc/llvm-project?rev=111677&view=rev
Log:
Print the verbose output of runCmd()/expect() to stderr instead of stdout.
And converted the rest of the test cases to runCmd()/expect().

Modified:
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/load_unload/TestLoadUnload.py
    lldb/trunk/test/order/TestOrderFile.py
    lldb/trunk/test/persistent_variables/TestPersistentVariables.py
    lldb/trunk/test/set_values/TestSetValues.py
    lldb/trunk/test/stl/TestSTL.py
    lldb/trunk/test/struct_types/TestStructTypes.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Fri Aug 20 16:03:09 2010
@@ -28,6 +28,7 @@
 """
 
 import os
+import sys
 import unittest2
 import lldb
 
@@ -37,7 +38,7 @@
 
 CURRENT_EXECUTABLE_SET = "Current executable set successfully"
 
-RUN_STOPPED = "Process is stopped successfully"
+RUN_STOPPED = "Process is launched and then stopped successfully"
 
 RUN_COMPLETED = "Process exited successfully"
 
@@ -124,18 +125,18 @@
             raise Exception("Bad 'cmd' parameter encountered")
 
         if verbose:
-            print "runCmd:", cmd
+            print >> sys.stderr, "runCmd:", cmd
 
         self.ci.HandleCommand(cmd, self.res)
 
         if cmd.startswith("run"):
             self.runStarted = True
 
-        if not self.res.Succeeded():
-            print self.res.GetError()
-
         if verbose:
-            print "output:", self.res.GetOutput()
+            if self.res.Succeeded():
+                print >> sys.stderr, "output:", self.res.GetOutput()
+            else:
+                print >> sys.stderr, self.res.GetError()
 
         if check:
             self.assertTrue(self.res.Succeeded(),
@@ -159,14 +160,14 @@
         matched = output.startswith(startstr) if startstr else True
 
         if not matched and startstr and verbose:
-            print "Startstr not matched:", startstr
+            print >> sys.stderr, "Startstr not matched:", startstr
 
         if substrs:
             for str in substrs:
                 matched = output.find(str) > 0
                 if not matched:
                     if verbose:
-                        print "Substring not matched:", str
+                        print >> sys.stderr, "Substring not matched:", str
                     break
 
         self.assertTrue(matched, msg if msg else CMD_MSG(cmd))

Modified: lldb/trunk/test/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/test/load_unload/TestLoadUnload.py Fri Aug 20 16:03:09 2010
@@ -13,57 +13,38 @@
 
     def test_load_unload(self):
         """Test breakpoint by name works correctly with dlopen'ing."""
-        res = self.res
         exe = os.path.join(os.getcwd(), "a.out")
-        self.ci.HandleCommand("file " + exe, res)
-        self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Break by function name a_function (not yet loaded).
-        self.ci.HandleCommand("breakpoint set -n a_function", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 1: name = 'a_function', locations = 0 "
-            "(pending)"
-            ),
-                        BREAKPOINT_CREATED)
-
-        self.ci.HandleCommand("run", res)
-        self.runStarted = True
-        self.assertTrue(res.Succeeded(), RUN_STOPPED)
+        self.expect("breakpoint set -n a_function", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: name = 'a_function', locations = 0 (pending)")
+
+        self.runCmd("run", RUN_STOPPED)
 
         # The stop reason of the thread should be breakpoint and at a_function.
-        self.ci.HandleCommand("thread list", res)
-        output = res.GetOutput()
-        self.assertTrue(res.Succeeded(), CMD_MSG('thread list'))
-        self.assertTrue(output.find('state is Stopped') > 0 and
-                        output.find('a_function') > 0 and
-                        output.find('a.c:14') > 0 and
-                        output.find('stop reason = breakpoint') > 0,
-                        STOPPED_DUE_TO_BREAKPOINT)
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['state is Stopped',
+                       'a_function',
+                       'a.c:14',
+                       'stop reason = breakpoint'])
 
         # The breakpoint should have a hit count of 1.
-        self.ci.HandleCommand("breakpoint list", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint list'))
-        self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
-                        BREAKPOINT_HIT_ONCE)
+        self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
 
-#         # We should stop agaian at a_function.
+#         # Issue the 'contnue' command.  We should stop agaian at a_function.
 #         # The stop reason of the thread should be breakpoint and at a_function.
-#         self.ci.HandleCommand("thread list", res)
-#         output = res.GetOutput()
-#         self.assertTrue(res.Succeeded())
-#         self.assertTrue(output.find('state is Stopped') > 0 and
-#                         output.find('a_function') > 0 and
-#                         output.find('a.c:14') > 0 and
-#                         output.find('stop reason = breakpoint') > 0)
-
+#         self.runCmd("continue")
+#         self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+#             substrs = ['state is Stopped',
+#                        'a_function',
+#                        'a.c:14',
+#                        'stop reason = breakpoint'])
+#
 #         # The breakpoint should have a hit count of 2.
-#         self.ci.HandleCommand("breakpoint list", res)
-#         self.assertTrue(res.Succeeded())
-#         self.assertTrue(res.GetOutput().find(' resolved, hit count = 2') > 0)
-
-#         self.ci.HandleCommand("continue", res)
-#         self.assertTrue(res.Succeeded())
+#         self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+#             substrs = [' resolved, hit count = 2'])
 
 
 if __name__ == '__main__':

Modified: lldb/trunk/test/order/TestOrderFile.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/order/TestOrderFile.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/order/TestOrderFile.py (original)
+++ lldb/trunk/test/order/TestOrderFile.py Fri Aug 20 16:03:09 2010
@@ -14,15 +14,12 @@
 
     def test_order_file(self):
         """Test debug symbols follow the correct order by the order file."""
-        res = self.res
         exe = os.path.join(os.getcwd(), "a.out")
-        self.ci.HandleCommand("file " + exe, res)
-        self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Test that the debug symbols have Function f3 before Function f1.
-        self.ci.HandleCommand("image dump symtab a.out", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('image dump'))
-        output = res.GetOutput()
+        self.runCmd("image dump symtab a.out")
+        output = self.res.GetOutput()
         mo_f3 = re.search("Function +.+f3", output)
         mo_f1 = re.search("Function +.+f1", output)
         
@@ -30,9 +27,7 @@
         self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start(),
                         "Symbols have correct order by the order file")
 
-        self.ci.HandleCommand("run", res)
-        self.runStarted = True
-        self.assertTrue(res.Succeeded(), RUN_COMPLETED)
+        self.runCmd("run", RUN_COMPLETED)
 
 
 if __name__ == '__main__':

Modified: lldb/trunk/test/persistent_variables/TestPersistentVariables.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/persistent_variables/TestPersistentVariables.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/persistent_variables/TestPersistentVariables.py (original)
+++ lldb/trunk/test/persistent_variables/TestPersistentVariables.py Fri Aug 20 16:03:09 2010
@@ -13,38 +13,23 @@
 
     def test_persistent_variables(self):
         """Test that lldb persistent variables works correctly."""
-        res = self.res
+        self.runCmd("file ../array_types/a.out", CURRENT_EXECUTABLE_SET)
 
-        self.ci.HandleCommand("file ../array_types/a.out", res)
-        self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+        self.runCmd("breakpoint set --name main")
 
-        self.ci.HandleCommand("breakpoint set --name main", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
+        self.runCmd("run", RUN_STOPPED)
 
-        self.ci.HandleCommand("run", res)
-        self.runStarted = True
-        self.assertTrue(res.Succeeded(), RUN_STOPPED)
-
-        self.ci.HandleCommand("expr int $i = 5; $i + 1", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('expr int $i = 5; $i + 1'))
-        #print res.GetOutput()
+        self.runCmd("expr int $i = 5; $i + 1")
         # $0 = (int)6
 
-        self.ci.HandleCommand("expr $i + 3", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('expr $i + 3'))
-        #print res.GetOutput()
+        self.runCmd("expr $i + 3")
         # $1 = (int)8
 
-        self.ci.HandleCommand("expr $1 + $0", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('expr $1 + $0'))
-        #print res.GetOutput()
+        self.runCmd("expr $1 + $0")
         # $2 = (int)14
 
-        self.ci.HandleCommand("expr $2", res)
-        self.assertTrue(res.Succeeded() and
-                        res.GetOutput().startswith("$3 = (int) 14"),
-                        CMD_MSG('expr $2'))
-        #print res.GetOutput()
+        self.expect("expr $2",
+            startstr = "$3 = (int) 14")
         # $3 = (int)14
 
 

Modified: lldb/trunk/test/set_values/TestSetValues.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/set_values/TestSetValues.py (original)
+++ lldb/trunk/test/set_values/TestSetValues.py Fri Aug 20 16:03:09 2010
@@ -11,111 +11,81 @@
 
     def test_set_values(self):
         """Test settings and readings of program variables."""
-        res = self.res
         exe = os.path.join(os.getcwd(), "a.out")
-        self.ci.HandleCommand("file " + exe, res)
-        self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Set breakpoints on several places to set program variables.
-        self.ci.HandleCommand("breakpoint set -f main.c -l 15", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 1: file ='main.c', line = 15, locations = 1"),
-                        BREAKPOINT_CREATED)
-        self.ci.HandleCommand("breakpoint set -f main.c -l 36", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 2: file ='main.c', line = 36, locations = 1"),
-                        BREAKPOINT_CREATED)
-        self.ci.HandleCommand("breakpoint set -f main.c -l 57", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 3: file ='main.c', line = 57, locations = 1"),
-                        BREAKPOINT_CREATED)
-        self.ci.HandleCommand("breakpoint set -f main.c -l 78", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 4: file ='main.c', line = 78, locations = 1"),
-                        BREAKPOINT_CREATED)
-        self.ci.HandleCommand("breakpoint set -f main.c -l 85", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 5: file ='main.c', line = 85, locations = 1"),
-                        BREAKPOINT_CREATED)
-
-        self.ci.HandleCommand("run", res)
-        self.runStarted = True
-        self.assertTrue(res.Succeeded(), RUN_STOPPED)
+        self.expect("breakpoint set -f main.c -l 15", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.c', line = 15, locations = 1")
+
+        self.expect("breakpoint set -f main.c -l 36", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 2: file ='main.c', line = 36, locations = 1")
+
+        self.expect("breakpoint set -f main.c -l 57", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 3: file ='main.c', line = 57, locations = 1")
+
+        self.expect("breakpoint set -f main.c -l 78", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 4: file ='main.c', line = 78, locations = 1")
+
+        self.expect("breakpoint set -f main.c -l 85", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 5: file ='main.c', line = 85, locations = 1")
+
+        self.runCmd("run", RUN_STOPPED)
 
         # The stop reason of the thread should be breakpoint.
-        self.ci.HandleCommand("thread list", res)
-        #print "thread list ->", res.GetOutput()
-        self.assertTrue(res.Succeeded(), CMD_MSG('thread list'))
-        self.assertTrue(res.GetOutput().find('state is Stopped') > 0 and
-                        res.GetOutput().find('stop reason = breakpoint') > 0,
-                        STOPPED_DUE_TO_BREAKPOINT)
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['state is Stopped',
+                       'stop reason = breakpoint'])
 
         # The breakpoint should have a hit count of 1.
-        self.ci.HandleCommand("breakpoint list", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint list'))
-        self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
-                        BREAKPOINT_HIT_ONCE)
+        self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
 
         # main.c:15
         # Check that 'variable list' displays the correct data type and value.
-        self.ci.HandleCommand("variable list", res);
-        self.assertTrue(res.Succeeded(), CMD_MSG('variable list'))
-        self.assertTrue(res.GetOutput().startswith("i = (char) 'a'"),
-                        VARIABLES_DISPLAYED_CORRECTLY)
+        self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY,
+            startstr = "i = (char) 'a'")
+
         # TODO:
         # Now set variable 'i' and check that it is correctly displayed.
 
-        self.ci.HandleCommand("continue", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('continue'))
+        self.runCmd("continue")
 
         # main.c:36
         # Check that 'variable list' displays the correct data type and value.
-        self.ci.HandleCommand("variable list", res);
-        self.assertTrue(res.Succeeded(), CMD_MSG('variable list'))
-        self.assertTrue(res.GetOutput().startswith(
-                "i = (short unsigned int) 0x0021"),
-                        VARIABLES_DISPLAYED_CORRECTLY)
+        self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY,
+            startstr = "i = (short unsigned int) 0x0021")
+
         # TODO:
         # Now set variable 'i' and check that it is correctly displayed.
 
-        self.ci.HandleCommand("continue", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('continue'))
+        self.runCmd("continue")
 
         # main.c:57
         # Check that 'variable list' displays the correct data type and value.
-        self.ci.HandleCommand("variable list", res);
-        self.assertTrue(res.Succeeded(), CMD_MSG('variable list'))
-        self.assertTrue(res.GetOutput().startswith("i = (long int) 33"),
-                        VARIABLES_DISPLAYED_CORRECTLY)
+        self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY,
+            startstr = "i = (long int) 33")
+
         # TODO:
         # Now set variable 'i' and check that it is correctly displayed.
 
-        self.ci.HandleCommand("continue", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('continue'))
+        self.runCmd("continue")
 
         # main.c:78
         # Check that 'variable list' displays the correct data type and value.
-        self.ci.HandleCommand("variable list", res);
-        self.assertTrue(res.Succeeded(), CMD_MSG('variable list'))
-        self.assertTrue(res.GetOutput().startswith("i = (double) 3.14159"),
-                        VARIABLES_DISPLAYED_CORRECTLY)
+        self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY,
+            startstr = "i = (double) 3.14159")
+
         # TODO:
         # Now set variable 'i' and check that it is correctly displayed.
 
-        self.ci.HandleCommand("continue", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('continue'))
+        self.runCmd("continue")
 
         # main.c:85
         # Check that 'variable list' displays the correct data type and value.
-        self.ci.HandleCommand("variable list", res);
-        self.assertTrue(res.Succeeded(), CMD_MSG('variable list'))
-        self.assertTrue(res.GetOutput().startswith("i = (long double) "),
-                        VARIABLES_DISPLAYED_CORRECTLY)
+        self.expect("variable list", VARIABLES_DISPLAYED_CORRECTLY,
+            startstr = "i = (long double) ")
+
         # TODO:
         # Now set variable 'i' and check that it is correctly displayed.
 

Modified: lldb/trunk/test/stl/TestSTL.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/stl/TestSTL.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/stl/TestSTL.py (original)
+++ lldb/trunk/test/stl/TestSTL.py Fri Aug 20 16:03:09 2010
@@ -14,58 +14,40 @@
     @unittest2.expectedFailure
     def test_step_into_stl(self):
         """Test that we can successfully step into an STL function."""
-        res = self.res
         exe = os.path.join(os.getcwd(), "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.ci.HandleCommand("file " + exe, res)
-        self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Break on line 13 of main.cpp.
-        self.ci.HandleCommand("breakpoint set -f main.cpp -l 13", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1"
-            ),
-                        BREAKPOINT_CREATED)
-
-        self.ci.HandleCommand("run", res)
-        self.runStarted = True
-        self.assertTrue(res.Succeeded(), RUN_STOPPED)
+        self.expect("breakpoint set -f main.cpp -l 13", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1")
+
+        self.runCmd("run", RUN_STOPPED)
 
         # Stop at 'std::string hello_world ("Hello World!");'.
-        self.ci.HandleCommand("thread list", res)
-        #print "thread list ->", res.GetOutput()
-        self.assertTrue(res.Succeeded(), CMD_MSG('thread list'))
-        output = res.GetOutput()
-        self.assertTrue(output.find('main.cpp:13') > 0 and
-                        output.find('stop reason = breakpoint') > 0,
-                        STOPPED_DUE_TO_BREAKPOINT)
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['main.cpp:13',
+                       'stop reason = breakpoint'])
 
         # The breakpoint should have a hit count of 1.
-        self.ci.HandleCommand("breakpoint list", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint list'))
-        self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
-                        BREAKPOINT_HIT_ONCE)
+        self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
 
         # Now do 'thread step-in', we should stop on the basic_string template.
-        self.ci.HandleCommand("thread step-in", res)
-        #print "thread step-in:", res.GetOutput()
-
         #
         # This assertion currently always fails.
         # This might be related: rdar://problem/8247112.
         #
-        self.assertTrue(res.Succeeded(), CMD_MSG("thread step-in"))
+        #self.runCmd("thread step-in", verbose=True)
+        self.runCmd("thread step-in")
 
-        self.ci.HandleCommand("thread backtrace", res)
-        print "thread backtrace:", res.GetOutput()
-        self.assertTrue(res.Succeeded(), CMD_MSG('thread backtarce'))
-        output = res.GetOutput()
-        self.assertTrue(output.find('[inlined]') > 0 and
-                        output.find('basic_string.h'),
-                        "Command 'thread backtrace' shows we stepped in STL")
+        self.expect("thread backtrace", "We have stepped in STL",
+             substrs = ['[inlined]',
+                        'basic_string.h'])
 
 
 if __name__ == '__main__':

Modified: lldb/trunk/test/struct_types/TestStructTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/struct_types/TestStructTypes.py?rev=111677&r1=111676&r2=111677&view=diff
==============================================================================
--- lldb/trunk/test/struct_types/TestStructTypes.py (original)
+++ lldb/trunk/test/struct_types/TestStructTypes.py Fri Aug 20 16:03:09 2010
@@ -15,37 +15,24 @@
 
     def test_struct_types(self):
         """Test that break on a struct declaration has no effect."""
-        res = self.res
         exe = os.path.join(os.getcwd(), "a.out")
-        self.ci.HandleCommand("file " + exe, res)
-        self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
 
         # Break on the ctor function of class C.
-        self.ci.HandleCommand("breakpoint set -f main.c -l 14", res)
-        self.assertTrue(res.Succeeded(), CMD_MSG('breakpoint set'))
-        self.assertTrue(res.GetOutput().startswith(
-            "Breakpoint created: 1: file ='main.c', line = 14, locations = 1"),
-                        BREAKPOINT_CREATED)
-
-        self.ci.HandleCommand("run", res)
-        self.runStarted = True
-        self.assertTrue(res.Succeeded(), RUN_STOPPED)
+        self.expect("breakpoint set -f main.c -l 14", BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.c', line = 14, locations = 1")
+
+        self.runCmd("run", RUN_STOPPED)
 
         # We should be stopped on the first executable statement within the
         # function where the original breakpoint was attempted.
-        self.ci.HandleCommand("thread backtrace", res)
-        #print "thread backtrace ->", res.GetOutput()
-        self.assertTrue(res.Succeeded(), CMD_MSG('thread backtarce'))
-        output = res.GetOutput()
-        self.assertTrue(output.find('main.c:20') > 0 and
-                        output.find('stop reason = breakpoint') > 0,
-                        STOPPED_DUE_TO_BREAKPOINT)
+        self.expect("thread backtrace", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['main.c:20',
+                       'stop reason = breakpoint'])
 
         # The breakpoint should have a hit count of 1.
-        self.ci.HandleCommand("breakpoint list", res)
-        self.assertTrue(res.Succeeded())
-        self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
-                        BREAKPOINT_HIT_ONCE)
+        self.expect("breakpoint list", BREAKPOINT_HIT_ONCE,
+            substrs = [' resolved, hit count = 1'])
 
 
 if __name__ == '__main__':





More information about the lldb-commits mailing list