2011-04-29 14:27:02 +08:00
|
|
|
# -*clang- Python -*-
|
|
|
|
|
|
|
|
import os
|
|
|
|
import platform
|
2013-03-13 05:27:39 +08:00
|
|
|
import re
|
2017-07-12 17:42:05 +08:00
|
|
|
import subprocess
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2013-08-10 05:54:36 +08:00
|
|
|
import lit.formats
|
|
|
|
import lit.util
|
|
|
|
|
2021-07-31 04:17:45 +08:00
|
|
|
from lit.llvm import llvm_config
|
|
|
|
|
2011-04-29 14:27:02 +08:00
|
|
|
# Configuration file for the 'lit' test runner.
|
|
|
|
|
|
|
|
# name: The name of this test suite.
|
|
|
|
config.name = 'Polly'
|
|
|
|
|
|
|
|
# testFormat: The test format to use to interpret tests.
|
|
|
|
#
|
|
|
|
# For now we require '&&' between commands, until they get globally killed and
|
|
|
|
# the test runner updated.
|
|
|
|
execute_external = platform.system() != 'Windows'
|
|
|
|
config.test_format = lit.formats.ShTest(execute_external)
|
|
|
|
|
|
|
|
# suffixes: A list of file extensions to treat as test files.
|
|
|
|
config.suffixes = ['.ll']
|
|
|
|
|
|
|
|
# test_source_root: The root path where tests are located.
|
|
|
|
config.test_source_root = os.path.dirname(__file__)
|
|
|
|
|
|
|
|
# test_exec_root: The root path where tests should be run.
|
2017-09-16 06:10:46 +08:00
|
|
|
config.test_exec_root = os.path.join(config.polly_obj_root, 'test')
|
2011-04-29 14:27:02 +08:00
|
|
|
|
|
|
|
# Tweak the PATH to include the tools dir and the scripts dir.
|
2017-09-16 06:10:46 +08:00
|
|
|
base_paths = [config.llvm_tools_dir, config.environment['PATH']]
|
|
|
|
path = os.path.pathsep.join(base_paths + config.extra_paths)
|
|
|
|
config.environment['PATH'] = path
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2017-09-16 06:10:46 +08:00
|
|
|
path = os.path.pathsep.join((config.llvm_libs_dir,
|
|
|
|
config.environment.get('LD_LIBRARY_PATH','')))
|
|
|
|
config.environment['LD_LIBRARY_PATH'] = path
|
2011-04-29 14:27:02 +08:00
|
|
|
|
2021-07-31 04:17:45 +08:00
|
|
|
llvm_config.use_default_substitutions()
|
|
|
|
|
|
|
|
tool_patterns = ['opt', 'polly-isl-test']
|
|
|
|
llvm_config.add_tool_substitutions(tool_patterns)
|
|
|
|
|
2014-05-13 03:43:20 +08:00
|
|
|
# opt knows whether it is compiled with -DNDEBUG.
|
2013-03-13 05:27:39 +08:00
|
|
|
import subprocess
|
|
|
|
try:
|
2017-09-16 06:10:46 +08:00
|
|
|
opt_cmd = subprocess.Popen([os.path.join(config.llvm_tools_dir, 'opt'), '-version'],
|
2015-07-25 04:33:22 +08:00
|
|
|
stdout = subprocess.PIPE,
|
|
|
|
env=config.environment)
|
|
|
|
except OSError:
|
2017-09-16 06:10:46 +08:00
|
|
|
print("Could not find opt in " + config.llvm_tools_dir)
|
2013-03-13 05:27:39 +08:00
|
|
|
exit(42)
|
|
|
|
|
2015-07-25 04:33:22 +08:00
|
|
|
if re.search(r'with assertions', opt_cmd.stdout.read().decode('ascii')):
|
2013-03-13 05:27:39 +08:00
|
|
|
config.available_features.add('asserts')
|
2014-05-13 03:43:20 +08:00
|
|
|
opt_cmd.wait()
|
2014-05-14 22:18:14 +08:00
|
|
|
|
|
|
|
try:
|
2017-09-16 06:10:46 +08:00
|
|
|
llvm_config_cmd = subprocess.Popen([os.path.join(
|
|
|
|
config.llvm_tools_dir,
|
|
|
|
'llvm-config'),
|
2014-05-14 22:18:14 +08:00
|
|
|
'--targets-built'],
|
2015-07-25 04:33:22 +08:00
|
|
|
stdout = subprocess.PIPE,
|
|
|
|
env=config.environment)
|
|
|
|
except OSError:
|
2017-09-16 06:10:46 +08:00
|
|
|
print("Could not find llvm-config in " + config.llvm_tools_dir)
|
2014-05-14 22:18:14 +08:00
|
|
|
exit(42)
|
|
|
|
|
2015-07-25 04:33:22 +08:00
|
|
|
if re.search(r'NVPTX', llvm_config_cmd.stdout.read().decode('ascii')):
|
2014-05-14 22:18:14 +08:00
|
|
|
config.available_features.add('nvptx-registered-target')
|
|
|
|
llvm_config_cmd.wait()
|