forked from OSchip/llvm-project
Modified the remaining test cases to display more meaningful assert messages.
Added a generic message generator to the lldbtest.py base module. llvm-svn: 110625
This commit is contained in:
parent
5aee162f97
commit
1794184ada
|
@ -21,14 +21,15 @@ class TestArrayTypes(TestBase):
|
|||
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 @@ class TestArrayTypes(TestBase):
|
|||
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.
|
||||
|
||||
|
|
|
@ -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 @@ class TestClassTypes(lldbtest.TestBase):
|
|||
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())
|
||||
|
|
|
@ -7,9 +7,9 @@ See also http://llvm.org/viewvc/llvm-project?view=rev&revision=109673.
|
|||
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 @@ class TestCommandSource(lldbtest.TestBase):
|
|||
# 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__':
|
||||
|
|
|
@ -5,9 +5,9 @@ Test that breakpoint works correctly in the presence of dead-code stripping.
|
|||
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 @@ class TestDeadStrip(lldbtest.TestBase):
|
|||
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 @@ class TestDeadStrip(lldbtest.TestBase):
|
|||
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 @@ class TestDeadStrip(lldbtest.TestBase):
|
|||
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())
|
||||
|
|
|
@ -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 @@ class TestFunctionTypes(lldbtest.TestBase):
|
|||
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 @@ class TestFunctionTypes(lldbtest.TestBase):
|
|||
#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())
|
||||
|
|
|
@ -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 @@ class TestGlobalVariables(lldbtest.TestBase):
|
|||
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 @@ class TestGlobalVariables(lldbtest.TestBase):
|
|||
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())
|
||||
|
|
|
@ -7,9 +7,9 @@ See also CommandInterpreter::OutputFormattedHelpText().
|
|||
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 @@ class TestHelpCommand(lldbtest.TestBase):
|
|||
"""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__':
|
||||
|
|
|
@ -37,11 +37,13 @@ import lldb
|
|||
|
||||
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 @@ STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in"
|
|||
|
||||
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."""
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ Test that breakpoint by symbol name works correctly dlopen'ing a dynamic lib.
|
|||
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 @@ class TestLoadUnload(lldbtest.TestBase):
|
|||
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 @@ class TestLoadUnload(lldbtest.TestBase):
|
|||
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())
|
||||
|
|
|
@ -6,9 +6,9 @@ import os, time
|
|||
import re
|
||||
import unittest2
|
||||
import lldb
|
||||
import lldbtest
|
||||
from lldbtest import *
|
||||
|
||||
class TestOrderFile(lldbtest.TestBase):
|
||||
class TestOrderFile(TestBase):
|
||||
|
||||
mydir = "order"
|
||||
|
||||
|
@ -17,7 +17,7 @@ class TestOrderFile(lldbtest.TestBase):
|
|||
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 @@ class TestOrderFile(lldbtest.TestBase):
|
|||
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__':
|
||||
|
|
|
@ -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 @@ class TestSetValues(lldbtest.TestBase):
|
|||
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 @@ class TestSetValues(lldbtest.TestBase):
|
|||
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 @@ class TestSetValues(lldbtest.TestBase):
|
|||
# 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 @@ class TestSetValues(lldbtest.TestBase):
|
|||
# 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 @@ class TestSetValues(lldbtest.TestBase):
|
|||
# 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.
|
||||
|
||||
|
|
|
@ -5,9 +5,9 @@ Test that we can successfully step into an STL function.
|
|||
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 @@ class TestSTL(lldbtest.TestBase):
|
|||
#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 @@ class TestSTL(lldbtest.TestBase):
|
|||
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())
|
||||
|
|
|
@ -7,9 +7,9 @@ Instead, the first executable statement is set as the breakpoint.
|
|||
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 @@ class TestStructTypes(lldbtest.TestBase):
|
|||
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())
|
||||
|
|
|
@ -6,9 +6,9 @@ import os, time
|
|||
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 @@ class TestUnsignedTypes(lldbtest.TestBase):
|
|||
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 @@ class TestUnsignedTypes(lldbtest.TestBase):
|
|||
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)
|
||||
|
|
Loading…
Reference in New Issue