84 lines · plain
1# -*clang- Python -*-2 3import os4import platform5import re6import subprocess7 8import lit.formats9import lit.util10 11from lit.llvm import llvm_config12 13# Configuration file for the 'lit' test runner.14 15# name: The name of this test suite.16config.name = 'Polly'17 18# testFormat: The test format to use to interpret tests.19#20# For now we require '&&' between commands, until they get globally killed and21# the test runner updated.22#23# TODO: Consolidate the logic for turning on the internal shell by default for all LLVM test suites.24# See https://github.com/llvm/llvm-project/issues/106636 for more details.25#26# We prefer the lit internal shell which provides a better user experience on failures27# unless the user explicitly disables it with LIT_USE_INTERNAL_SHELL=0 env var.28use_lit_shell = True29lit_shell_env = os.environ.get("LIT_USE_INTERNAL_SHELL")30if lit_shell_env:31 use_lit_shell = lit.util.pythonize_bool(lit_shell_env)32 33config.test_format = lit.formats.ShTest(execute_external=not use_lit_shell)34 35# suffixes: A list of file extensions to treat as test files.36config.suffixes = ['.ll']37 38# test_source_root: The root path where tests are located.39config.test_source_root = os.path.dirname(__file__)40 41# test_exec_root: The root path where tests should be run.42config.test_exec_root = os.path.join(config.polly_obj_root, 'test')43 44# Tweak the PATH to include the tools dir and the scripts dir.45base_paths = [config.llvm_tools_dir, config.environment['PATH']]46path = os.path.pathsep.join(base_paths + config.extra_paths)47config.environment['PATH'] = path48 49path = os.path.pathsep.join((config.llvm_libs_dir,50 config.environment.get('LD_LIBRARY_PATH','')))51config.environment['LD_LIBRARY_PATH'] = path52 53llvm_config.use_default_substitutions()54 55tool_patterns = ['opt', 'polly-isl-test']56llvm_config.add_tool_substitutions(tool_patterns)57 58# opt knows whether it is compiled with -DNDEBUG.59import subprocess60try:61 opt_cmd = subprocess.Popen([os.path.join(config.llvm_tools_dir, 'opt'), '-version'],62 stdout = subprocess.PIPE,63 env=config.environment)64except OSError:65 print("Could not find opt in " + config.llvm_tools_dir)66 exit(42)67 68if re.search(r'with assertions', opt_cmd.stdout.read().decode('ascii')):69 config.available_features.add('asserts')70opt_cmd.wait()71 72try:73 llvm_config_cmd = subprocess.Popen([os.path.join(74 config.llvm_tools_dir,75 'llvm-config'),76 '--targets-built'],77 stdout = subprocess.PIPE,78 env=config.environment)79except OSError:80 print("Could not find llvm-config in " + config.llvm_tools_dir)81 exit(42)82 83llvm_config_cmd.wait()84