[clang] 1f822f2 - Handle two corner cases in creduce-clang-crash.py

Reid Kleckner via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 5 16:24:30 PST 2019


Author: Reid Kleckner
Date: 2019-12-05T16:24:24-08:00
New Revision: 1f822f212cde1ad9099cf45af0652a83380de772

URL: https://github.com/llvm/llvm-project/commit/1f822f212cde1ad9099cf45af0652a83380de772
DIFF: https://github.com/llvm/llvm-project/commit/1f822f212cde1ad9099cf45af0652a83380de772.diff

LOG: Handle two corner cases in creduce-clang-crash.py

Summary:
First, call os.path.normpath on the filename argument. I passed in
./foo-asdf.cpp, and this meant that the script failed to find the
filename, and bad things happened.

Second, call os.path.abspath on binaries. CReduce runs the
interestingness test in a temp dir, so relative paths will not work.

Reviewers: akhuang

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D71098

Added: 
    

Modified: 
    clang/utils/creduce-clang-crash.py

Removed: 
    


################################################################################
diff  --git a/clang/utils/creduce-clang-crash.py b/clang/utils/creduce-clang-crash.py
index e886bf72e5a7..b69d6efc2481 100755
--- a/clang/utils/creduce-clang-crash.py
+++ b/clang/utils/creduce-clang-crash.py
@@ -30,6 +30,7 @@ def verbose_print(*args, **kwargs):
     print(*args, **kwargs)
 
 def check_file(fname):
+  fname = os.path.normpath(fname)
   if not os.path.isfile(fname):
     sys.exit("ERROR: %s does not exist" % (fname))
   return fname
@@ -40,6 +41,8 @@ def check_cmd(cmd_name, cmd_dir, cmd_path=None):
   or absolute path to cmd_dir/cmd_name.
   """
   if cmd_path:
+    # Make the path absolute so the creduce test can be run from any directory.
+    cmd_path = os.path.abspath(cmd_path)
     cmd = find_executable(cmd_path)
     if cmd:
       return cmd


        


More information about the cfe-commits mailing list