llvm-project
73 строки · 2.3 Кб
1# -*clang- Python -*-
2
3import os
4import platform
5import re
6import subprocess
7
8import lit.formats
9import lit.util
10
11from lit.llvm import llvm_config
12
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 and
21# the test runner updated.
22execute_external = platform.system() != 'Windows'
23config.test_format = lit.formats.ShTest(execute_external)
24
25# suffixes: A list of file extensions to treat as test files.
26config.suffixes = ['.ll']
27
28# test_source_root: The root path where tests are located.
29config.test_source_root = os.path.dirname(__file__)
30
31# test_exec_root: The root path where tests should be run.
32config.test_exec_root = os.path.join(config.polly_obj_root, 'test')
33
34# Tweak the PATH to include the tools dir and the scripts dir.
35base_paths = [config.llvm_tools_dir, config.environment['PATH']]
36path = os.path.pathsep.join(base_paths + config.extra_paths)
37config.environment['PATH'] = path
38
39path = os.path.pathsep.join((config.llvm_libs_dir,
40config.environment.get('LD_LIBRARY_PATH','')))
41config.environment['LD_LIBRARY_PATH'] = path
42
43llvm_config.use_default_substitutions()
44
45tool_patterns = ['opt', 'polly-isl-test']
46llvm_config.add_tool_substitutions(tool_patterns)
47
48# opt knows whether it is compiled with -DNDEBUG.
49import subprocess
50try:
51opt_cmd = subprocess.Popen([os.path.join(config.llvm_tools_dir, 'opt'), '-version'],
52stdout = subprocess.PIPE,
53env=config.environment)
54except OSError:
55print("Could not find opt in " + config.llvm_tools_dir)
56exit(42)
57
58if re.search(r'with assertions', opt_cmd.stdout.read().decode('ascii')):
59config.available_features.add('asserts')
60opt_cmd.wait()
61
62try:
63llvm_config_cmd = subprocess.Popen([os.path.join(
64config.llvm_tools_dir,
65'llvm-config'),
66'--targets-built'],
67stdout = subprocess.PIPE,
68env=config.environment)
69except OSError:
70print("Could not find llvm-config in " + config.llvm_tools_dir)
71exit(42)
72
73llvm_config_cmd.wait()
74