[LNT] r194516 - Better errors for invalid --cc parameters.

Chris Matthews cmatthews5 at apple.com
Tue Nov 12 13:50:24 PST 2013


Author: cmatthews
Date: Tue Nov 12 15:50:24 2013
New Revision: 194516

URL: http://llvm.org/viewvc/llvm-project?rev=194516&view=rev
Log:
Better errors for invalid --cc parameters.

When you specified something odd for --cc you'd get a really cryptic "Permission Denied" error when we go to check the compiler version. Do better checking on the --cc executable first, and error if it is not  1) executable and 2) a file.  Also, make the compile test function in the same way.

Modified:
    lnt/trunk/lnt/testing/util/compilers.py
    lnt/trunk/lnt/tests/compile.py
    lnt/trunk/lnt/tests/nt.py

Modified: lnt/trunk/lnt/testing/util/compilers.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/testing/util/compilers.py?rev=194516&r1=194515&r2=194516&view=diff
==============================================================================
--- lnt/trunk/lnt/testing/util/compilers.py (original)
+++ lnt/trunk/lnt/testing/util/compilers.py Tue Nov 12 15:50:24 2013
@@ -13,6 +13,12 @@ def ishexhash(string):
              for c in string
              if c.isdigit() or c in 'abcdef']) == 40
 
+
+def is_valid(path):
+    """Does this path point to a valid executable?"""
+    return os.path.isfile(path) and os.access(path, os.X_OK)
+
+
 def get_cc_info(path, cc_flags=[]):
     """get_cc_info(path) -> { ... }
 

Modified: lnt/trunk/lnt/tests/compile.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/compile.py?rev=194516&r1=194515&r2=194516&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/compile.py (original)
+++ lnt/trunk/lnt/tests/compile.py Tue Nov 12 15:50:24 2013
@@ -750,6 +750,13 @@ class CompileTest(builtintest.BuiltinTes
         if len(args) != 0:
             parser.error("invalid number of arguments")
 
+        # Resolve the cc_under_test path.
+        opts.cc = resolve_command_path(opts.cc)
+
+        if not lnt.testing.util.compilers.is_valid(opts.cc):
+            parser.error('--cc does not point to a valid executable.')
+
+
         # Attempt to infer the cxx compiler if not given.
         if opts.cc and opts.cxx is None:
             opts.cxx = lnt.testing.util.compilers.infer_cxx_compiler(opts.cc)

Modified: lnt/trunk/lnt/tests/nt.py
URL: http://llvm.org/viewvc/llvm-project/lnt/trunk/lnt/tests/nt.py?rev=194516&r1=194515&r2=194516&view=diff
==============================================================================
--- lnt/trunk/lnt/tests/nt.py (original)
+++ lnt/trunk/lnt/tests/nt.py Tue Nov 12 15:50:24 2013
@@ -1338,6 +1338,9 @@ class NTTest(builtintest.BuiltinTest):
         # Resolve the cc_under_test path.
         opts.cc_under_test = resolve_command_path(opts.cc_under_test)
 
+        if not lnt.testing.util.compilers.is_valid(opts.cc_under_test):
+            parser.error('--cc does not point to a valid executable.')
+
         # If there was no --cxx given, attempt to infer it from the --cc.
         if opts.cxx_under_test is None:
             opts.cxx_under_test = lnt.testing.util.compilers.infer_cxx_compiler(





More information about the llvm-commits mailing list