3 # Configuration file for the 'lit' test runner.
9 # name: The name of this test suite.
10 config.name = 'LLVM-Unit'
12 # suffixes: A list of file extensions to treat as test files.
15 # test_source_root: The root path where tests are located.
16 # test_exec_root: The root path where tests should be run.
17 llvm_obj_root = getattr(config, 'llvm_obj_root', None)
18 if 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
22 # testFormat: The test format to use to interpret tests.
23 llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
24 config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
26 # Propagate the temp directory. Windows requires this because it uses \Windows\
27 # if none of these are present.
28 if 'TMP' in os.environ:
29 config.environment['TMP'] = os.environ['TMP']
30 if 'TEMP' in os.environ:
31 config.environment['TEMP'] = os.environ['TEMP']
33 # Propagate path to symbolizer for ASan/MSan.
34 for symbolizer in ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH']:
35 if symbolizer in os.environ:
36 config.environment[symbolizer] = os.environ[symbolizer]
40 # Check that the object root is known.
41 if config.test_exec_root is None:
42 # Otherwise, we haven't loaded the site specific configuration (the user is
43 # probably trying to run on a test file directly, and either the site
44 # configuration hasn't been created by the build system, or we are in an
45 # out-of-tree build situation).
47 # Check for 'llvm_unit_site_config' user parameter, and use that if available.
48 site_cfg = lit_config.params.get('llvm_unit_site_config', None)
49 if site_cfg and os.path.exists(site_cfg):
50 lit_config.load_config(config, site_cfg)
53 # Try to detect the situation where we are using an out-of-tree build by
54 # looking for 'llvm-config'.
56 # FIXME: I debated (i.e., wrote and threw away) adding logic to
57 # automagically generate the lit.site.cfg if we are in some kind of fresh
58 # build situation. This means knowing how to invoke the build system
59 # though, and I decided it was too much magic.
61 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
63 lit_config.fatal('No site specific configuration available!')
65 # Get the source and object roots.
66 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
67 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
69 # Validate that we got a tree which points to here.
70 this_src_root = os.path.join(os.path.dirname(__file__),'..','..')
71 if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
72 lit_config.fatal('No site specific configuration available!')
74 # Check that the site specific configuration exists.
75 site_cfg = os.path.join(llvm_obj_root, 'test', 'Unit', 'lit.site.cfg')
76 if not os.path.exists(site_cfg):
77 lit_config.fatal('No site specific configuration available!')
79 # Okay, that worked. Notify the user of the automagic, and reconfigure.
80 lit_config.note('using out-of-tree build at %r' % llvm_obj_root)
81 lit_config.load_config(config, site_cfg)
84 # If necessary, point the dynamic loader at libLLVM.so.
85 if config.enable_shared:
86 shlibpath = config.environment.get(config.shlibpath_var,'')
88 shlibpath = os.pathsep + shlibpath
89 shlibpath = config.shlibdir + shlibpath
90 config.environment[config.shlibpath_var] = shlibpath