[Lldb-commits] [lldb] r110625 - in /lldb/trunk/test: array_types/TestArrayTypes.py class_types/TestClassTypes.py command_source/TestCommandSource.py dead-strip/TestDeadStrip.py function_types/TestFunctionTypes.py global_variables/TestGlobalVariables.py help/TestHelp.py lldbtest.py load_unload/TestLoadUnload.py order/TestOrderFile.py set_values/TestSetValues.py stl/TestSTL.py struct_types/TestStructTypes.py unsigned_types/TestUnsignedTypes.py
Johnny Chen
johnny.chen at apple.com
Mon Aug 9 16:44:24 PDT 2010
Author: johnny
Date: Mon Aug 9 18:44:24 2010
New Revision: 110625
URL: http://llvm.org/viewvc/llvm-project?rev=110625&view=rev
Log:
Modified the remaining test cases to display more meaningful assert messages.
Added a generic message generator to the lldbtest.py base module.
Modified:
lldb/trunk/test/array_types/TestArrayTypes.py
lldb/trunk/test/class_types/TestClassTypes.py
lldb/trunk/test/command_source/TestCommandSource.py
lldb/trunk/test/dead-strip/TestDeadStrip.py
lldb/trunk/test/function_types/TestFunctionTypes.py
lldb/trunk/test/global_variables/TestGlobalVariables.py
lldb/trunk/test/help/TestHelp.py
lldb/trunk/test/lldbtest.py
lldb/trunk/test/load_unload/TestLoadUnload.py
lldb/trunk/test/order/TestOrderFile.py
lldb/trunk/test/set_values/TestSetValues.py
lldb/trunk/test/stl/TestSTL.py
lldb/trunk/test/struct_types/TestStructTypes.py
lldb/trunk/test/unsigned_types/TestUnsignedTypes.py
Modified: lldb/trunk/test/array_types/TestArrayTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/array_types/TestArrayTypes.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/array_types/TestArrayTypes.py (original)
+++ lldb/trunk/test/array_types/TestArrayTypes.py Mon Aug 9 18:44:24 2010
@@ -21,14 +21,15 @@
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 1: file ='main.c', line = 42, locations = 1"),
- BREAK_POINT_CREATED)
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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())
self.assertTrue(res.GetOutput().find('state is Stopped') > 0 and
res.GetOutput().find('stop reason = breakpoint') > 0,
@@ -38,7 +39,7 @@
self.ci.HandleCommand("breakpoint list", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().find('resolved, hit count = 1') > 0,
- BREAK_POINT_HIT_ONCE)
+ BREAKPOINT_HIT_ONCE)
# Issue 'variable list' command on several array-type variables.
Modified: lldb/trunk/test/class_types/TestClassTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/class_types/TestClassTypes.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/class_types/TestClassTypes.py (original)
+++ lldb/trunk/test/class_types/TestClassTypes.py Mon Aug 9 18:44:24 2010
@@ -3,9 +3,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestClassTypes(lldbtest.TestBase):
+class TestClassTypes(TestBase):
mydir = "class_types"
@@ -14,34 +14,38 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break on the ctor function of class C.
self.ci.HandleCommand("breakpoint set -f main.cpp -l 73", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.cpp', line = 73, locations = 1"))
+ "Breakpoint created: 1: file ='main.cpp', line = 73, locations = 1"),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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())
+ #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)
+ res.GetOutput().find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
# We should be stopped on the ctor function of class C.
self.ci.HandleCommand("variable list this", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith('(class C *const) this = '))
+ self.assertTrue(res.GetOutput().startswith('(class C *const) this = '),
+ VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/command_source/TestCommandSource.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/command_source/TestCommandSource.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/command_source/TestCommandSource.py (original)
+++ lldb/trunk/test/command_source/TestCommandSource.py Mon Aug 9 18:44:24 2010
@@ -7,9 +7,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestCommandSource(lldbtest.TestBase):
+class TestCommandSource(TestBase):
mydir = "command_source"
@@ -20,13 +20,13 @@
# Sourcing .lldb in the current working directory, which in turn imports
# the "my" package that defines the date() function.
self.ci.HandleCommand("command source .lldb", res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CMD_MSG('command source .lldb'))
# Python should evaluate "my.date()" successfully.
self.ci.HandleCommand("script my.date()", res)
if (not res.Succeeded()):
print res.GetError()
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CMD_MSG('script my.date()'))
if __name__ == '__main__':
Modified: lldb/trunk/test/dead-strip/TestDeadStrip.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dead-strip/TestDeadStrip.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/dead-strip/TestDeadStrip.py (original)
+++ lldb/trunk/test/dead-strip/TestDeadStrip.py Mon Aug 9 18:44:24 2010
@@ -5,9 +5,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestDeadStrip(lldbtest.TestBase):
+class TestDeadStrip(TestBase):
mydir = "dead-strip"
@@ -16,32 +16,35 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break by function name f1 (live code).
self.ci.HandleCommand("breakpoint set -s a.out -n f1", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 1: name = 'f1', module = a.out, locations = 1"
- ))
+ ),
+ BREAKPOINT_CREATED)
# Break by function name f2 (dead code).
self.ci.HandleCommand("breakpoint set -s a.out -n f2", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 2: name = 'f2', module = a.out, locations = 0 "
- "(pending)"))
+ "(pending)"),
+ BREAKPOINT_CREATED)
# Break by function name f3 (live code).
self.ci.HandleCommand("breakpoint set -s a.out -n f3", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 3: name = 'f3', module = a.out, locations = 1"
- ))
+ ),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint (breakpoint #1).
self.ci.HandleCommand("thread list", res)
@@ -50,12 +53,14 @@
self.assertTrue(output.find('state is Stopped') > 0 and
output.find('main.c:20') > 0 and
output.find('where = a.out`f1') > 0 and
- output.find('stop reason = breakpoint') > 0)
+ output.find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_BREAKPOINT)
# The breakpoint should have a hit count of 1.
self.ci.HandleCommand("breakpoint list 1", res)
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
@@ -67,12 +72,14 @@
self.assertTrue(output.find('state is Stopped') > 0 and
output.find('main.c:40') > 0 and
output.find('where = a.out`f3') > 0 and
- output.find('stop reason = breakpoint') > 0)
+ output.find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_BREAKPOINT)
# The breakpoint should have a hit count of 1.
self.ci.HandleCommand("breakpoint list 3", res)
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/function_types/TestFunctionTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/function_types/TestFunctionTypes.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/function_types/TestFunctionTypes.py (original)
+++ lldb/trunk/test/function_types/TestFunctionTypes.py Mon Aug 9 18:44:24 2010
@@ -3,9 +3,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestFunctionTypes(lldbtest.TestBase):
+class TestFunctionTypes(TestBase):
mydir = "function_types"
@@ -14,39 +14,43 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break inside the main.
self.ci.HandleCommand("breakpoint set -f main.c -l 21", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.c', line = 21, locations = 1"))
+ "Breakpoint created: 1: file ='main.c', line = 21, locations = 1"),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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())
+ #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)
+ res.GetOutput().find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
# Check that the 'callback' variable display properly.
self.ci.HandleCommand("variable list callback", res);
self.assertTrue(res.Succeeded())
output = res.GetOutput()
- self.assertTrue(output.startswith('(int (*)(char const *)) callback ='))
+ self.assertTrue(output.startswith('(int (*)(char const *)) callback ='),
+ VARIABLES_DISPLAYED_CORRECTLY)
# And that we can break on the callback function.
self.ci.HandleCommand("breakpoint set -n string_not_empty", res);
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), BREAKPOINT_CREATED)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
@@ -57,7 +61,8 @@
#print "process status =", output
self.assertTrue(output.find('where = a.out`string_not_empty') > 0 and
output.find('main.c:12') > 0 and
- output.find('stop reason = breakpoint') > 0)
+ output.find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_BREAKPOINT)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/global_variables/TestGlobalVariables.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/global_variables/TestGlobalVariables.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/global_variables/TestGlobalVariables.py (original)
+++ lldb/trunk/test/global_variables/TestGlobalVariables.py Mon Aug 9 18:44:24 2010
@@ -3,9 +3,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestGlobalVariables(lldbtest.TestBase):
+class TestGlobalVariables(TestBase):
mydir = "global_variables"
@@ -14,29 +14,32 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break inside the main.
self.ci.HandleCommand("breakpoint set -f main.c -l 20", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.c', line = 20, locations = 1"))
+ "Breakpoint created: 1: file ='main.c', line = 20, locations = 1"),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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())
+ #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)
+ res.GetOutput().find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
# Check that GLOBAL scopes are indicated for the variables.
self.ci.HandleCommand("variable list -s -a", res);
@@ -47,7 +50,8 @@
output.find('GLOBAL: g_file_global_int') > 0 and
output.find('(int) 42') > 0 and
output.find('GLOBAL: g_file_global_cstr') > 0 and
- output.find('g_file_global_cstr') > 0)
+ output.find('g_file_global_cstr') > 0,
+ VARIABLES_DISPLAYED_CORRECTLY)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/help/TestHelp.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/help/TestHelp.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/help/TestHelp.py (original)
+++ lldb/trunk/test/help/TestHelp.py Mon Aug 9 18:44:24 2010
@@ -7,9 +7,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestHelpCommand(lldbtest.TestBase):
+class TestHelpCommand(TestBase):
mydir = "help"
@@ -17,22 +17,24 @@
"""A simple test of 'help' command and its output."""
res = lldb.SBCommandReturnObject()
self.ci.HandleCommand("help", res)
- time.sleep(0.1)
+ #time.sleep(0.1)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- 'The following is a list of built-in, permanent debugger commands'))
+ 'The following is a list of built-in, permanent debugger commands'),
+ CMD_MSG('help'))
def test_help_should_not_hang_emacsshell(self):
"""Command 'set term-width 0' should not hang the help command."""
res = lldb.SBCommandReturnObject()
self.ci.HandleCommand("set term-width 0", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), CMD_MSG('set term-width 0'))
self.ci.HandleCommand("help", res)
- time.sleep(0.1)
+ #time.sleep(0.1)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- 'The following is a list of built-in, permanent debugger commands'))
+ 'The following is a list of built-in, permanent debugger commands'),
+ CMD_MSG('help'))
if __name__ == '__main__':
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Mon Aug 9 18:44:24 2010
@@ -37,11 +37,13 @@
CURRENT_EXECUTABLE_SET = "Current executable set successfully"
-COMMAND_HANDLED = "Command handled successfully"
+RUN_STOPPED = "Process is stopped successfully"
-BREAK_POINT_CREATED = "Breakpoint created successfully"
+RUN_COMPLETED = "Process exited successfully"
-BREAK_POINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1"
+BREAKPOINT_CREATED = "Breakpoint created successfully"
+
+BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1"
STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint"
@@ -49,6 +51,13 @@
VARIABLES_DISPLAYED_CORRECTLY = "Show specified variable(s) correctly"
+#
+# And a generic "Command '%s' returns successfully" message generator.
+#
+def CMD_MSG(command):
+ return "Command '%s' returns successfully" % (command)
+
+
class TestBase(unittest2.TestCase):
"""This LLDB abstract base class is meant to be subclassed."""
Modified: lldb/trunk/test/load_unload/TestLoadUnload.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/load_unload/TestLoadUnload.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/load_unload/TestLoadUnload.py (original)
+++ lldb/trunk/test/load_unload/TestLoadUnload.py Mon Aug 9 18:44:24 2010
@@ -5,9 +5,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestLoadUnload(lldbtest.TestBase):
+class TestLoadUnload(TestBase):
mydir = "load_unload"
@@ -16,7 +16,7 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break by function name a_function (not yet loaded).
self.ci.HandleCommand("breakpoint set -n a_function", res)
@@ -24,25 +24,28 @@
self.assertTrue(res.GetOutput().startswith(
"Breakpoint created: 1: name = 'a_function', locations = 0 "
"(pending)"
- ))
+ ),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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())
+ 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)
+ output.find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/order/TestOrderFile.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/order/TestOrderFile.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/order/TestOrderFile.py (original)
+++ lldb/trunk/test/order/TestOrderFile.py Mon Aug 9 18:44:24 2010
@@ -6,9 +6,9 @@
import re
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestOrderFile(lldbtest.TestBase):
+class TestOrderFile(TestBase):
mydir = "order"
@@ -17,7 +17,7 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Test that the debug symbols have Function f3 before Function f1.
self.ci.HandleCommand("image dump symtab a.out", res)
@@ -27,10 +27,11 @@
mo_f1 = re.search("Function +.+f1", output)
# Match objects for f3 and f1 must exist and f3 must come before f1.
- self.assertTrue(mo_f3 and mo_f1 and mo_f3.start() < mo_f1.start())
+ 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.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), RUN_COMPLETED)
if __name__ == '__main__':
Modified: lldb/trunk/test/set_values/TestSetValues.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/set_values/TestSetValues.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/set_values/TestSetValues.py (original)
+++ lldb/trunk/test/set_values/TestSetValues.py Mon Aug 9 18:44:24 2010
@@ -3,9 +3,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestSetValues(lldbtest.TestBase):
+class TestSetValues(TestBase):
mydir = "set_values"
@@ -14,51 +14,59 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), 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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.c', line = 15, locations = 1"))
+ "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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 2: file ='main.c', line = 36, locations = 1"))
+ "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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 3: file ='main.c', line = 57, locations = 1"))
+ "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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 4: file ='main.c', line = 78, locations = 1"))
+ "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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 5: file ='main.c', line = 85, locations = 1"))
+ "Breakpoint created: 5: file ='main.c', line = 85, locations = 1"),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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())
+ #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)
+ res.GetOutput().find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
# main.c:15
# Check that 'variable list' displays the correct data type and value.
self.ci.HandleCommand("variable list", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith("i = (char) 'a'"))
+ self.assertTrue(res.GetOutput().startswith("i = (char) 'a'"),
+ VARIABLES_DISPLAYED_CORRECTLY)
# TODO:
# Now set variable 'i' and check that it is correctly displayed.
@@ -70,7 +78,8 @@
self.ci.HandleCommand("variable list", res);
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- "i = (short unsigned int) 0x0021"))
+ "i = (short unsigned int) 0x0021"),
+ VARIABLES_DISPLAYED_CORRECTLY)
# TODO:
# Now set variable 'i' and check that it is correctly displayed.
@@ -81,7 +90,8 @@
# Check that 'variable list' displays the correct data type and value.
self.ci.HandleCommand("variable list", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith("i = (long int) 33"))
+ self.assertTrue(res.GetOutput().startswith("i = (long int) 33"),
+ VARIABLES_DISPLAYED_CORRECTLY)
# TODO:
# Now set variable 'i' and check that it is correctly displayed.
@@ -92,7 +102,8 @@
# Check that 'variable list' displays the correct data type and value.
self.ci.HandleCommand("variable list", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith("i = (double) 3.14159"))
+ self.assertTrue(res.GetOutput().startswith("i = (double) 3.14159"),
+ VARIABLES_DISPLAYED_CORRECTLY)
# TODO:
# Now set variable 'i' and check that it is correctly displayed.
@@ -103,7 +114,8 @@
# Check that 'variable list' displays the correct data type and value.
self.ci.HandleCommand("variable list", res);
self.assertTrue(res.Succeeded())
- self.assertTrue(res.GetOutput().startswith("i = (long double) "))
+ self.assertTrue(res.GetOutput().startswith("i = (long double) "),
+ VARIABLES_DISPLAYED_CORRECTLY)
# 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=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/stl/TestSTL.py (original)
+++ lldb/trunk/test/stl/TestSTL.py Mon Aug 9 18:44:24 2010
@@ -5,9 +5,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestSTL(lldbtest.TestBase):
+class TestSTL(TestBase):
mydir = "stl"
@@ -20,42 +20,44 @@
#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())
+ self.assertTrue(res.Succeeded(), 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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1")
- )
+ "Breakpoint created: 1: file ='main.cpp', line = 13, locations = 1"
+ ),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), RUN_STOPPED)
# Stop at 'std::string hello_world ("Hello World!");'.
self.ci.HandleCommand("thread list", res)
- print "thread list ->", res.GetOutput()
+ #print "thread list ->", res.GetOutput()
self.assertTrue(res.Succeeded())
output = res.GetOutput()
self.assertTrue(output.find('main.cpp:13') > 0 and
- output.find('stop reason = breakpoint') > 0)
+ output.find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
# 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()
+ #print "thread step-in:", res.GetOutput()
#
# This assertion currently always fails.
# This might be related: rdar://problem/8247112.
#
- self.assertTrue(res.Succeeded(),
- 'Command "thread step-in" returns successfully')
+ self.assertTrue(res.Succeeded(), CMD_MSG("thread step-in"))
#self.ci.HandleCommand("process status", res)
#print "process status:", res.GetOutput()
@@ -66,7 +68,7 @@
self.assertTrue(output.find('[inlined]') > 0 and
output.find('basic_string.h') and
output.find('stop reason = step in,') > 0,
- 'Command "thread backtrace" shows we stepped in STL')
+ "Command 'thread backtrace' shows we stepped in STL")
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/struct_types/TestStructTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/struct_types/TestStructTypes.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/struct_types/TestStructTypes.py (original)
+++ lldb/trunk/test/struct_types/TestStructTypes.py Mon Aug 9 18:44:24 2010
@@ -7,9 +7,9 @@
import os, time
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestStructTypes(lldbtest.TestBase):
+class TestStructTypes(TestBase):
mydir = "struct_types"
@@ -18,31 +18,34 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), 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())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.c', line = 14, locations = 1"))
+ "Breakpoint created: 1: file ='main.c', line = 14, locations = 1"),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), 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()
+ #print "thread backtrace ->", res.GetOutput()
self.assertTrue(res.Succeeded())
output = res.GetOutput()
self.assertTrue(output.find('main.c:20') > 0 and
- output.find('stop reason = breakpoint') > 0)
+ output.find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
self.ci.HandleCommand("continue", res)
self.assertTrue(res.Succeeded())
Modified: lldb/trunk/test/unsigned_types/TestUnsignedTypes.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/unsigned_types/TestUnsignedTypes.py?rev=110625&r1=110624&r2=110625&view=diff
==============================================================================
--- lldb/trunk/test/unsigned_types/TestUnsignedTypes.py (original)
+++ lldb/trunk/test/unsigned_types/TestUnsignedTypes.py Mon Aug 9 18:44:24 2010
@@ -6,9 +6,9 @@
import re
import unittest2
import lldb
-import lldbtest
+from lldbtest import *
-class TestUnsignedTypes(lldbtest.TestBase):
+class TestUnsignedTypes(TestBase):
mydir = "unsigned_types"
@@ -17,33 +17,36 @@
res = self.res
exe = os.path.join(os.getcwd(), "a.out")
self.ci.HandleCommand("file " + exe, res)
- self.assertTrue(res.Succeeded())
+ self.assertTrue(res.Succeeded(), CURRENT_EXECUTABLE_SET)
# Break on line 19 in main() aftre the variables are assigned values.
self.ci.HandleCommand("breakpoint set -f main.cpp -l 19", res)
self.assertTrue(res.Succeeded())
self.assertTrue(res.GetOutput().startswith(
- "Breakpoint created: 1: file ='main.cpp', line = 19, locations = 1")
- )
+ "Breakpoint created: 1: file ='main.cpp', line = 19, locations = 1"
+ ),
+ BREAKPOINT_CREATED)
self.ci.HandleCommand("run", res)
- time.sleep(0.1)
- self.assertTrue(res.Succeeded())
+ #time.sleep(0.1)
+ self.assertTrue(res.Succeeded(), RUN_STOPPED)
# The stop reason of the thread should be breakpoint.
self.ci.HandleCommand("thread list", res)
- self.assertTrue(res.Succeeded())
+ 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)
+ res.GetOutput().find('stop reason = breakpoint') > 0,
+ STOPPED_DUE_TO_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)
+ self.assertTrue(res.GetOutput().find(' resolved, hit count = 1') > 0,
+ BREAKPOINT_HIT_ONCE)
# Test that unsigned types display correctly.
self.ci.HandleCommand("variable list -a", res)
- print "variable list -a ->", res.GetOutput()
+ #print "variable list -a ->", res.GetOutput()
self.assertTrue(res.Succeeded())
output = res.GetOutput()
self.assertTrue(
@@ -59,7 +62,9 @@
output.find("the_unsigned_long_long = (long long unsigned int)"
" 0x0000000000000063") > 0
and
- output.find("the_uint32 = (uint32_t) 0x00000063")
+ output.find("the_uint32 = (uint32_t) 0x00000063"),
+
+ VARIABLES_DISPLAYED_CORRECTLY
)
self.ci.HandleCommand("continue", res)
More information about the lldb-commits
mailing list