lit.cfg 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # -*- Python -*-
  2. # Configuration file for the 'lit' test runner.
  3. import os
  4. import lit.formats
  5. # name: The name of this test suite.
  6. config.name = 'LLVM-Unit'
  7. # suffixes: A list of file extensions to treat as test files.
  8. config.suffixes = []
  9. # test_source_root: The root path where tests are located.
  10. # test_exec_root: The root path where tests should be run.
  11. llvm_obj_root = getattr(config, 'llvm_obj_root', None)
  12. if llvm_obj_root is not None:
  13. config.test_exec_root = os.path.join(llvm_obj_root, 'unittests')
  14. config.test_source_root = config.test_exec_root
  15. # testFormat: The test format to use to interpret tests.
  16. llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
  17. config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
  18. # Propagate the temp directory. Windows requires this because it uses \Windows\
  19. # if none of these are present.
  20. if 'TMP' in os.environ:
  21. config.environment['TMP'] = os.environ['TMP']
  22. if 'TEMP' in os.environ:
  23. config.environment['TEMP'] = os.environ['TEMP']
  24. # Propagate path to symbolizer for ASan/MSan.
  25. for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
  26. if symbolizer in os.environ:
  27. config.environment[symbolizer] = os.environ[symbolizer]
  28. # Win32 seeks DLLs along %PATH%.
  29. if sys.platform in ['win32', 'cygwin'] and os.path.isdir(config.shlibdir):
  30. config.environment['PATH'] = os.path.pathsep.join((
  31. config.shlibdir, config.environment['PATH']))
  32. ###
  33. # Check that the object root is known.
  34. if config.test_exec_root is None:
  35. # Otherwise, we haven't loaded the site specific configuration (the user is
  36. # probably trying to run on a test file directly, and either the site
  37. # configuration hasn't been created by the build system, or we are in an
  38. # out-of-tree build situation).
  39. # Check for 'llvm_unit_site_config' user parameter, and use that if available.
  40. site_cfg = lit_config.params.get('llvm_unit_site_config', None)
  41. if site_cfg and os.path.exists(site_cfg):
  42. lit_config.load_config(config, site_cfg)
  43. raise SystemExit
  44. # Try to detect the situation where we are using an out-of-tree build by
  45. # looking for 'llvm-config'.
  46. #
  47. # FIXME: I debated (i.e., wrote and threw away) adding logic to
  48. # automagically generate the lit.site.cfg if we are in some kind of fresh
  49. # build situation. This means knowing how to invoke the build system
  50. # though, and I decided it was too much magic.
  51. llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
  52. if not llvm_config:
  53. lit_config.fatal('No site specific configuration available!')
  54. # Get the source and object roots.
  55. llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
  56. llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
  57. # Validate that we got a tree which points to here.
  58. this_src_root = os.path.join(os.path.dirname(__file__),'..','..')
  59. if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
  60. lit_config.fatal('No site specific configuration available!')
  61. # Check that the site specific configuration exists.
  62. site_cfg = os.path.join(llvm_obj_root, 'test', 'Unit', 'lit.site.cfg')
  63. if not os.path.exists(site_cfg):
  64. lit_config.fatal('No site specific configuration available!')
  65. # Okay, that worked. Notify the user of the automagic, and reconfigure.
  66. lit_config.note('using out-of-tree build at %r' % llvm_obj_root)
  67. lit_config.load_config(config, site_cfg)
  68. raise SystemExit