lit.cfg.py 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. # -*- Python -*-
  2. import os
  3. import platform
  4. import re
  5. import subprocess
  6. import tempfile
  7. import lit.formats
  8. import lit.util
  9. from lit.llvm import llvm_config
  10. from lit.llvm.subst import ToolSubst
  11. from lit.llvm.subst import FindTool
  12. # Configuration file for the 'lit' test runner.
  13. # name: The name of this test suite.
  14. config.name = 'Clang'
  15. # testFormat: The test format to use to interpret tests.
  16. #
  17. # For now we require '&&' between commands, until they get globally killed and
  18. # the test runner updated.
  19. config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell)
  20. # suffixes: A list of file extensions to treat as test files.
  21. config.suffixes = ['.c', '.cpp', '.cppm', '.m', '.mm', '.cu',
  22. '.ll', '.cl', '.s', '.S', '.modulemap', '.test', '.rs', '.ifs']
  23. # excludes: A list of directories to exclude from the testsuite. The 'Inputs'
  24. # subdirectories contain auxiliary inputs for various tests in their parent
  25. # directories.
  26. config.excludes = ['Inputs', 'CMakeLists.txt', 'README.txt', 'LICENSE.txt', 'debuginfo-tests']
  27. # test_source_root: The root path where tests are located.
  28. config.test_source_root = os.path.dirname(__file__)
  29. # test_exec_root: The root path where tests should be run.
  30. config.test_exec_root = os.path.join(config.clang_obj_root, 'test')
  31. llvm_config.use_default_substitutions()
  32. llvm_config.use_clang()
  33. config.substitutions.append(
  34. ('%src_include_dir', config.clang_src_dir + '/include'))
  35. # Propagate path to symbolizer for ASan/MSan.
  36. llvm_config.with_system_environment(
  37. ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
  38. config.substitutions.append(('%PATH%', config.environment['PATH']))
  39. # For each occurrence of a clang tool name, replace it with the full path to
  40. # the build directory holding that tool. We explicitly specify the directories
  41. # to search to ensure that we get the tools just built and not some random
  42. # tools that might happen to be in the user's PATH.
  43. tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
  44. tools = [
  45. 'c-index-test', 'clang-diff', 'clang-format', 'clang-tblgen', 'opt', 'llvm-ifs',
  46. ToolSubst('%clang_extdef_map', command=FindTool(
  47. 'clang-extdef-mapping'), unresolved='ignore'),
  48. ]
  49. if config.clang_examples:
  50. config.available_features.add('examples')
  51. tools.append('clang-interpreter')
  52. if config.clang_staticanalyzer:
  53. config.available_features.add('staticanalyzer')
  54. tools.append('clang-check')
  55. if config.clang_staticanalyzer_z3 == '1':
  56. config.available_features.add('z3')
  57. llvm_config.add_tool_substitutions(tools, tool_dirs)
  58. config.substitutions.append(
  59. ('%hmaptool', "'%s' %s" % (config.python_executable,
  60. os.path.join(config.clang_tools_dir, 'hmaptool'))))
  61. # Plugins (loadable modules)
  62. if config.has_plugins and config.llvm_plugin_ext:
  63. config.available_features.add('plugins')
  64. # Set available features we allow tests to conditionalize on.
  65. #
  66. if config.clang_default_cxx_stdlib != '':
  67. config.available_features.add('default-cxx-stdlib-set')
  68. # As of 2011.08, crash-recovery tests still do not pass on FreeBSD.
  69. if platform.system() not in ['FreeBSD']:
  70. config.available_features.add('crash-recovery')
  71. # Support for new pass manager.
  72. if config.enable_experimental_new_pass_manager:
  73. config.available_features.add('experimental-new-pass-manager')
  74. # ANSI escape sequences in non-dumb terminal
  75. if platform.system() not in ['Windows']:
  76. config.available_features.add('ansi-escape-sequences')
  77. # Capability to print utf8 to the terminal.
  78. # Windows expects codepage, unless Wide API.
  79. if platform.system() not in ['Windows']:
  80. config.available_features.add('utf8-capable-terminal')
  81. # Support for libgcc runtime. Used to rule out tests that require
  82. # clang to run with -rtlib=libgcc.
  83. if platform.system() not in ['Darwin', 'Fuchsia']:
  84. config.available_features.add('libgcc')
  85. # Case-insensitive file system
  86. def is_filesystem_case_insensitive():
  87. handle, path = tempfile.mkstemp(
  88. prefix='case-test', dir=config.test_exec_root)
  89. isInsensitive = os.path.exists(
  90. os.path.join(
  91. os.path.dirname(path),
  92. os.path.basename(path).upper()
  93. ))
  94. os.close(handle)
  95. os.remove(path)
  96. return isInsensitive
  97. if is_filesystem_case_insensitive():
  98. config.available_features.add('case-insensitive-filesystem')
  99. # Tests that require the /dev/fd filesystem.
  100. if os.path.exists('/dev/fd/0') and sys.platform not in ['cygwin']:
  101. config.available_features.add('dev-fd-fs')
  102. # Set on native MS environment.
  103. if re.match(r'.*-(windows-msvc)$', config.target_triple):
  104. config.available_features.add('ms-sdk')
  105. # [PR8833] LLP64-incompatible tests
  106. if not re.match(r'^x86_64.*-(windows-msvc|windows-gnu)$', config.target_triple):
  107. config.available_features.add('LP64')
  108. # [PR12920] "clang-driver" -- set if gcc driver is not used.
  109. if not re.match(r'.*-(cygwin)$', config.target_triple):
  110. config.available_features.add('clang-driver')
  111. # [PR18856] Depends to remove opened file. On win32, a file could be removed
  112. # only if all handles were closed.
  113. if platform.system() not in ['Windows']:
  114. config.available_features.add('can-remove-opened-file')
  115. def calculate_arch_features(arch_string):
  116. features = []
  117. for arch in arch_string.split():
  118. features.append(arch.lower() + '-registered-target')
  119. return features
  120. llvm_config.feature_config(
  121. [('--assertion-mode', {'ON': 'asserts'}),
  122. ('--cxxflags', {r'-D_GLIBCXX_DEBUG\b': 'libstdcxx-safe-mode'}),
  123. ('--targets-built', calculate_arch_features)
  124. ])
  125. if lit.util.which('xmllint'):
  126. config.available_features.add('xmllint')
  127. if config.enable_backtrace:
  128. config.available_features.add('backtrace')
  129. if config.enable_threads:
  130. config.available_features.add('thread_support')
  131. # Check if we should allow outputs to console.
  132. run_console_tests = int(lit_config.params.get('enable_console', '0'))
  133. if run_console_tests != 0:
  134. config.available_features.add('console')
  135. lit.util.usePlatformSdkOnDarwin(config, lit_config)
  136. macOSSDKVersion = lit.util.findPlatformSdkVersionOnMacOS(config, lit_config)
  137. if macOSSDKVersion is not None:
  138. config.available_features.add('macos-sdk-' + str(macOSSDKVersion))
  139. if os.path.exists('/etc/gentoo-release'):
  140. config.available_features.add('gentoo')
  141. if config.enable_shared:
  142. config.available_features.add("enable_shared")