summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohnny Chen <johnny.chen@apple.com>2010-10-06 20:40:56 +0000
committerJohnny Chen <johnny.chen@apple.com>2010-10-06 20:40:56 +0000
commit56e6cbdaf0f38490061c94eb17c71bb46f9a27a6 (patch)
tree580bb8e94e875f4065ed0a56417d972a7341c41e
parent233b3a2f95b32cec22f246a191e3321d2007fd85 (diff)
downloadbcm5719-llvm-56e6cbdaf0f38490061c94eb17c71bb46f9a27a6.tar.gz
bcm5719-llvm-56e6cbdaf0f38490061c94eb17c71bb46f9a27a6.zip
Enhance the test driver with a '-f filterspec' option to specify the
testclass.testmethod to be run and with a '-g' option which instructs the test driver to only admit the module which satisfy the filterspec condition to the test suite. Example: # This only runs the test case under the array_types directory which has class # name of 'ArrayTypesTestCase' and the test method name of 'test_with_dwarf_and_run_command'. /Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' -g array_types ---------------------------------------------------------------------- Collected 1 test test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ... ok ---------------------------------------------------------------------- Ran 1 test in 1.353s OK # And this runs the test cases under the array_types and the hello_world directories. # If the module discovered has the 'ArrayTypesTestCase.test_with_dwarf_and_run_command' # attribute, only the test case specified by the filterspec for the module will be run. # If the module does not have the said attribute, e.g., the module under hello_world, # the whole module is still admitted to the test suite. /Volumes/data/lldb/svn/trunk/test $ ./dotest.py -v -f 'ArrayTypesTestCase.test_with_dwarf_and_run_command' array_types hello_world ---------------------------------------------------------------------- Collected 3 tests test_with_dwarf_and_run_command (TestArrayTypes.ArrayTypesTestCase) Test 'frame variable var_name' on some variables with array types. ... ok test_with_dsym_and_run_command (TestHelloWorld.HelloWorldTestCase) Create target, breakpoint, launch a process, and then kill it. ... ok test_with_dwarf_and_process_launch_api (TestHelloWorld.HelloWorldTestCase) Create target, breakpoint, launch a process, and then kill it. ... ok ---------------------------------------------------------------------- Ran 3 tests in 4.964s OK llvm-svn: 115832
-rwxr-xr-xlldb/test/dotest.py56
1 files changed, 55 insertions, 1 deletions
diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py
index 43f33a48f84..804b6769372 100755
--- a/lldb/test/dotest.py
+++ b/lldb/test/dotest.py
@@ -54,6 +54,12 @@ config = {}
# Delay startup in order for the debugger to attach.
delay = False
+# The filter (testcase.testmethod) used to admit tests into our test suite.
+filterspec = None
+
+# If '-g' is specified, the filterspec must be consulted for each test module, default to False.
+fs4all = False
+
# Ignore the build search path relative to this script to locate the lldb.py module.
ignore = False
@@ -81,6 +87,12 @@ where options:
-c : read a config file specified after this option
(see also lldb-trunk/example/test/usage-config)
-d : delay startup for 10 seconds (in order for the debugger to attach)
+-f : specify a filter to admit tests into the test suite
+ e.g., -f 'ClassTypesTestCase.test_with_dwarf_and_python_api'
+-g : if specified, only the modules with the corect filter will be run
+ it has no effect if no '-f' option is present
+ '-f filterspec -g' can be used with '-p filename-regexp' to select only
+ the testfile.testclass.testmethod to run
-i : ignore (don't bailout) if 'lldb.py' module cannot be located in the build
tree relative to this script; use PYTHONPATH to locate the module
-l : don't skip long running test
@@ -117,6 +129,8 @@ def parseOptionsAndInitTestdirs():
global configFile
global delay
+ global filterspec
+ global fs4all
global ignore
global skipLongRunningTest
global regexp
@@ -148,6 +162,16 @@ def parseOptionsAndInitTestdirs():
elif sys.argv[index].startswith('-d'):
delay = True
index += 1
+ elif sys.argv[index].startswith('-f'):
+ # Increment by 1 to fetch the filter spec.
+ index += 1
+ if index >= len(sys.argv) or sys.argv[index].startswith('-'):
+ usage()
+ filterspec = sys.argv[index]
+ index += 1
+ elif sys.argv[index].startswith('-g'):
+ fs4all = True
+ index += 1
elif sys.argv[index].startswith('-i'):
ignore = True
index += 1
@@ -267,6 +291,8 @@ def visit(prefix, dir, names):
global suite
global regexp
+ global filterspec
+ global fs4all
for name in names:
if os.path.isdir(os.path.join(dir, name)):
@@ -287,7 +313,35 @@ def visit(prefix, dir, names):
if not sys.path.count(dir):
sys.path.append(dir)
base = os.path.splitext(name)[0]
- suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
+
+ # Thoroughly check the filterspec against the base module and admit
+ # the (base, filterspec) combination only when it makes sense.
+ if filterspec:
+ # Optimistically set the flag to True.
+ filtered = True
+ module = __import__(base)
+ parts = filterspec.split('.')
+ obj = module
+ for part in parts:
+ try:
+ parent, obj = obj, getattr(obj, part)
+ except AttributeError:
+ # The filterspec has failed.
+ filtered = False
+ break
+ # Forgo this module if the (base, filterspec) combo is invalid
+ # and the '-g' option is present.
+ if fs4all and not filtered:
+ continue
+
+ if filterspec and filtered:
+ suite.addTests(
+ unittest2.defaultTestLoader.loadTestsFromName(filterspec, module))
+ else:
+ # A simple case of just the module name. Also the failover case
+ # from the filterspec branch when the (base, filterspec) combo
+ # doesn't make sense.
+ suite.addTests(unittest2.defaultTestLoader.loadTestsFromName(base))
def lldbLoggings():
OpenPOWER on IntegriCloud