[Lldb-commits] [lldb] r112102 - in /lldb/trunk/test: lldbtest.py macosx/universal/TestUniversal.py

Johnny Chen johnny.chen at apple.com
Wed Aug 25 15:52:45 PDT 2010


Author: johnny
Date: Wed Aug 25 17:52:45 2010
New Revision: 112102

URL: http://llvm.org/viewvc/llvm-project?rev=112102&view=rev
Log:
Added logic to TestUniversal.py to exercise the python APIs:

o SBDebugger.GetCurrentTarget()
o SBTarget.GetProcess()
o SBProcess.GetAddressByteSize()

in order to make sure that, indeed, 64-bit, followed by 32-bit processes have
been launched.

Added invoke() method to TestBase to factor in the tracing logic in one place.
This method allows an object to call a method with no arg reflectively.

Modified:
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/macosx/universal/TestUniversal.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=112102&r1=112101&r2=112102&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Aug 25 17:52:45 2010
@@ -289,3 +289,16 @@
 
         self.assertTrue(matched, msg if msg else CMD_MSG(cmd))
 
+    def invoke(self, obj, name, trace=False):
+        """Use reflection to call a method dynamically without any argument."""
+
+        trace = (True if self.traceAlways else trace)
+        
+        method = getattr(obj, name)
+        import inspect
+        self.assertTrue(inspect.ismethod(method),
+                        name + "is a method name of object: " + str(obj))
+        result = method()
+        if self.traceAlways:
+            print str(method) + ":",  result
+        return result

Modified: lldb/trunk/test/macosx/universal/TestUniversal.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/macosx/universal/TestUniversal.py?rev=112102&r1=112101&r2=112102&view=diff
==============================================================================
--- lldb/trunk/test/macosx/universal/TestUniversal.py (original)
+++ lldb/trunk/test/macosx/universal/TestUniversal.py Wed Aug 25 17:52:45 2010
@@ -26,6 +26,14 @@
 
         # We should be able to launch the x86_64 executable.
         self.runCmd("run", RUN_STOPPED)
+
+        # Check whether we have a 64-bit process launched.
+        target = self.dbg.GetCurrentTarget()
+        process = target.GetProcess()
+        self.assertTrue(target.IsValid() and process.IsValid() and
+                        self.invoke(process, 'GetAddressByteSize') == 8,
+                        "64-bit process launched")
+
         self.runCmd("continue")
 
         # Now specify i386 as the architecture for "testit".
@@ -39,6 +47,14 @@
 
         # We should be able to launch the i386 executable as well.
         self.runCmd("run", RUN_STOPPED)
+
+        # Check whether we have a 32-bit process launched.
+        target = self.dbg.GetCurrentTarget()
+        process = target.GetProcess()
+        self.assertTrue(target.IsValid() and process.IsValid() and
+                        self.invoke(process, 'GetAddressByteSize') == 4,
+                        "32-bit process launched")
+
         self.runCmd("continue")
 
 





More information about the lldb-commits mailing list