blob: 017558774a2adae603b3d7b9f2ff364cc6106942 [file] [log] [blame]
Michael J. Spencer773a8fb2011-12-18 08:27:59 +00001# -*- Python -*-
2
3import os
4import platform
5import re
6import subprocess
Michael J. Spencera4f983e2014-03-26 00:53:48 +00007import locale
Michael J. Spencer773a8fb2011-12-18 08:27:59 +00008
Daniel Dunbarbc7bfb12013-08-09 18:51:17 +00009import lit.formats
10import lit.util
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000011
Zachary Turnerd4401d32017-09-18 22:26:48 +000012from lit.llvm import llvm_config
Zachary Turner0aa02c02017-09-21 22:16:40 +000013from lit.llvm import ToolFilter
Zachary Turnerd4401d32017-09-18 22:26:48 +000014
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000015# Configuration file for the 'lit' test runner.
16
17# name: The name of this test suite.
18config.name = 'lld'
19
20# testFormat: The test format to use to interpret tests.
21#
22# For now we require '&&' between commands, until they get globally killed and
23# the test runner updated.
Zachary Turnerd4401d32017-09-18 22:26:48 +000024config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000025
26# suffixes: A list of file extensions to treat as test files.
Reid Kleckner892d2a52017-06-26 16:42:44 +000027config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt']
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000028
Rafael Espindolac08ab8e2015-04-24 15:51:45 +000029# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
30# subdirectories contain auxiliary inputs for various tests in their parent
31# directories.
32config.excludes = ['Inputs']
33
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000034# test_source_root: The root path where tests are located.
35config.test_source_root = os.path.dirname(__file__)
36
Zachary Turnerce92db12017-09-15 22:10:46 +000037config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000038
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000039# Tweak the PATH to include the tools dir and the scripts dir.
Zachary Turner0aa02c02017-09-21 22:16:40 +000040llvm_config.with_environment('PATH',
41 [config.llvm_tools_dir, config.lld_tools_dir], append_path=True)
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000042
Zachary Turner0aa02c02017-09-21 22:16:40 +000043llvm_config.with_environment('LD_LIBRARY_PATH',
44 [config.lld_libs_dir, config.llvm_libs_dir], append_path=True)
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000045
Zachary Turner0aa02c02017-09-21 22:16:40 +000046# For each occurrence of a clang tool name, replace it with the full path to
47# the build directory holding that tool. We explicitly specify the directories
48# to search to ensure that we get the tools just built and not some random
Pete Cooper80c9b942015-12-10 19:17:35 +000049# tools that might happen to be in the user's PATH.
Zachary Turner0aa02c02017-09-21 22:16:40 +000050tool_dirs = [config.lld_tools_dir, config.llvm_tools_dir]
Pete Cooper80c9b942015-12-10 19:17:35 +000051
Zachary Turnerc9814482017-10-06 17:54:27 +000052config.substitutions.append((r"\bld.lld\b", 'ld.lld --full-shutdown'))
Rafael Espindolacb09daa2016-10-26 18:59:00 +000053
Zachary Turner0aa02c02017-09-21 22:16:40 +000054tool_patterns = [
55 'FileCheck', 'not', 'ld.lld', 'lld-link', 'llvm-as', 'llvm-mc', 'llvm-nm',
56 'llvm-objdump', 'llvm-pdbutil', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
57 ToolFilter('lld', pre='-./', post='-.')]
Pete Cooper80c9b942015-12-10 19:17:35 +000058
Zachary Turner0aa02c02017-09-21 22:16:40 +000059llvm_config.add_tool_substitutions(tool_patterns, tool_dirs)
Pete Cooper80c9b942015-12-10 19:17:35 +000060
NAKAMURA Takumi12729542016-02-09 07:30:18 +000061# Add site-specific substitutions.
Zachary Turnerc9814482017-10-06 17:54:27 +000062config.substitutions.append(('%python', config.python_executable))
NAKAMURA Takumi12729542016-02-09 07:30:18 +000063
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000064# When running under valgrind, we mangle '-vg' onto the end of the triple so we
65# can check it with XFAIL and XTARGET.
Daniel Dunbarbc7bfb12013-08-09 18:51:17 +000066if lit_config.useValgrind:
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000067 config.target_triple += '-vg'
68
Nick Kledzik50bda292014-09-11 00:52:05 +000069# Running on ELF based *nix
Ed Maste933daef2014-09-12 13:16:30 +000070if platform.system() in ['FreeBSD', 'Linux']:
Nick Kledzik50bda292014-09-11 00:52:05 +000071 config.available_features.add('system-linker-elf')
72
NAKAMURA Takumic96ae0c2016-02-09 07:30:11 +000073# Set if host-cxxabi's demangler can handle target's symbols.
74if platform.system() not in ['Windows']:
75 config.available_features.add('demangler')
76
Zachary Turnerd4401d32017-09-18 22:26:48 +000077llvm_config.feature_config(
Zachary Turnerc9814482017-10-06 17:54:27 +000078 [('--build-mode', {'DEBUG': 'debug'}),
79 ('--assertion-mode', {'ON': 'asserts'}),
80 ('--targets-built', {'AArch64': 'aarch64',
81 'AMDGPU': 'amdgpu',
82 'ARM': 'arm',
83 'AVR': 'avr',
84 'Mips': 'mips',
85 'PowerPC': 'ppc',
86 'Sparc': 'sparc',
87 'X86': 'x86'})
88 ])
Rui Ueyamaf23b27a2013-11-04 05:17:54 +000089
Rui Ueyama3da3f062016-11-10 20:20:37 +000090# Set a fake constant version so that we get consitent output.
91config.environment['LLD_VERSION'] = 'LLD 1.0'
92
Eric Beckmannc8dba242017-07-08 03:06:10 +000093# Indirectly check if the mt.exe Microsoft utility exists by searching for
Eric Beckmann87c6acf2017-08-22 03:15:28 +000094# cvtres, which always accompanies it. Alternatively, check if we can use
95# libxml2 to merge manifests.
96if (lit.util.which('cvtres', config.environment['PATH'])) or \
Zachary Turnerc9814482017-10-06 17:54:27 +000097 (config.llvm_libxml2_enabled == '1'):
Eric Beckmann87c6acf2017-08-22 03:15:28 +000098 config.available_features.add('manifest_tool')
Eric Beckmann0aa4b7d2017-09-06 01:50:36 +000099
Zachary Turnerc9814482017-10-06 17:54:27 +0000100if (config.llvm_libxml2_enabled == '1'):
Eric Beckmann0aa4b7d2017-09-06 01:50:36 +0000101 config.available_features.add('libxml2')