6 # python 2.7 backwards compatibility
8 from shlex import quote as shell_quote
10 from pipes import quote as shell_quote
13 def add_update_script_substition(
14 name, python_exe=config.python_executable, extra_args=""
16 assert name.startswith("%")
17 script_path = os.path.join(config.llvm_src_root, "utils", name[1:] + ".py")
18 assert os.path.isfile(script_path)
19 # Specify an explicit default version in UTC tests, so that the --version
20 # embedded in UTC_ARGS does not change in all test expectations every time
21 # the default is bumped.
22 extra_args += " --version=1"
23 config.substitutions.append(
24 (name, "'%s' %s %s" % (python_exe, script_path, extra_args))
28 config.test_format = lit.formats.ShTest(execute_external=False)
29 config.suffixes = [".test"]
31 llc_path = os.path.join(config.llvm_tools_dir, "llc")
32 if os.path.isfile(llc_path):
33 config.available_features.add("llc-binary")
34 llc_arg = "--llc-binary " + shell_quote(llc_path)
35 add_update_script_substition("%update_llc_test_checks", extra_args=llc_arg)
36 add_update_script_substition("%update_mir_test_checks", extra_args=llc_arg)
38 opt_path = os.path.join(config.llvm_tools_dir, "opt")
39 if os.path.isfile(opt_path):
40 config.available_features.add("opt-binary")
41 opt_arg = "--opt-binary " + shell_quote(opt_path)
42 add_update_script_substition("%update_test_checks", extra_args=opt_arg)
43 add_update_script_substition("%update_analyze_test_checks", extra_args=opt_arg)
45 llvm_mca_path = os.path.join(config.llvm_tools_dir, "llvm-mca")
46 if os.path.isfile(llvm_mca_path):
47 config.available_features.add("llvm-mca-binary")
48 mca_arg = "--llvm-mca-binary " + shell_quote(llvm_mca_path)
49 add_update_script_substition("%update_test_checks", extra_args=mca_arg)