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