[Lldb-commits] [lldb] r121442 - in /lldb/trunk/test: dotest.py expression_command/test/TestExprs.py lldbtest.py
Johnny Chen
johnny.chen at apple.com
Thu Dec 9 16:51:23 PST 2010
Author: johnny
Date: Thu Dec 9 18:51:23 2010
New Revision: 121442
URL: http://llvm.org/viewvc/llvm-project?rev=121442&view=rev
Log:
Add an infrastructure to mark the Python APIs only test using a decorator.
Example:
@python_api_test
def test_evaluate_expression_python(self):
"""Test SBFrame.EvaluateExpression() API for evaluating an expression."""
...
The opposite of Python APIs only test is an lldb command line test, which sends
commands to the lldb command interpreter. Add a '-a' option to the test driver
to skip Python API only tests.
Modify TestExprs.py to mark a test as @python_api_test and remove an @expectedFailure
decorator as the bug has been fixed.
Modified:
lldb/trunk/test/dotest.py
lldb/trunk/test/expression_command/test/TestExprs.py
lldb/trunk/test/lldbtest.py
Modified: lldb/trunk/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/dotest.py?rev=121442&r1=121441&r2=121442&view=diff
==============================================================================
--- lldb/trunk/test/dotest.py (original)
+++ lldb/trunk/test/dotest.py Thu Dec 9 18:51:23 2010
@@ -45,6 +45,14 @@
# The test suite.
suite = unittest2.TestSuite()
+# By default, both command line and Python API tests are performed.
+# See @python_api_test decorator in lldbtest.py.
+dont_do_python_api_test = False
+
+# By default, both command line and Python API tests are performed.
+# This does not work yet as the @lldb_command_test decorator is needed.
+just_do_python_api_test = False
+
# The blacklist is optional (-b blacklistFile) and allows a central place to skip
# testclass's and/or testclass.testmethod's.
blacklist = None
@@ -113,6 +121,8 @@
Usage: dotest.py [option] [args]
where options:
-h : print this help message and exit (also --help)
+-a : don't do lldb Python API tests
+ use @python_api_test to decorate a test case as lldb Python API test
-b : read a blacklist file specified after this option
-c : read a config file specified after this option
(see also lldb-trunk/example/test/usage-config)
@@ -231,6 +241,8 @@
'-h/--help as the first option prints out usage info and exit the program.
"""
+ global dont_do_python_api_test
+ global just_do_python_api_test
global blacklist
global blacklistConfig
global configFile
@@ -253,12 +265,21 @@
# Process possible trace and/or verbose flag, among other things.
index = 1
while index < len(sys.argv):
- if not sys.argv[index].startswith('-'):
+ if sys.argv[index].startswith('-') or sys.argv[index].startswith('+'):
+ # We should continue processing...
+ pass
+ else:
# End of option processing.
break
if sys.argv[index].find('-h') != -1:
usage()
+ elif sys.argv[index].startswith('-a'):
+ dont_do_python_api_test = True
+ index += 1
+ elif sys.argv[index].startswith('+a'):
+ just_do_python_api_test = True
+ index += 1
elif sys.argv[index].startswith('-b'):
# Increment by 1 to fetch the blacklist file name option argument.
index += 1
@@ -624,9 +645,13 @@
# Create a singleton SBDebugger in the lldb namespace.
lldb.DBG = lldb.SBDebugger.Create()
-# And put the blacklist in the lldb namespace, to be used by lldb.TestBase.
+# Put the blacklist in the lldb namespace, to be used by lldb.TestBase.
lldb.blacklist = blacklist
+# Put dont/just_do_python_api_test in the lldb namespace, too.
+lldb.dont_do_python_api_test = dont_do_python_api_test
+lldb.just_do_python_api_test = just_do_python_api_test
+
# Turn on lldb loggings if necessary.
lldbLoggings()
Modified: lldb/trunk/test/expression_command/test/TestExprs.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/expression_command/test/TestExprs.py?rev=121442&r1=121441&r2=121442&view=diff
==============================================================================
--- lldb/trunk/test/expression_command/test/TestExprs.py (original)
+++ lldb/trunk/test/expression_command/test/TestExprs.py Thu Dec 9 18:51:23 2010
@@ -78,7 +78,7 @@
os.path.join(self.mydir, "a.out")])
# (const char *) $8 = 0x... "/Volumes/data/lldb/svn/trunk/test/expression_command/test/a.out"
-
+ @python_api_test
def test_evaluate_expression_python(self):
"""These SBFrame.EvaluateExpression() API."""
self.buildDefault()
@@ -161,8 +161,6 @@
startstr = "'Z'")
self.DebugSBValue(frame, val)
-
- @unittest2.expectedFailure
# rdar://problem/8686536
# CommandInterpreter::HandleCommand is stripping \'s from input for WantsRawCommand commands
def test_expr_commands_can_handle_quotes(self):
@@ -212,7 +210,9 @@
# output:
self.runCmd(r'''command alias print_hi expression printf ("\n\tHi!\n")''')
# This fails currently.
- self.runCmd('print_hi')
+ self.expect('print_hi',
+ substrs = ['(unsigned long) $',
+ '6'])
if __name__ == '__main__':
Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=121442&r1=121441&r2=121442&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Thu Dec 9 18:51:23 2010
@@ -227,6 +227,16 @@
a_pointer = ctypes.c_void_p(0xffff)
return 8 * ctypes.sizeof(a_pointer)
+from functools import wraps
+def python_api_test(func):
+ """Decorate the item as a Python API only test."""
+ @wraps(func)
+ def wrapper(self, *args, **kwargs):
+ if lldb.dont_do_python_api_test:
+ self.skipTest("Skip Python API tests")
+ return func(self, *args, **kwargs)
+
+ return wrapper
class recording(StringIO.StringIO):
"""
More information about the lldb-commits
mailing list