diff options
author | Johnny Chen <johnny.chen@apple.com> | 2010-06-30 22:16:25 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2010-06-30 22:16:25 +0000 |
commit | 6ea3fc5a9f8ab265fceb805a268cde636d522641 (patch) | |
tree | a4b0369c42d98e5ea8692290cb74855e6e222066 | |
parent | 4a58ced75059a2fbf8ae65f9fda18fa40fc21807 (diff) | |
download | bcm5719-llvm-6ea3fc5a9f8ab265fceb805a268cde636d522641.tar.gz bcm5719-llvm-6ea3fc5a9f8ab265fceb805a268cde636d522641.zip |
Added TestClassTypes.py to test setting a breakpoint on a class constructor and
do 'variable list this' command when stopped.
Applied some cleanup on TestArrayTypes.py. In particular, specify the absolute
path to the object file in order not to confuse the debugger.
llvm-svn: 107330
-rw-r--r-- | lldb/test/array_types/TestArrayTypes.py | 23 | ||||
-rw-r--r-- | lldb/test/class_types/TestClassTypes.py | 60 |
2 files changed, 73 insertions, 10 deletions
diff --git a/lldb/test/array_types/TestArrayTypes.py b/lldb/test/array_types/TestArrayTypes.py index 8b626a68626..7bf5aba1d17 100644 --- a/lldb/test/array_types/TestArrayTypes.py +++ b/lldb/test/array_types/TestArrayTypes.py @@ -25,8 +25,10 @@ class TestArrayTypes(unittest.TestCase): def test_array_types(self): """Test 'variable list var_name' on some variables with array types.""" res = lldb.SBCommandReturnObject() - self.ci.HandleCommand("file a.out", res) + exe = os.path.join(os.getcwd(), "a.out") + self.ci.HandleCommand("file " + exe, res) self.assertTrue(res.Succeeded()) + self.ci.HandleCommand("breakpoint set -f main.c -l 42", res) self.assertTrue(res.Succeeded()) self.assertTrue(res.GetOutput().startswith( @@ -46,15 +48,16 @@ class TestArrayTypes(unittest.TestCase): self.ci.HandleCommand("variable list strings", res); self.assertTrue(res.Succeeded()) - self.assertTrue(res.GetOutput().startswith('(char *[4])') and - res.GetOutput().find('(char *) strings[0]') and - res.GetOutput().find('(char *) strings[1]') and - res.GetOutput().find('(char *) strings[2]') and - res.GetOutput().find('(char *) strings[3]') and - res.GetOutput().find('Hello') and - res.GetOutput().find('Hola') and - res.GetOutput().find('Bonjour') and - res.GetOutput().find('Guten Tag')) + output = res.GetOutput() + self.assertTrue(output.startswith('(char *[4])') and + output.find('(char *) strings[0]') and + output.find('(char *) strings[1]') and + output.find('(char *) strings[2]') and + output.find('(char *) strings[3]') and + output.find('Hello') and + output.find('Hola') and + output.find('Bonjour') and + output.find('Guten Tag')) self.ci.HandleCommand("variable list char_16", res); self.assertTrue(res.Succeeded()) diff --git a/lldb/test/class_types/TestClassTypes.py b/lldb/test/class_types/TestClassTypes.py new file mode 100644 index 00000000000..93f9fb06147 --- /dev/null +++ b/lldb/test/class_types/TestClassTypes.py @@ -0,0 +1,60 @@ +"""Test breakpoint on a class constructor; and variable list the this object.""" + +import os +import lldb +import unittest + +class TestClassTypes(unittest.TestCase): + + def setUp(self): + # Save old working directory. + self.oldcwd = os.getcwd() + # Change current working directory if ${LLDB_TEST} is defined. + if ("LLDB_TEST" in os.environ): + os.chdir(os.path.join(os.environ["LLDB_TEST"], "class_types")); + self.dbg = lldb.SBDebugger.Create() + self.dbg.SetAsync(False) + self.ci = self.dbg.GetCommandInterpreter() + if not self.ci: + raise Exception('Could not get the command interpreter') + + def tearDown(self): + # Restore old working directory. + os.chdir(self.oldcwd) + + def test_class_types(self): + """Test 'variable list this' when stopped on a class constructor.""" + res = lldb.SBCommandReturnObject() + exe = os.path.join(os.getcwd(), "a.out") + self.ci.HandleCommand("file " + exe, res) + self.assertTrue(res.Succeeded()) + + 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")) + + self.ci.HandleCommand("run", res) + self.assertTrue(res.Succeeded()) + + self.ci.HandleCommand("breakpoint list", res) + self.assertTrue(res.Succeeded()) + self.assertTrue(res.GetOutput().find('resolved, hit count = 1')) + + self.ci.HandleCommand("thread list", res) + self.assertTrue(res.Succeeded()) + self.assertTrue(res.GetOutput().find('state is Stopped') and + res.GetOutput().find('stop reason = breakpoint')) + + self.ci.HandleCommand("variable list this", res); + self.assertTrue(res.Succeeded()) + self.assertTrue(res.GetOutput().startswith('(class C *const) this = ')) + + self.ci.HandleCommand("continue", res) + self.assertTrue(res.Succeeded()) + + +if __name__ == '__main__': + lldb.SBDebugger.Initialize() + unittest.main() + lldb.SBDebugger.Terminate() |