blob: 8f27781523f0eecb7b69c065aed0c6a38551264f [file] [log] [blame]
Jeffrey Yasskin7a178892011-02-03 04:51:52 +00001# -*- Python -*-
2
3# Configuration file for the 'lit' test runner.
4
5import os
6
7# name: The name of this test suite.
8config.name = 'Clang-Unit'
9
10# suffixes: A list of file extensions to treat as test files.
11config.suffixes = []
12
13# test_source_root: The root path where tests are located.
14# test_exec_root: The root path where tests should be run.
15clang_obj_root = getattr(config, 'clang_obj_root', None)
16if clang_obj_root is not None:
17 config.test_exec_root = os.path.join(clang_obj_root, 'unittests')
18 config.test_source_root = config.test_exec_root
19
20# testFormat: The test format to use to interpret tests.
21llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
22config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
23
24# Propagate the temp directory. Windows requires this because it uses \Windows\
25# if none of these are present.
26if 'TMP' in os.environ:
27 config.environment['TMP'] = os.environ['TMP']
28if 'TEMP' in os.environ:
29 config.environment['TEMP'] = os.environ['TEMP']
30
31###
32
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000033# Check that the object root is known.
34if 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
Jeffrey Yasskin718b01d2011-02-15 07:54:28 +000040 # Check for 'clang_unit_site_config' user parameter, and use that if available.
41 site_cfg = lit.params.get('clang_unit_site_config', None)
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000042 if site_cfg and os.path.exists(site_cfg):
43 lit.load_config(config, site_cfg)
44 raise SystemExit
45
46 # Try to detect the situation where we are using an out-of-tree build by
47 # looking for 'llvm-config'.
48 #
49 # FIXME: I debated (i.e., wrote and threw away) adding logic to
50 # automagically generate the lit.site.cfg if we are in some kind of fresh
51 # build situation. This means knowing how to invoke the build system
52 # though, and I decided it was too much magic.
53
54 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
55 if not llvm_config:
56 lit.fatal('No site specific configuration available!')
57
58 # Get the source and object roots.
59 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
60 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
61 clang_src_root = os.path.join(llvm_src_root, "tools", "clang")
62 clang_obj_root = os.path.join(llvm_obj_root, "tools", "clang")
63
64 # Validate that we got a tree which points to here, using the standard
65 # tools/clang layout.
Daniel Dunbar9c7f4692011-06-22 21:46:43 +000066 this_src_root = os.path.join(os.path.dirname(__file__),'..','..')
Jeffrey Yasskin7a178892011-02-03 04:51:52 +000067 if os.path.realpath(clang_src_root) != os.path.realpath(this_src_root):
68 lit.fatal('No site specific configuration available!')
69
70 # Check that the site specific configuration exists.
71 site_cfg = os.path.join(clang_obj_root, 'test', 'Unit', 'lit.site.cfg')
72 if not os.path.exists(site_cfg):
73 lit.fatal('No site specific configuration available!')
74
75 # Okay, that worked. Notify the user of the automagic, and reconfigure.
76 lit.note('using out-of-tree build at %r' % clang_obj_root)
77 lit.load_config(config, site_cfg)
78 raise SystemExit
Daniel Dunbar9c7f4692011-06-22 21:46:43 +000079
80# If necessary, point the dynamic loader at libLLVM.so.
81if config.enable_shared:
82 shlibpath = config.environment.get(config.shlibpath_var,'')
83 if shlibpath:
84 shlibpath = os.pathsep + shlibpath
85 shlibpath = config.shlibdir + shlibpath
86 config.environment[config.shlibpath_var] = shlibpath