Checked in an initial template for the types directory. Right now, it doesn't

actually test-and-compare anything yet.  The lldbtest.TestBase has an added
method setTearDownCleanup(dictionary=None) to facilitate running the cleanup
right after each data type test is run.  The test case can pass a dictionary
object when registering the test case cleanup.

There is currently only int_type test in the repository.

llvm-svn: 114600
This commit is contained in:
Johnny Chen 2010-09-22 23:00:20 +00:00
parent 3231d13ddd
commit c70b02a324
3 changed files with 107 additions and 27 deletions

View File

@ -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):

View File

@ -17,18 +17,6 @@ import lldbtest
#print "Hello, darwin plugin!"
def getCCSpec(compiler):
"""
Helper function to return the key-value string to specify the compiler
used for the make system.
"""
cc = compiler if compiler else None
if not cc and "LLDB_CC" in os.environ:
cc = os.environ["LLDB_CC"]
# Note the leading space character.
return (" CC=" + cc) if cc else ""
def getArchSpec(architecture):
"""
Helper function to return the key-value string to specify the architecture
@ -41,38 +29,69 @@ def getArchSpec(architecture):
# 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
used for the make system.
"""
cc = compiler if compiler else None
if not cc and "LLDB_CC" in os.environ:
cc = os.environ["LLDB_CC"]
def buildDefault(architecture=None, compiler=None):
# Note the leading space character.
return (" CC=" + cc) if cc else ""
def getCmdLine(d):
"""
Helper function to return a properly formatted command line argument(s)
string used for the make system.
"""
# 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 " " + cmdline
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

View File

@ -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()