[Lldb-commits] [lldb] r124511 - /lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py

Caroline Tice ctice at apple.com
Fri Jan 28 16:20:56 PST 2011


Author: ctice
Date: Fri Jan 28 18:20:56 2011
New Revision: 124511

URL: http://llvm.org/viewvc/llvm-project?rev=124511&view=rev
Log:
Add a test case to verify that the frame and breakpoint location
are being properly passed down to script breakpoint commands.


Modified:
    lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py

Modified: lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py?rev=124511&r1=124510&r2=124511&view=diff
==============================================================================
--- lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py (original)
+++ lldb/trunk/test/breakpoint_command/TestBreakpointCommand.py Fri Jan 28 18:20:56 2011
@@ -21,11 +21,13 @@
         """Test a sequence of breakpoint command add, list, and remove."""
         self.buildDsym()
         self.breakpoint_command_sequence()
+        self.breakpoint_command_script_parameters ()
 
     def test_with_dwarf(self):
         """Test a sequence of breakpoint command add, list, and remove."""
         self.buildDwarf()
         self.breakpoint_command_sequence()
+        self.breakpoint_command_script_parameters ()
 
     def setUp(self):
         # Call super's setUp().
@@ -127,6 +129,44 @@
         self.expect("breakpoint list", BREAKPOINT_HIT_TWICE,
             substrs = ['resolved, hit count = 2'])
 
+    def breakpoint_command_script_parameters (self):
+        """Test that the frame and breakpoint location are being properly passed to the script breakpoint command function."""
+        exe = os.path.join(os.getcwd(), "a.out")
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Add a breakpoint.
+        self.expect("breakpoint set -f main.c -l %d" % self.line,
+                    BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='main.c', line = %d, locations = 1" %
+                        self.line)
+
+        # Now add callbacks for the breakpoints just created.
+        self.runCmd("breakpoint command add -p -o 'here = open(\"output-2.txt\", \"w\"); print >> here, frame; print >> here, bp_loc; here.close()' 1")
+
+        # Remove 'output-2.txt' if it already exists.
+
+        if (os.path.exists('output-2.txt')):
+            os.remove ('output-2.txt')
+
+        # Run program, hit breakpoint, and hopefully write out new version of 'output-2.txt'
+        self.runCmd ("run", RUN_SUCCEEDED)
+
+        # Check that the file 'output.txt' exists and contains the string "lldb".
+
+        # The 'output-2.txt' file should now exist.
+        self.assertTrue(os.path.isfile("output-2.txt"),
+                        "'output-2.txt' exists due to breakpoint command for breakpoint 1.")
+
+        # Read the output file produced by running the program.
+        with open('output-2.txt', 'r') as f:
+            output = f.read()
+
+        self.expect (output, "File 'output-2.txt' and the content matches", exe=False,
+                     startstr = "frame #0:",
+                     patterns = ["1.* where = .*main .* 11.* resolved, hit count = 1" ])
+
+        # Now remove 'output-2.txt'
+        os.remove ('output-2.txt')
 
 if __name__ == '__main__':
     import atexit





More information about the lldb-commits mailing list