summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/test/array_types/TestArrayTypes.py23
-rw-r--r--lldb/test/class_types/TestClassTypes.py60
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()
OpenPOWER on IntegriCloud