summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lldb/test/lldbtest.py28
-rw-r--r--lldb/test/plugins/darwin.py51
-rw-r--r--lldb/test/types/TestBasicTypes.py45
3 files changed, 102 insertions, 22 deletions
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py
index f950185d5ad..ea9e3228ba2 100644
--- a/lldb/test/lldbtest.py
+++ b/lldb/test/lldbtest.py
@@ -132,6 +132,8 @@ BREAKPOINT_PENDING_CREATED = "Pending breakpoint created successfully"
BREAKPOINT_HIT_ONCE = "Breakpoint resolved with hit cout = 1"
+STEP_OUT_SUCCEEDED = "Thread step-out succeeded"
+
STOPPED_DUE_TO_BREAKPOINT = "Process state is stopped due to breakpoint"
STOPPED_DUE_TO_STEP_IN = "Process state is stopped due to step in"
@@ -354,6 +356,14 @@ class TestBase(unittest2.TestCase):
# And the result object.
self.res = lldb.SBCommandReturnObject()
+ # These are for customized teardown cleanup.
+ self.dict = None
+ self.doTearDownCleanup = False
+
+ def setTearDownCleanup(self, dictionary=None):
+ self.dict = dictionary
+ self.doTearDownCleanup = True
+
def tearDown(self):
#import traceback
#traceback.print_stack()
@@ -367,6 +377,12 @@ class TestBase(unittest2.TestCase):
del self.dbg
+ # Perform registered teardown cleanup.
+ if self.doTearDownCleanup:
+ module = __import__(sys.platform)
+ if not module.cleanup(dictionary=self.dict):
+ raise Exception("Don't know how to do cleanup")
+
def runCmd(self, cmd, msg=None, check=True, trace=False, setCookie=True):
"""
Ask the command interpreter to handle the command and then check its
@@ -549,22 +565,22 @@ class TestBase(unittest2.TestCase):
# End of while loop.
- def buildDefault(self, compiler=None):
+ def buildDefault(self, architecture=None, compiler=None, dictionary=None):
"""Platform specific way to build the default binaries."""
module = __import__(sys.platform)
- if not module.buildDefault(compiler):
+ if not module.buildDefault(architecture, compiler, dictionary):
raise Exception("Don't know how to build default binary")
- def buildDsym(self, compiler=None):
+ def buildDsym(self, architecture=None, compiler=None, dictionary=None):
"""Platform specific way to build binaries with dsym info."""
module = __import__(sys.platform)
- if not module.buildDsym(compiler):
+ if not module.buildDsym(architecture, compiler, dictionary):
raise Exception("Don't know how to build binary with dsym")
- def buildDwarf(self, compiler=None):
+ def buildDwarf(self, architecture=None, compiler=None, dictionary=None):
"""Platform specific way to build binaries with dwarf maps."""
module = __import__(sys.platform)
- if not module.buildDwarf(compiler):
+ if not module.buildDwarf(architecture, compiler, dictionary):
raise Exception("Don't know how to build binary with dwarf")
def DebugSBValue(self, frame, val):
diff --git a/lldb/test/plugins/darwin.py b/lldb/test/plugins/darwin.py
index ee861dc3e3d..b41fb6ff50e 100644
--- a/lldb/test/plugins/darwin.py
+++ b/lldb/test/plugins/darwin.py
@@ -17,6 +17,18 @@ import lldbtest
#print "Hello, darwin plugin!"
+def getArchSpec(architecture):
+ """
+ Helper function to return the key-value string to specify the architecture
+ used for the make system.
+ """
+ arch = architecture if architecture else None
+ if not arch and "LLDB_ARCH" in os.environ:
+ arch = os.environ["LLDB_ARCH"]
+
+ # Note the leading space character.
+ return (" ARCH=" + arch) if arch else ""
+
def getCCSpec(compiler):
"""
Helper function to return the key-value string to specify the compiler
@@ -29,50 +41,57 @@ def getCCSpec(compiler):
# Note the leading space character.
return (" CC=" + cc) if cc else ""
-def getArchSpec(architecture):
+def getCmdLine(d):
"""
- Helper function to return the key-value string to specify the architecture
- used for the make system.
+ Helper function to return a properly formatted command line argument(s)
+ string used for the make system.
"""
- arch = architecture if architecture else None
- if not arch and "LLDB_ARCH" in os.environ:
- arch = os.environ["LLDB_ARCH"]
+
+ # If d is None or an empty mapping, just return an empty string.
+ if not d:
+ return ""
+
+ cmdline = " ".join(["%s='%s'" % (k, v) for k, v in d.items()])
# Note the leading space character.
- return (" ARCH=" + arch) if arch else ""
+ return " " + cmdline
-def buildDefault(architecture=None, compiler=None):
+def buildDefault(architecture=None, compiler=None, dictionary=None):
"""Build the binaries the default way."""
lldbtest.system(["/bin/sh", "-c",
"make clean; make"
- + getArchSpec(architecture) + getCCSpec(compiler)])
+ + getArchSpec(architecture) + getCCSpec(compiler)
+ + getCmdLine(dictionary)])
# True signifies that we can handle building default.
return True
-def buildDsym(architecture=None, compiler=None):
+def buildDsym(architecture=None, compiler=None, dictionary=None):
"""Build the binaries with dsym debug info."""
lldbtest.system(["/bin/sh", "-c",
"make clean; make MAKE_DSYM=YES"
- + getArchSpec(architecture) + getCCSpec(compiler)])
+ + getArchSpec(architecture) + getCCSpec(compiler)
+ + getCmdLine(dictionary)])
# True signifies that we can handle building dsym.
return True
-def buildDwarf(architecture=None, compiler=None):
+def buildDwarf(architecture=None, compiler=None, dictionary=None):
"""Build the binaries with dwarf debug info."""
lldbtest.system(["/bin/sh", "-c",
"make clean; make MAKE_DSYM=NO"
- + getArchSpec(architecture) + getCCSpec(compiler)])
+ + getArchSpec(architecture) + getCCSpec(compiler)
+ + getCmdLine(dictionary)])
# True signifies that we can handle building dsym.
return True
-def cleanup():
- """Do class-wide cleanup after the test."""
+def cleanup(dictionary=None):
+ """Perform a platform-specific cleanup after the test."""
if os.path.isfile("Makefile"):
- lldbtest.system(["/bin/sh", "-c", "make clean"])
+ lldbtest.system(["/bin/sh", "-c", "make clean" + getCmdLine(dictionary)]
+ )
# True signifies that we can handle building dsym.
return True
diff --git a/lldb/test/types/TestBasicTypes.py b/lldb/test/types/TestBasicTypes.py
new file mode 100644
index 00000000000..c4aa918d978
--- /dev/null
+++ b/lldb/test/types/TestBasicTypes.py
@@ -0,0 +1,45 @@
+"""
+Test that variables of basic types are displayed correctly.
+"""
+
+import os, time
+import unittest2
+import lldb
+from lldbtest import *
+
+class BasicTypesTestCase(TestBase):
+
+ mydir = "types"
+
+ def test_int_type_with_dsym(self):
+ """Test that int-type variables are displayed correctly."""
+ d = {'CXX_SOURCES': 'int.cpp'}
+ self.buildDsym(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.int_type()
+
+ def test_int_type_with_dwarf(self):
+ """Test that int-type variables are displayed correctly."""
+ d = {'CXX_SOURCES': 'int.cpp'}
+ self.buildDwarf(dictionary=d)
+ self.setTearDownCleanup(dictionary=d)
+ self.int_type()
+
+ def int_type(self):
+ """Test that int-type variables are displayed correctly."""
+ self.runCmd("file a.out", CURRENT_EXECUTABLE_SET)
+
+ self.runCmd("breakpoint set --name Puts")
+
+ self.runCmd("run", RUN_SUCCEEDED)
+
+ self.runCmd("thread step-out", STEP_OUT_SUCCEEDED)
+
+ self.runCmd("frame variable a")
+
+
+if __name__ == '__main__':
+ import atexit
+ lldb.SBDebugger.Initialize()
+ atexit.register(lambda: lldb.SBDebugger.Terminate())
+ unittest2.main()
OpenPOWER on IntegriCloud