summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2012-01-31 01:26:28 +0000
committerJohnny Chen <johnny.chen@apple.com>2012-01-31 01:26:28 +0000
commit6b68c98f7d52b01b8a55896632a334b554467bad (patch)
tree3620e4708bc0b736178deb40d5737a0c7f83d716
parentea6e935e958c2140b991272ae2895fdaac9ff6d3 (diff)
downloadbcm5719-llvm-6b68c98f7d52b01b8a55896632a334b554467bad.tar.gz
bcm5719-llvm-6b68c98f7d52b01b8a55896632a334b554467bad.zip
Add some more test cases for the "watchpoint set" command.
llvm-svn: 149324
-rw-r--r--lldb/test/functionalities/completion/TestCompletion.py12
-rw-r--r--lldb/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py67
2 files changed, 79 insertions, 0 deletions
diff --git a/lldb/test/functionalities/completion/TestCompletion.py b/lldb/test/functionalities/completion/TestCompletion.py
index 7906068fddb..48a4a77def6 100644
--- a/lldb/test/functionalities/completion/TestCompletion.py
+++ b/lldb/test/functionalities/completion/TestCompletion.py
@@ -26,10 +26,22 @@ class CommandLineCompletionTestCase(TestBase):
"""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')
diff --git a/lldb/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py b/lldb/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py
new file mode 100644
index 00000000000..3ff21478460
--- /dev/null
+++ b/lldb/test/functionalities/watchpoint/watchpoint_set_command/TestWatchpointSetErrorCases.py
@@ -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()
OpenPOWER on IntegriCloud