[Lldb-commits] [lldb] r150133 - in /lldb/trunk/test: lldbtest.py terminal/TestSTTYBeforeAndAfter.py

Johnny Chen johnny.chen at apple.com
Wed Feb 8 18:02:00 PST 2012


Author: johnny
Date: Wed Feb  8 20:01:59 2012
New Revision: 150133

URL: http://llvm.org/viewvc/llvm-project?rev=150133&view=rev
Log:
Add safe guard for when the 'expect' program cannot be located and skip the test.

Modified:
    lldb/trunk/test/lldbtest.py
    lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py

Modified: lldb/trunk/test/lldbtest.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/lldbtest.py?rev=150133&r1=150132&r2=150133&view=diff
==============================================================================
--- lldb/trunk/test/lldbtest.py (original)
+++ lldb/trunk/test/lldbtest.py Wed Feb  8 20:01:59 2012
@@ -240,6 +240,23 @@
     a_pointer = ctypes.c_void_p(0xffff)
     return 8 * ctypes.sizeof(a_pointer)
 
+def is_exe(fpath):
+    """Returns true if fpath is an executable."""
+    return os.path.isfile(fpath) and os.access(fpath, os.X_OK)
+
+def which(program):
+    """Returns the full path to a program; None otherwise."""
+    fpath, fname = os.path.split(program)
+    if fpath:
+        if is_exe(program):
+            return program
+    else:
+        for path in os.environ["PATH"].split(os.pathsep):
+            exe_file = os.path.join(path, program)
+            if is_exe(exe_file):
+                return exe_file
+    return None
+
 class recording(StringIO.StringIO):
     """
     A nice little context manager for recording the debugger interactions into

Modified: lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py?rev=150133&r1=150132&r2=150133&view=diff
==============================================================================
--- lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py (original)
+++ lldb/trunk/test/terminal/TestSTTYBeforeAndAfter.py Wed Feb  8 20:01:59 2012
@@ -23,6 +23,9 @@
     def test_stty_dash_a_before_and_afetr_invoking_lldb_command(self):
         """Test that 'stty -a' displays the same output before and after running the lldb command."""
 
+        if not which('expect'):
+            self.skipTest("The 'expect' program cannot be located, skip the test")
+
         # The expect prompt.
         expect_prompt = "expect[0-9.]+> "
         # The default lldb prompt.





More information about the lldb-commits mailing list