diff options
-rw-r--r-- | lld/test/lit.cfg | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/lld/test/lit.cfg b/lld/test/lit.cfg index 8c0ec51a277..95e4c821400 100644 --- a/lld/test/lit.cfg +++ b/lld/test/lit.cfg @@ -139,6 +139,46 @@ if config.test_exec_root is None: lit_config.load_config(config, site_cfg) raise SystemExit +# For each occurrence of a lld tool name as its own word, replace it +# with the full path to the build directory holding that tool. This +# ensures that we are testing the tools just built and not some random +# tools that might happen to be in the user's PATH. + +# Regex assertions to reject neighbor hyphens/dots (seen in some tests). +# For example, we want to prefix 'lld' and 'ld.lld' but not the 'lld' inside +# of 'ld.lld'. +NoPreHyphenDot = r"(?<!(-|\.))" +NoPostHyphenDot = r"(?!(-|\.))" + +tool_patterns = [r"\bFileCheck\b", + r"\bnot\b", + NoPreHyphenDot + r"\blld\b" + NoPostHyphenDot, + r"\bld.lld\b", + r"\blld-link\b", + r"\bllvm-mc\b", + r"\bllvm-nm\b", + r"\bllvm-objdump\b", + r"\bllvm-readobj\b", + r"\byaml2obj\b"] + +for pattern in tool_patterns: + # Extract the tool name from the pattern. This relies on the tool + # name being surrounded by \b word match operators. If the + # pattern starts with "| ", include it in the string to be + # substituted. + tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_\.]+)\\b\W*$", + pattern) + tool_pipe = tool_match.group(2) + tool_name = tool_match.group(4) + tool_path = lit.util.which(tool_name, llvm_tools_dir) + if not tool_path: + # Warn, but still provide a substitution. + lit_config.note('Did not find ' + tool_name + ' in ' + llvm_tools_dir) + tool_path = llvm_tools_dir + '/' + tool_name + config.substitutions.append((pattern, tool_pipe + tool_path)) + +### + # When running under valgrind, we mangle '-vg' onto the end of the triple so we # can check it with XFAIL and XTARGET. if lit_config.useValgrind: |