10 # Configuration file for the 'lit' test runner.
12 # name: The name of this test suite.
15 # testFormat: The test format to use to interpret tests.
17 # For now we require '&&' between commands, until they get globally killed and
18 # the test runner updated.
19 execute_external = platform.system() != 'Windows'
20 config.test_format = lit.formats.ShTest(execute_external)
22 # suffixes: A list of file extensions to treat as test files.
23 config.suffixes = ['.ll']
25 # test_source_root: The root path where tests are located.
26 config.test_source_root = os.path.dirname(__file__)
28 # test_exec_root: The root path where tests should be run.
29 polly_obj_root = getattr(config, 'polly_obj_root', None)
30 if polly_obj_root is not None:
31 config.test_exec_root = os.path.join(polly_obj_root, 'test')
33 # Set llvm_{src,obj}_root for use by others.
34 config.llvm_src_root = getattr(config, 'llvm_src_root', None)
35 config.llvm_obj_root = getattr(config, 'llvm_obj_root', None)
37 # Tweak the PATH to include the tools dir and the scripts dir.
38 if polly_obj_root is not None:
39 llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
40 if not llvm_tools_dir:
41 lit_config.fatal('No LLVM tools dir set!')
42 extra_paths = getattr(config, 'extra_paths', [])
43 base_paths = [llvm_tools_dir, config.environment['PATH']]
44 path = os.path.pathsep.join(base_paths + extra_paths)
45 config.environment['PATH'] = path
47 llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
49 lit_config.fatal('No LLVM libs dir set!')
50 path = os.path.pathsep.join((llvm_libs_dir,
51 config.environment.get('LD_LIBRARY_PATH','')))
52 config.environment['LD_LIBRARY_PATH'] = path
56 # Check that the object root is known.
57 if config.test_exec_root is None:
58 # Otherwise, we haven't loaded the site specific configuration (the user is
59 # probably trying to run on a test file directly, and either the site
60 # configuration hasn't been created by the build system, or we are in an
61 # out-of-tree build situation).
63 # Check for 'polly_site_config' user parameter, and use that if available.
64 site_cfg = lit_config.params.get('polly_site_config', None)
65 if site_cfg and os.path.exists(site_cfg):
66 lit_config.load_config(config, site_cfg)
69 # Try to detect the situation where we are using an out-of-tree build by
70 # looking for 'llvm-config'.
72 # FIXME: I debated (i.e., wrote and threw away) adding logic to
73 # automagically generate the lit.site.cfg if we are in some kind of fresh
74 # build situation. This means knowing how to invoke the build system though,
75 # and I decided it was too much magic. We should solve this by just having
76 # the .cfg files generated during the configuration step.
78 llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
80 lit_config.fatal('No site specific configuration available!')
82 # Get the source and object roots.
83 llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
84 llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
85 polly_src_root = os.path.join(llvm_src_root, "tools", "polly")
86 polly_obj_root = os.path.join(llvm_obj_root, "tools", "polly")
88 # Validate that we got a tree which points to here, using the standard
90 this_src_root = os.path.dirname(config.test_source_root)
91 if os.path.realpath(polly_src_root) != os.path.realpath(this_src_root):
92 lit_config.fatal('No site specific configuration available!')
94 # Check that the site specific configuration exists.
95 site_cfg = os.path.join(polly_obj_root, 'test', 'lit.site.cfg')
96 if not os.path.exists(site_cfg):
97 lit_config.fatal('No site specific configuration available!')
99 # Okay, that worked. Notify the user of the automagic, and reconfigure.
100 lit_config.note('using out-of-tree build at %r' % polly_obj_root)
101 lit_config.load_config(config, site_cfg)
104 # opt knows whether it is compiled with -DNDEBUG.
107 opt_cmd = subprocess.Popen([os.path.join(llvm_tools_dir, 'opt'), '-version'],
108 stdout = subprocess.PIPE,
109 env=config.environment)
111 print("Could not find opt in " + llvm_tools_dir)
114 if re.search(r'with assertions', opt_cmd.stdout.read().decode('ascii')):
115 config.available_features.add('asserts')
119 llvm_config_cmd = subprocess.Popen([os.path.join(llvm_tools_dir,
122 stdout = subprocess.PIPE,
123 env=config.environment)
125 print("Could not find llvm-config in " + llvm_tools_dir)
128 if re.search(r'NVPTX', llvm_config_cmd.stdout.read().decode('ascii')):
129 config.available_features.add('nvptx-registered-target')
130 llvm_config_cmd.wait()