60 lines · plain
1import os2 3import lit.formats4import lit.util5 6# python 2.7 backwards compatibility7try:8 from shlex import quote as shell_quote9except ImportError:10 from pipes import quote as shell_quote11 12 13def add_update_script_substitution(14 name, python_exe=config.python_executable, extra_args=""15):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 --version20 # embedded in UTC_ARGS does not change in all test expectations every time21 # the default is bumped.22 if name != "%update_test_body":23 extra_args += " --version=1"24 config.substitutions.append(25 (name, "'%s' %s %s" % (python_exe, script_path, extra_args))26 )27 28 29config.test_format = lit.formats.ShTest(execute_external=False)30config.suffixes = [".test"]31 32llc_path = os.path.join(config.llvm_tools_dir, "llc")33if os.path.isfile(llc_path):34 config.available_features.add("llc-binary")35 llc_arg = "--llc-binary " + shell_quote(llc_path)36 add_update_script_substitution("%update_llc_test_checks", extra_args=llc_arg)37 add_update_script_substitution("%update_mir_test_checks", extra_args=llc_arg)38 add_update_script_substitution("%update_givaluetracking_test_checks", extra_args=llc_arg)39 40opt_path = os.path.join(config.llvm_tools_dir, "opt")41if os.path.isfile(opt_path):42 config.available_features.add("opt-binary")43 opt_arg = "--opt-binary " + shell_quote(opt_path)44 add_update_script_substitution("%update_test_checks", extra_args=opt_arg)45 add_update_script_substitution("%update_analyze_test_checks", extra_args=opt_arg)46 47llvm_mca_path = os.path.join(config.llvm_tools_dir, "llvm-mca")48if os.path.isfile(llvm_mca_path):49 config.available_features.add("llvm-mca-binary")50 mca_arg = "--llvm-mca-binary " + shell_quote(llvm_mca_path)51 add_update_script_substitution("%update_test_checks", extra_args=mca_arg)52 53split_file_path = os.path.join(config.llvm_tools_dir, "split-file")54if os.path.isfile(split_file_path):55 add_update_script_substitution("%update_test_body")56 57llvm_mc_path = os.path.join(config.llvm_tools_dir, "llvm-mc")58if os.path.isfile(llvm_mc_path):59 add_update_script_substitution("%update_mc_test_checks")60