3 # Configuration file for the 'lit' test runner.
7 # name: The name of this test suite.
8 config.name = 'LLVM-Unit'
10 # suffixes: A list of file extensions to treat as test files.
13 # test_source_root: The root path where tests are located.
14 # test_exec_root: The root path where tests should be run.
15 llvm_obj_root = getattr(config, 'llvm_obj_root', None)
16 if llvm_obj_root is not None:
17 config.test_exec_root = os.path.join(llvm_obj_root, 'unittests')
18 config.test_source_root = config.test_exec_root
20 # testFormat: The test format to use to interpret tests.
21 llvm_build_mode = getattr(config, 'llvm_build_mode', "Debug")
22 config.test_format = lit.formats.GoogleTest(llvm_build_mode, 'Tests')
28 # Check that the object root is known.
29 if config.test_exec_root is None:
30 # Otherwise, we haven't loaded the site specific configuration (the user is
31 # probably trying to run on a test file directly, and either the site
32 # configuration hasn't been created by the build system, or we are in an
33 # out-of-tree build situation).
35 # Check for 'llvm_unit_site_config' user parameter, and use that if available.
36 site_cfg = lit.params.get('llvm_unit_site_config', None)
37 if site_cfg and os.path.exists(site_cfg):
38 lit.load_config(config, site_cfg)
41 # Try to detect the situation where we are using an out-of-tree build by
42 # looking for 'llvm-config'.
44 # FIXME: I debated (i.e., wrote and threw away) adding logic to
45 # automagically generate the lit.site.cfg if we are in some kind of fresh
46 # build situation. This means knowing how to invoke the build system
47 # though, and I decided it was too much magic.
49 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
51 lit.fatal('No site specific configuration available!')
53 # Get the source and object roots.
54 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
55 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.fatal('No site specific configuration available!')
62 # Check that the site specific configuration exists.
63 site_cfg = os.path.join(llvm_obj_root, 'test', 'Unit', 'lit.site.cfg')
64 if not os.path.exists(site_cfg):
65 lit.fatal('No site specific configuration available!')
67 # Okay, that worked. Notify the user of the automagic, and reconfigure.
68 lit.note('using out-of-tree build at %r' % llvm_obj_root)
69 lit.load_config(config, site_cfg)