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