[Lldb-commits] [lldb] r149324 - in /lldb/trunk/test/functionalities: completion/TestCompletion.py watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py

Johnny Chen johnny.chen at apple.com
Mon Jan 30 17:26:28 PST 2012


Author: johnny
Date: Mon Jan 30 19:26:28 2012
New Revision: 149324

URL: http://llvm.org/viewvc/llvm-project?rev=149324&view=rev
Log:
Add some more test cases for the "watchpoint set" command.

Added:
    lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py
Modified:
    lldb/trunk/test/functionalities/completion/TestCompletion.py

Modified: lldb/trunk/test/functionalities/completion/TestCompletion.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/completion/TestCompletion.py?rev=149324&r1=149323&r2=149324&view=diff
==============================================================================
--- lldb/trunk/test/functionalities/completion/TestCompletion.py (original)
+++ lldb/trunk/test/functionalities/completion/TestCompletion.py Mon Jan 30 19:26:28 2012
@@ -26,10 +26,22 @@
         """Test that 'frame variable -w ' completes to ['Available completions:', 'read', 'write', 'read_write']."""
         self.complete_from_to('frame variable -w ', ['Available completions:', 'read', 'write', 'read_write'])
 
+    def test_watchpoint_set_dash_x(self):
+        """Test that 'watchpoint set -x' completes to 'watchpoint set -x '."""
+        self.complete_from_to('watchpoint set -x', 'watchpoint set -x ')
+
+    def test_watchpoint_set_dash_w_read_underbar(self):
+        """Test that 'watchpoint set -w read_' completes to 'watchpoint set -w read_write'."""
+        self.complete_from_to('watchpoint set -w read_', 'watchpoint set -w read_write')
+
     def test_help_fi(self):
         """Test that 'help fi' completes to ['Available completions:', 'file', 'finish']."""
         self.complete_from_to('help fi', ['Available completions:', 'file', 'finish'])
 
+    def test_help_watchpoint_s(self):
+        """Test that 'help watchpoint s' completes to 'help watchpoint set '."""
+        self.complete_from_to('help watchpoint s', 'help watchpoint set ')
+
     def test_settings_append_target_er(self):
         """Test that 'settings append target.er' completes to 'settings append target.error-path'."""
         self.complete_from_to('settings append target.er', 'settings append target.error-path')

Added: lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py?rev=149324&view=auto
==============================================================================
--- lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py (added)
+++ lldb/trunk/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py Mon Jan 30 19:26:28 2012
@@ -0,0 +1,67 @@
+"""
+Test error cases for the 'watchpoint set' command to make sure it errors out when necessary.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class WatchpointSetErrorTestCase(TestBase):
+
+    mydir = os.path.join("functionalities", "watchpoint", "watchpoint_set_command")
+
+    def test_error_cases_with_watchpoint_set(self):
+        """Test error cases with the 'watchpoint set' command."""
+        self.buildDwarf(dictionary=self.d)
+        self.setTearDownCleanup(dictionary=self.d)
+        self.error_cases_with_watchpoint_set()
+
+    def setUp(self):
+        # Call super's setUp().
+        TestBase.setUp(self)
+        # Our simple source filename.
+        self.source = 'main.cpp'
+        # Find the line number to break inside main().
+        self.line = line_number(self.source, '// Set break point at this line.')
+        # Build dictionary to have unique executable names for each test method.
+        self.exe_name = self.testMethodName
+        self.d = {'CXX_SOURCES': self.source, 'EXE': self.exe_name}
+
+    def error_cases_with_watchpoint_set(self):
+        """Test error cases with the 'watchpoint set' command."""
+        exe = os.path.join(os.getcwd(), self.exe_name)
+        self.runCmd("file " + exe, CURRENT_EXECUTABLE_SET)
+
+        # Add a breakpoint to set a watchpoint when stopped on the breakpoint.
+        self.expect("breakpoint set -l %d" % self.line, BREAKPOINT_CREATED,
+            startstr = "Breakpoint created: 1: file ='%s', line = %d, locations = 1" %
+                       (self.source, self.line))
+
+        # Run the program.
+        self.runCmd("run", RUN_SUCCEEDED)
+
+        # We should be stopped again due to the breakpoint.
+        # The stop reason of the thread should be breakpoint.
+        self.expect("thread list", STOPPED_DUE_TO_BREAKPOINT,
+            substrs = ['stopped',
+                       'stop reason = breakpoint'])
+
+        # Try some error conditions:
+
+        # No argument is an error.
+        self.expect("watchpoint set", error=True,
+            substrs = ['specify your target variable',
+                       'or expression',
+                       'to watch for'])
+
+        # Wrong size parameter is an error.
+        self.expect("watchpoint set -x -128", error=True,
+            substrs = ['invalid enumeration value'])
+
+
+if __name__ == '__main__':
+    import atexit
+    lldb.SBDebugger.Initialize()
+    atexit.register(lambda: lldb.SBDebugger.Terminate())
+    unittest2.main()





More information about the lldb-commits mailing list