diff options
author | Johnny Chen <johnny.chen@apple.com> | 2012-02-09 02:01:59 +0000 |
---|---|---|
committer | Johnny Chen <johnny.chen@apple.com> | 2012-02-09 02:01:59 +0000 |
commit | 57816730f0cd4f8f5f14bc14f2e5d99685220682 (patch) | |
tree | cb80b6c6ce1b137a66a9172341638f9d48122f25 | |
parent | abecb9ce3c0967d8b728ff3a77694ee58f550f56 (diff) | |
download | bcm5719-llvm-57816730f0cd4f8f5f14bc14f2e5d99685220682.tar.gz bcm5719-llvm-57816730f0cd4f8f5f14bc14f2e5d99685220682.zip |
Add safe guard for when the 'expect' program cannot be located and skip the test.
llvm-svn: 150133
-rw-r--r-- | lldb/test/lldbtest.py | 17 | ||||
-rw-r--r-- | lldb/test/terminal/TestSTTYBeforeAndAfter.py | 3 |
2 files changed, 20 insertions, 0 deletions
diff --git a/lldb/test/lldbtest.py b/lldb/test/lldbtest.py index a4fceca2d0c..39b28e235d5 100644 --- a/lldb/test/lldbtest.py +++ b/lldb/test/lldbtest.py @@ -240,6 +240,23 @@ def pointer_size(): 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 diff --git a/lldb/test/terminal/TestSTTYBeforeAndAfter.py b/lldb/test/terminal/TestSTTYBeforeAndAfter.py index f08119b4cec..a79dec81221 100644 --- a/lldb/test/terminal/TestSTTYBeforeAndAfter.py +++ b/lldb/test/terminal/TestSTTYBeforeAndAfter.py @@ -23,6 +23,9 @@ class CommandLineCompletionTestCase(TestBase): 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. |