[Lldb-commits] [lldb] r154848 - in /lldb/branches/lldb-platform-work: ./ examples/test/.lldb-pre-post-flight examples/test/.lldb-pre-post-flight.bad examples/test/usage-pre-post-flight test/dotest.py test/lldbtest.py

Johnny Chen johnny.chen at apple.com
Mon Apr 16 11:57:51 PDT 2012


Author: johnny
Date: Mon Apr 16 13:57:51 2012
New Revision: 154848

URL: http://llvm.org/viewvc/llvm-project?rev=154848&view=rev
Log:
Merge r154847 from ToT:

svn merge -r 154728:154847 https://johnny@llvm.org/svn/llvm-project/lldb/trunk .

Added:
    lldb/branches/lldb-platform-work/examples/test/.lldb-pre-post-flight
      - copied unchanged from r154847, lldb/trunk/examples/test/.lldb-pre-post-flight
    lldb/branches/lldb-platform-work/examples/test/.lldb-pre-post-flight.bad
      - copied unchanged from r154847, lldb/trunk/examples/test/.lldb-pre-post-flight.bad
    lldb/branches/lldb-platform-work/examples/test/usage-pre-post-flight
      - copied unchanged from r154847, lldb/trunk/examples/test/usage-pre-post-flight
Modified:
    lldb/branches/lldb-platform-work/   (props changed)
    lldb/branches/lldb-platform-work/test/dotest.py
    lldb/branches/lldb-platform-work/test/lldbtest.py

Propchange: lldb/branches/lldb-platform-work/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Apr 16 13:57:51 2012
@@ -1 +1 @@
-/lldb/trunk:154224-154730
+/lldb/trunk:154224-154847

Modified: lldb/branches/lldb-platform-work/test/dotest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/test/dotest.py?rev=154848&r1=154847&r2=154848&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/test/dotest.py (original)
+++ lldb/branches/lldb-platform-work/test/dotest.py Mon Apr 16 13:57:51 2012
@@ -96,6 +96,9 @@
 
 # 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 @@
     # 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 @@
 # 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

Modified: lldb/branches/lldb-platform-work/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/branches/lldb-platform-work/test/lldbtest.py?rev=154848&r1=154847&r2=154848&view=diff
==============================================================================
--- lldb/branches/lldb-platform-work/test/lldbtest.py (original)
+++ lldb/branches/lldb-platform-work/test/lldbtest.py Mon Apr 16 13:57:51 2012
@@ -1058,6 +1058,10 @@
         # 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 @@
         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):





More information about the lldb-commits mailing list