Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 1 | # -*- Python -*- |
| 2 | |
| 3 | import os |
| 4 | import platform |
| 5 | import re |
| 6 | import subprocess |
Michael J. Spencer | a4f983e | 2014-03-26 00:53:48 +0000 | [diff] [blame] | 7 | import locale |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 8 | |
Daniel Dunbar | bc7bfb1 | 2013-08-09 18:51:17 +0000 | [diff] [blame] | 9 | import lit.formats |
| 10 | import lit.util |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 11 | |
Zachary Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 12 | from lit.llvm import llvm_config |
| 13 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 14 | # Configuration file for the 'lit' test runner. |
| 15 | |
| 16 | # name: The name of this test suite. |
| 17 | config.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 Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 23 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 24 | |
| 25 | # suffixes: A list of file extensions to treat as test files. |
Reid Kleckner | 892d2a5 | 2017-06-26 16:42:44 +0000 | [diff] [blame] | 26 | config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt'] |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 27 | |
Rafael Espindola | c08ab8e | 2015-04-24 15:51:45 +0000 | [diff] [blame] | 28 | # 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. |
| 31 | config.excludes = ['Inputs'] |
| 32 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 33 | # test_source_root: The root path where tests are located. |
| 34 | config.test_source_root = os.path.dirname(__file__) |
| 35 | |
Zachary Turner | ce92db1 | 2017-09-15 22:10:46 +0000 | [diff] [blame] | 36 | config.test_exec_root = os.path.join(config.lld_obj_root, 'test') |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 37 | |
Zachary Turner | 96b04b6 | 2017-10-06 17:54:46 +0000 | [diff] [blame] | 38 | llvm_config.use_default_substitutions() |
Zachary Turner | ad5997e | 2017-10-12 21:56:05 +0000 | [diff] [blame] | 39 | llvm_config.use_lld() |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 40 | |
Zachary Turner | 0aa02c0 | 2017-09-21 22:16:40 +0000 | [diff] [blame] | 41 | tool_patterns = [ |
Alexander Richardson | 8edd70b | 2018-02-27 22:01:02 +0000 | [diff] [blame] | 42 | 'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', 'llvm-objdump', 'llvm-pdbutil', |
Sam Clegg | c729c1b | 2018-05-30 18:07:52 +0000 | [diff] [blame] | 43 | 'llvm-dwarfdump', 'llvm-readelf', 'llvm-readobj', 'obj2yaml', 'yaml2obj', |
| 44 | 'opt', 'llvm-dis'] |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 45 | |
Zachary Turner | ad5997e | 2017-10-12 21:56:05 +0000 | [diff] [blame] | 46 | llvm_config.add_tool_substitutions(tool_patterns) |
Pete Cooper | 80c9b94 | 2015-12-10 19:17:35 +0000 | [diff] [blame] | 47 | |
Kamil Rytarowski | ae1ab91 | 2018-12-23 21:20:09 +0000 | [diff] [blame] | 48 | # 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. |
| 50 | if platform.system() in ['NetBSD']: |
| 51 | config.test_retry_attempts = 2 |
| 52 | |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 53 | # When running under valgrind, we mangle '-vg' onto the end of the triple so we |
| 54 | # can check it with XFAIL and XTARGET. |
Daniel Dunbar | bc7bfb1 | 2013-08-09 18:51:17 +0000 | [diff] [blame] | 55 | if lit_config.useValgrind: |
Michael J. Spencer | 773a8fb | 2011-12-18 08:27:59 +0000 | [diff] [blame] | 56 | config.target_triple += '-vg' |
| 57 | |
Nick Kledzik | 50bda29 | 2014-09-11 00:52:05 +0000 | [diff] [blame] | 58 | # Running on ELF based *nix |
Michal Gorny | ceacc63 | 2019-01-02 19:39:26 +0000 | [diff] [blame] | 59 | if platform.system() in ['FreeBSD', 'NetBSD', 'Linux']: |
Nick Kledzik | 50bda29 | 2014-09-11 00:52:05 +0000 | [diff] [blame] | 60 | config.available_features.add('system-linker-elf') |
| 61 | |
NAKAMURA Takumi | c96ae0c | 2016-02-09 07:30:11 +0000 | [diff] [blame] | 62 | # Set if host-cxxabi's demangler can handle target's symbols. |
| 63 | if platform.system() not in ['Windows']: |
| 64 | config.available_features.add('demangler') |
| 65 | |
Zachary Turner | d4401d3 | 2017-09-18 22:26:48 +0000 | [diff] [blame] | 66 | llvm_config.feature_config( |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 67 | [('--build-mode', {'DEBUG': 'debug'}), |
| 68 | ('--assertion-mode', {'ON': 'asserts'}), |
| 69 | ('--targets-built', {'AArch64': 'aarch64', |
| 70 | 'AMDGPU': 'amdgpu', |
| 71 | 'ARM': 'arm', |
| 72 | 'AVR': 'avr', |
Sid Manning | 95b0c2e | 2018-06-13 18:45:25 +0000 | [diff] [blame] | 73 | 'Hexagon': 'hexagon', |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 74 | 'Mips': 'mips', |
George Rimar | 73af3d4 | 2019-01-10 13:43:06 +0000 | [diff] [blame] | 75 | 'MSP430': 'msp430', |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 76 | 'PowerPC': 'ppc', |
Rui Ueyama | 5cd9c6b | 2018-08-09 17:59:56 +0000 | [diff] [blame] | 77 | 'RISCV': 'riscv', |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 78 | 'Sparc': 'sparc', |
Sam Clegg | c94d393 | 2017-11-17 18:14:09 +0000 | [diff] [blame] | 79 | 'WebAssembly': 'wasm', |
Zachary Turner | c981448 | 2017-10-06 17:54:27 +0000 | [diff] [blame] | 80 | 'X86': 'x86'}) |
| 81 | ]) |
Rui Ueyama | f23b27a | 2013-11-04 05:17:54 +0000 | [diff] [blame] | 82 | |
Eric Christopher | 7baac21 | 2018-03-20 18:10:30 +0000 | [diff] [blame] | 83 | # Set a fake constant version so that we get consistent output. |
Rui Ueyama | 3da3f06 | 2016-11-10 20:20:37 +0000 | [diff] [blame] | 84 | config.environment['LLD_VERSION'] = 'LLD 1.0' |
Rui Ueyama | 7c9ad29 | 2018-02-16 23:41:48 +0000 | [diff] [blame] | 85 | config.environment['LLD_IN_TEST'] = '1' |
Rui Ueyama | 3da3f06 | 2016-11-10 20:20:37 +0000 | [diff] [blame] | 86 | |
Eric Beckmann | c8dba24 | 2017-07-08 03:06:10 +0000 | [diff] [blame] | 87 | # Indirectly check if the mt.exe Microsoft utility exists by searching for |
Eric Beckmann | 87c6acf | 2017-08-22 03:15:28 +0000 | [diff] [blame] | 88 | # cvtres, which always accompanies it. Alternatively, check if we can use |
| 89 | # libxml2 to merge manifests. |
Nico Weber | b166d7e | 2019-01-19 00:09:43 +0000 | [diff] [blame] | 90 | if (lit.util.which('cvtres', config.environment['PATH']) or |
| 91 | config.llvm_libxml2_enabled): |
Eric Beckmann | 87c6acf | 2017-08-22 03:15:28 +0000 | [diff] [blame] | 92 | config.available_features.add('manifest_tool') |
Eric Beckmann | 0aa4b7d | 2017-09-06 01:50:36 +0000 | [diff] [blame] | 93 | |
Nico Weber | b166d7e | 2019-01-19 00:09:43 +0000 | [diff] [blame] | 94 | if config.llvm_libxml2_enabled: |
Eric Beckmann | 0aa4b7d | 2017-09-06 01:50:36 +0000 | [diff] [blame] | 95 | config.available_features.add('libxml2') |
Peter Collingbourne | 75257bc | 2017-10-20 19:48:26 +0000 | [diff] [blame] | 96 | |
Zachary Turner | f228276 | 2018-03-23 19:57:25 +0000 | [diff] [blame] | 97 | if config.have_dia_sdk: |
| 98 | config.available_features.add("diasdk") |
| 99 | |
Peter Collingbourne | 16d9a0a | 2019-03-01 18:53:41 +0000 | [diff] [blame] | 100 | if config.sizeof_void_p == 8: |
| 101 | config.available_features.add("llvm-64-bits") |
| 102 | |
Igor Kudrin | 85e68a6 | 2017-10-26 02:31:36 +0000 | [diff] [blame] | 103 | tar_executable = lit.util.which('tar', config.environment['PATH']) |
| 104 | if tar_executable: |
| 105 | tar_version = subprocess.Popen( |
Michal Gorny | fbed4e1 | 2018-12-14 22:38:01 +0000 | [diff] [blame] | 106 | [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 Kudrin | 85e68a6 | 2017-10-26 02:31:36 +0000 | [diff] [blame] | 112 | config.available_features.add('gnutar') |