Remove llvm.lifetime.start/end in original region.
[polly-mirror.git] / test / lit.cfg
blob45d774f28176527e8deb8fc4f22d3a261e54654f
1 # -*clang- Python -*-
3 import os
4 import platform
5 import re
7 import lit.formats
8 import lit.util
10 # Configuration file for the 'lit' test runner.
12 # name: The name of this test suite.
13 config.name = 'Polly'
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     path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
43     config.environment['PATH'] = path
45     llvm_libs_dir = getattr(config, 'llvm_libs_dir', None)
46     if not llvm_libs_dir:
47         lit_config.fatal('No LLVM libs dir set!')
48     path = os.path.pathsep.join((llvm_libs_dir,
49                                  config.environment.get('LD_LIBRARY_PATH','')))
50     config.environment['LD_LIBRARY_PATH'] = path
52 ###
54 # Check that the object root is known.
55 if config.test_exec_root is None:
56     # Otherwise, we haven't loaded the site specific configuration (the user is
57     # probably trying to run on a test file directly, and either the site
58     # configuration hasn't been created by the build system, or we are in an
59     # out-of-tree build situation).
61     # Check for 'polly_site_config' user parameter, and use that if available.
62     site_cfg = lit_config.params.get('polly_site_config', None)
63     if site_cfg and os.path.exists(site_cfg):
64         lit_config.load_config(config, site_cfg)
65         raise SystemExit
67     # Try to detect the situation where we are using an out-of-tree build by
68     # looking for 'llvm-config'.
69     #
70     # FIXME: I debated (i.e., wrote and threw away) adding logic to
71     # automagically generate the lit.site.cfg if we are in some kind of fresh
72     # build situation. This means knowing how to invoke the build system though,
73     # and I decided it was too much magic. We should solve this by just having
74     # the .cfg files generated during the configuration step.
76     llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
77     if not llvm_config:
78         lit_config.fatal('No site specific configuration available!')
80     # Get the source and object roots.
81     llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
82     llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
83     polly_src_root = os.path.join(llvm_src_root, "tools", "polly")
84     polly_obj_root = os.path.join(llvm_obj_root, "tools", "polly")
86     # Validate that we got a tree which points to here, using the standard
87     # tools/polly layout.
88     this_src_root = os.path.dirname(config.test_source_root)
89     if os.path.realpath(polly_src_root) != os.path.realpath(this_src_root):
90         lit_config.fatal('No site specific configuration available!')
92     # Check that the site specific configuration exists.
93     site_cfg = os.path.join(polly_obj_root, 'test', 'lit.site.cfg')
94     if not os.path.exists(site_cfg):
95         lit_config.fatal('No site specific configuration available!')
97     # Okay, that worked. Notify the user of the automagic, and reconfigure.
98     lit_config.note('using out-of-tree build at %r' % polly_obj_root)
99     lit_config.load_config(config, site_cfg)
100     raise SystemExit
102 # opt knows whether it is compiled with -DNDEBUG.
103 import subprocess
104 try:
105     opt_cmd = subprocess.Popen([os.path.join(llvm_tools_dir, 'opt'), '-version'],
106                            stdout = subprocess.PIPE,
107                            env=config.environment)
108 except OSError:
109     print("Could not find opt in " + llvm_tools_dir)
110     exit(42)
112 if re.search(r'with assertions', opt_cmd.stdout.read().decode('ascii')):
113     config.available_features.add('asserts')
114 opt_cmd.wait()
116 try:
117     llvm_config_cmd = subprocess.Popen([os.path.join(llvm_tools_dir,
118                                                      'llvm-config'),
119                                         '--targets-built'],
120                                        stdout = subprocess.PIPE,
121                                        env=config.environment)
122 except OSError:
123     print("Could not find llvm-config in " + llvm_tools_dir)
124     exit(42)
126 if re.search(r'NVPTX', llvm_config_cmd.stdout.read().decode('ascii')):
127     config.available_features.add('nvptx-registered-target')
128 llvm_config_cmd.wait()