diff options
author | Johnny Chen <johnny.chen@apple.com> | 2012-04-16 18:55:15 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2012-04-16 18:55:15 +0000 |
commit | 44d2497138095224591706b245eb10848e111c0e (patch) | |
tree | 4776dcdfc212ad85f846086dd232beb98c4413d0 /lldb | |
parent | 78158af59ca5713a1b99e4a91ad787a2c1a604bc (diff) | |
download | bcm5719-llvm-44d2497138095224591706b245eb10848e111c0e.tar.gz bcm5719-llvm-44d2497138095224591706b245eb10848e111c0e.zip |
Add the capability of supplying the pre/post-flight functions to the test suite such that
the pre-flight code gets executed during setUp() after the debugger instance is available
and the post-flight code gets executed during tearDown() after the debugger instance has
done killing the inferior and deleting all the target programs.
Example:
[11:32:48] johnny:/Volumes/data/lldb/svn/ToT/test $ ./dotest.py -A x86_64 -v -c ../examples/test/.lldb-pre-post-flight functionalities/watchpoint/hello_watchpoint
config: {'pre_flight': <function pre_flight at 0x1098541b8>, 'post_flight': <function post_flight at 0x109854230>}
LLDB build dir: /Volumes/data/lldb/svn/ToT/build/Debug
LLDB-139
Path: /Volumes/data/lldb/svn/ToT
URL: https://johnny@llvm.org/svn/llvm-project/lldb/trunk
Repository Root: https://johnny@llvm.org/svn/llvm-project
Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8
Revision: 154753
Node Kind: directory
Schedule: normal
Last Changed Author: gclayton
Last Changed Rev: 154730
Last Changed Date: 2012-04-13 18:42:46 -0700 (Fri, 13 Apr 2012)
lldb.pre_flight: def pre_flight(test):
__import__("lldb")
__import__("lldbtest")
print "\nRunning pre-flight function:"
print "for test case:", test
lldb.post_flight: def post_flight(test):
__import__("lldb")
__import__("lldbtest")
print "\nRunning post-flight function:"
print "for test case:", test
Session logs for test failures/errors/unexpected successes will go into directory '2012-04-16-11_34_08'
Command invoked: python ./dotest.py -A x86_64 -v -c ../examples/test/.lldb-pre-post-flight functionalities/watchpoint/hello_watchpoint
compilers=['clang']
Configuration: arch=x86_64 compiler=clang
----------------------------------------------------------------------
Collected 2 tests
1: test_hello_watchpoint_with_dsym_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase)
Test a simple sequence of watchpoint creation and watchpoint hit. ...
Running pre-flight function:
for test case: test_hello_watchpoint_with_dsym_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase)
Running post-flight function:
for test case: test_hello_watchpoint_with_dsym_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase)
ok
2: test_hello_watchpoint_with_dwarf_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase)
Test a simple sequence of watchpoint creation and watchpoint hit. ...
Running pre-flight function:
for test case: test_hello_watchpoint_with_dwarf_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase)
Running post-flight function:
for test case: test_hello_watchpoint_with_dwarf_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase)
ok
----------------------------------------------------------------------
Ran 2 tests in 1.584s
OK
llvm-svn: 154847
Diffstat (limited to 'lldb')
-rw-r--r-- | lldb/examples/test/.lldb-pre-post-flight | 12 | ||||
-rw-r--r-- | lldb/examples/test/.lldb-pre-post-flight.bad | 8 | ||||
-rw-r--r-- | lldb/examples/test/usage-pre-post-flight | 65 | ||||
-rwxr-xr-x | lldb/test/dotest.py | 34 | ||||
-rw-r--r-- | lldb/test/lldbtest.py | 8 |
5 files changed, 125 insertions, 2 deletions
diff --git a/lldb/examples/test/.lldb-pre-post-flight b/lldb/examples/test/.lldb-pre-post-flight new file mode 100644 index 00000000000..c1568a7295a --- /dev/null +++ b/lldb/examples/test/.lldb-pre-post-flight @@ -0,0 +1,12 @@ +def pre_flight(test): + __import__("lldb") + __import__("lldbtest") + print "\nRunning pre-flight function:" + print "for test case:", test + +def post_flight(test): + __import__("lldb") + __import__("lldbtest") + print "\nRunning post-flight function:" + print "for test case:", test + diff --git a/lldb/examples/test/.lldb-pre-post-flight.bad b/lldb/examples/test/.lldb-pre-post-flight.bad new file mode 100644 index 00000000000..0e17f3cdc95 --- /dev/null +++ b/lldb/examples/test/.lldb-pre-post-flight.bad @@ -0,0 +1,8 @@ +pre_flight = "I am not callable" + +def post_flight(test): + __import__("lldb") + __import__("lldbtest") + print "\nRunning post-flight function:" + print "for test case:", test + diff --git a/lldb/examples/test/usage-pre-post-flight b/lldb/examples/test/usage-pre-post-flight new file mode 100644 index 00000000000..da686072425 --- /dev/null +++ b/lldb/examples/test/usage-pre-post-flight @@ -0,0 +1,65 @@ +# +# The following examples first show a bad pre/post flight config file followed by a good pre/post config file. +# + +[11:31:19] johnny:/Volumes/data/lldb/svn/ToT/test $ ./dotest.py -A x86_64 -v -c ../examples/test/.lldb-pre-post-flight.bad functionalities/watchpoint/hello_watchpoint +config: {'pre_flight': 'I am not callable', 'post_flight': <function post_flight at 0x1071871b8>} +fatal error: pre_flight is not callable, exiting. +[11:32:48] johnny:/Volumes/data/lldb/svn/ToT/test $ ./dotest.py -A x86_64 -v -c ../examples/test/.lldb-pre-post-flight functionalities/watchpoint/hello_watchpoint +config: {'pre_flight': <function pre_flight at 0x1098541b8>, 'post_flight': <function post_flight at 0x109854230>} +LLDB build dir: /Volumes/data/lldb/svn/ToT/build/Debug +LLDB-139 +Path: /Volumes/data/lldb/svn/ToT +URL: https://johnny@llvm.org/svn/llvm-project/lldb/trunk +Repository Root: https://johnny@llvm.org/svn/llvm-project +Repository UUID: 91177308-0d34-0410-b5e6-96231b3b80d8 +Revision: 154753 +Node Kind: directory +Schedule: normal +Last Changed Author: gclayton +Last Changed Rev: 154730 +Last Changed Date: 2012-04-13 18:42:46 -0700 (Fri, 13 Apr 2012) + + +lldb.pre_flight: def pre_flight(test): + __import__("lldb") + __import__("lldbtest") + print "\nRunning pre-flight function:" + print "for test case:", test + +lldb.post_flight: def post_flight(test): + __import__("lldb") + __import__("lldbtest") + print "\nRunning post-flight function:" + print "for test case:", test + + +Session logs for test failures/errors/unexpected successes will go into directory '2012-04-16-11_34_08' +Command invoked: python ./dotest.py -A x86_64 -v -c ../examples/test/.lldb-pre-post-flight functionalities/watchpoint/hello_watchpoint +compilers=['clang'] + +Configuration: arch=x86_64 compiler=clang +---------------------------------------------------------------------- +Collected 2 tests + +1: test_hello_watchpoint_with_dsym_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase) + Test a simple sequence of watchpoint creation and watchpoint hit. ... +Running pre-flight function: +for test case: test_hello_watchpoint_with_dsym_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase) + +Running post-flight function: +for test case: test_hello_watchpoint_with_dsym_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase) +ok +2: test_hello_watchpoint_with_dwarf_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase) + Test a simple sequence of watchpoint creation and watchpoint hit. ... +Running pre-flight function: +for test case: test_hello_watchpoint_with_dwarf_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase) + +Running post-flight function: +for test case: test_hello_watchpoint_with_dwarf_using_watchpoint_set (TestMyFirstWatchpoint.HelloWatchpointTestCase) +ok + +---------------------------------------------------------------------- +Ran 2 tests in 1.584s + +OK
\ No newline at end of file diff --git a/lldb/test/dotest.py b/lldb/test/dotest.py index c01af3052f2..be548fb5b4c 100755 --- a/lldb/test/dotest.py +++ b/lldb/test/dotest.py @@ -96,6 +96,9 @@ count = 1 # The dictionary as a result of sourcing configFile. config = {} +# The pre_flight and post_flight functions come from reading a config file. +pre_flight = None +post_flight = None # The 'archs' and 'compilers' can be specified via either command line or configFile, # with the command line overriding the configFile. When specified, they should be @@ -660,11 +663,21 @@ def parseOptionsAndInitTestdirs(): # respectively. # # See also lldb-trunk/example/test/usage-config. - global config + global config, pre_flight, post_flight if configFile: # Pass config (a dictionary) as the locals namespace for side-effect. execfile(configFile, globals(), config) - #print "config:", config + print "config:", config + if "pre_flight" in config: + pre_flight = config["pre_flight"] + if not callable(pre_flight): + print "fatal error: pre_flight is not callable, exiting." + sys.exit(1) + if "post_flight" in config: + post_flight = config["post_flight"] + if not callable(post_flight): + print "fatal error: post_flight is not callable, exiting." + sys.exit(1) #print "sys.stderr:", sys.stderr #print "sys.stdout:", sys.stdout @@ -1021,6 +1034,23 @@ lldb.DBG = lldb.SBDebugger.Create() # Put the blacklist in the lldb namespace, to be used by lldb.TestBase. lldb.blacklist = blacklist +# The pre_flight and post_flight come from reading a config file. +lldb.pre_flight = pre_flight +lldb.post_flight = post_flight +def getsource_if_available(obj): + """ + Return the text of the source code for an object if available. Otherwise, + a print representation is returned. + """ + import inspect + try: + return inspect.getsource(obj) + except: + return repr(obj) + +print "lldb.pre_flight:", getsource_if_available(lldb.pre_flight) +print "lldb.post_flight:", getsource_if_available(lldb.post_flight) + # Put all these test decorators in the lldb namespace. lldb.dont_do_python_api_test = dont_do_python_api_test lldb.just_do_python_api_test = just_do_python_api_test diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index 1626ca734cc..3bcdd5207e1 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -1058,6 +1058,10 @@ class TestBase(Base): # And the result object. self.res = lldb.SBCommandReturnObject() + # Run global pre-flight code, if defined via the config file. + if lldb.pre_flight: + lldb.pre_flight(self) + def tearDown(self): #import traceback #traceback.print_stack() @@ -1079,6 +1083,10 @@ class TestBase(Base): for target in targets: self.dbg.DeleteTarget(target) + # Run global post-flight code, if defined via the config file. + if lldb.post_flight: + lldb.post_flight(self) + del self.dbg def switch_to_thread_with_stop_reason(self, stop_reason): |