blob: 267f8c5178584a17b50952b7ecc7458fedbc771e [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
13
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000014# Configuration file for the 'lit' test runner.
15
16# name: The name of this test suite.
17config.name = 'lld'
18
19# testFormat: The test format to use to interpret tests.
20#
21# For now we require '&&' between commands, until they get globally killed and
22# the test runner updated.
Zachary Turnerd4401d32017-09-18 22:26:48 +000023config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000024
25# suffixes: A list of file extensions to treat as test files.
Reid Kleckner892d2a52017-06-26 16:42:44 +000026config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt']
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000027
Rafael Espindolac08ab8e2015-04-24 15:51:45 +000028# excludes: A list of directories to exclude from the testsuite. The 'Inputs'
29# subdirectories contain auxiliary inputs for various tests in their parent
30# directories.
31config.excludes = ['Inputs']
32
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000033# test_source_root: The root path where tests are located.
34config.test_source_root = os.path.dirname(__file__)
35
Zachary Turnerce92db12017-09-15 22:10:46 +000036config.test_exec_root = os.path.join(config.lld_obj_root, 'test')
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000037
Zachary Turner96b04b62017-10-06 17:54:46 +000038llvm_config.use_default_substitutions()
Zachary Turnerad5997e2017-10-12 21:56:05 +000039llvm_config.use_lld()
Pete Cooper80c9b942015-12-10 19:17:35 +000040
Zachary Turner0aa02c02017-09-21 22:16:40 +000041tool_patterns = [
Alexander Richardson8edd70b2018-02-27 22:01:02 +000042 'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-pdbutil',
Sam Cleggc729c1b2018-05-30 18:07:52 +000043 'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'obj2yaml', 'yaml2obj',
44 'opt', 'llvm-dis']
Pete Cooper80c9b942015-12-10 19:17:35 +000045
Zachary Turnerad5997e2017-10-12 21:56:05 +000046llvm_config.add_tool_substitutions(tool_patterns)
Pete Cooper80c9b942015-12-10 19:17:35 +000047
Kamil Rytarowskiae1ab912018-12-23 21:20:09 +000048# LLD tests tend to be flaky on NetBSD, so add some retries.
49# We don't do this on other platforms because it's slower.
50if platform.system() in ['NetBSD']:
51 config.test_retry_attempts = 2
52
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000053# When running under valgrind, we mangle '-vg' onto the end of the triple so we
54# can check it with XFAIL and XTARGET.
Daniel Dunbarbc7bfb12013-08-09 18:51:17 +000055if lit_config.useValgrind:
Michael J. Spencer773a8fb2011-12-18 08:27:59 +000056 config.target_triple += '-vg'
57
Nick Kledzik50bda292014-09-11 00:52:05 +000058# Running on ELF based *nix
Michal Gornyceacc632019-01-02 19:39:26 +000059if platform.system() in ['FreeBSD', 'NetBSD', 'Linux']:
Nick Kledzik50bda292014-09-11 00:52:05 +000060 config.available_features.add('system-linker-elf')
61
NAKAMURA Takumic96ae0c2016-02-09 07:30:11 +000062# Set if host-cxxabi's demangler can handle target's symbols.
63if platform.system() not in ['Windows']:
64 config.available_features.add('demangler')
65
Zachary Turnerd4401d32017-09-18 22:26:48 +000066llvm_config.feature_config(
Zachary Turnerc9814482017-10-06 17:54:27 +000067 [('--build-mode', {'DEBUG': 'debug'}),
68 ('--assertion-mode', {'ON': 'asserts'}),
69 ('--targets-built', {'AArch64': 'aarch64',
70 'AMDGPU': 'amdgpu',
71 'ARM': 'arm',
72 'AVR': 'avr',
Sid Manning95b0c2e2018-06-13 18:45:25 +000073 'Hexagon': 'hexagon',
Zachary Turnerc9814482017-10-06 17:54:27 +000074 'Mips': 'mips',
George Rimar73af3d42019-01-10 13:43:06 +000075 'MSP430': 'msp430',
Zachary Turnerc9814482017-10-06 17:54:27 +000076 'PowerPC': 'ppc',
Rui Ueyama5cd9c6b2018-08-09 17:59:56 +000077 'RISCV': 'riscv',
Zachary Turnerc9814482017-10-06 17:54:27 +000078 'Sparc': 'sparc',
Sam Cleggc94d3932017-11-17 18:14:09 +000079 'WebAssembly': 'wasm',
Zachary Turnerc9814482017-10-06 17:54:27 +000080 'X86': 'x86'})
81 ])
Rui Ueyamaf23b27a2013-11-04 05:17:54 +000082
Eric Christopher7baac212018-03-20 18:10:30 +000083# Set a fake constant version so that we get consistent output.
Rui Ueyama3da3f062016-11-10 20:20:37 +000084config.environment['LLD_VERSION'] = 'LLD 1.0'
Rui Ueyama7c9ad292018-02-16 23:41:48 +000085config.environment['LLD_IN_TEST'] = '1'
Rui Ueyama3da3f062016-11-10 20:20:37 +000086
Eric Beckmannc8dba242017-07-08 03:06:10 +000087# Indirectly check if the mt.exe Microsoft utility exists by searching for
Eric Beckmann87c6acf2017-08-22 03:15:28 +000088# cvtres, which always accompanies it. Alternatively, check if we can use
89# libxml2 to merge manifests.
Nico Weberb166d7e2019-01-19 00:09:43 +000090if (lit.util.which('cvtres', config.environment['PATH']) or
91 config.llvm_libxml2_enabled):
Eric Beckmann87c6acf2017-08-22 03:15:28 +000092 config.available_features.add('manifest_tool')
Eric Beckmann0aa4b7d2017-09-06 01:50:36 +000093
Nico Weberb166d7e2019-01-19 00:09:43 +000094if config.llvm_libxml2_enabled:
Eric Beckmann0aa4b7d2017-09-06 01:50:36 +000095 config.available_features.add('libxml2')
Peter Collingbourne75257bc2017-10-20 19:48:26 +000096
Zachary Turnerf2282762018-03-23 19:57:25 +000097if config.have_dia_sdk:
98 config.available_features.add("diasdk")
99
Peter Collingbourne16d9a0a2019-03-01 18:53:41 +0000100if config.sizeof_void_p == 8:
101 config.available_features.add("llvm-64-bits")
102
Igor Kudrin85e68a62017-10-26 02:31:36 +0000103tar_executable = lit.util.which('tar', config.environment['PATH'])
104if tar_executable:
105 tar_version = subprocess.Popen(
Michal Gornyfbed4e12018-12-14 22:38:01 +0000106 [tar_executable, '--version'],
107 stdout=subprocess.PIPE,
108 stderr=subprocess.PIPE,
109 env={'LANG': 'C'})
110 sout, _ = tar_version.communicate()
111 if 'GNU tar' in sout.decode():
Igor Kudrin85e68a62017-10-26 02:31:36 +0000112 config.available_features.add('gnutar')