Reenable StackTracke.cpp test.
[oota-llvm.git] / test / lit.cfg
1 # -*- Python -*-
2
3 # Configuration file for the 'lit' test runner.
4
5 import os
6
7 # name: The name of this test suite.
8 config.name = 'LLVM'
9
10 # testFormat: The test format to use to interpret tests.
11 config.test_format = lit.formats.TclTest()
12
13 # suffixes: A list of file extensions to treat as test files, this is actually
14 # set by on_clone().
15 config.suffixes = []
16
17 # test_source_root: The root path where tests are located.
18 config.test_source_root = os.path.dirname(__file__)
19
20 # test_exec_root: The root path where tests should be run.
21 llvm_obj_root = getattr(config, 'llvm_obj_root', None)
22 if llvm_obj_root is not None:
23     config.test_exec_root = os.path.join(llvm_obj_root, 'test')
24
25 # Tweak the PATH to include the scripts dir, the tools dir, and the llvm-gcc bin
26 # dir (if available).
27 if llvm_obj_root is not None:
28     llvm_src_root = getattr(config, 'llvm_src_root', None)
29     if not llvm_src_root:
30         lit.fatal('No LLVM source root set!')
31     path = os.path.pathsep.join((os.path.join(llvm_src_root, 'test',
32                                               'Scripts'),
33                                  config.environment['PATH']))
34     config.environment['PATH'] = path
35
36     llvm_tools_dir = getattr(config, 'llvm_tools_dir', None)
37     if not llvm_tools_dir:
38         lit.fatal('No LLVM tools dir set!')
39     path = os.path.pathsep.join((llvm_tools_dir, config.environment['PATH']))
40     config.environment['PATH'] = path
41
42     llvmgcc_dir = getattr(config, 'llvmgcc_dir', None)
43     if not llvm_tools_dir:
44         lit.fatal('No llvm-gcc dir set!')
45     if llvmgcc_dir:
46         path = os.path.pathsep.join((os.path.join(llvmgcc_dir, 'bin'),
47                                      config.environment['PATH']))
48         config.environment['PATH'] = path
49
50 ###
51
52 import os
53
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).
60
61     # Try to detect the situation where we are using an out-of-tree build by
62     # looking for 'llvm-config'.
63     #
64     # FIXME: I debated (i.e., wrote and threw away) adding logic to
65     # automagically generate the lit.site.cfg if we are in some kind of fresh
66     # build situation. This means knowing how to invoke the build system
67     # though, and I decided it was too much magic.
68
69     llvm_config = lit.util.which('llvm-config', config.environment['PATH'])
70     if not llvm_config:
71         lit.fatal('No site specific configuration available!')
72
73     # Get the source and object roots.
74     llvm_src_root = lit.util.capture(['llvm-config', '--src-root']).strip()
75     llvm_obj_root = lit.util.capture(['llvm-config', '--obj-root']).strip()
76
77     # Validate that we got a tree which points to here.
78     this_src_root = os.path.dirname(config.test_source_root)
79     if os.path.realpath(llvm_src_root) != os.path.realpath(this_src_root):
80         lit.fatal('No site specific configuration available!')
81
82     # Check that the site specific configuration exists.
83     site_cfg = os.path.join(llvm_obj_root, 'test', 'lit.site.cfg')
84     if not os.path.exists(site_cfg):
85         lit.fatal('No site specific configuration available!')
86
87     # Okay, that worked. Notify the user of the automagic, and reconfigure.
88     lit.note('using out-of-tree build at %r' % llvm_obj_root)
89     lit.load_config(config, site_cfg)
90     raise SystemExit
91
92 ###
93
94 # Load site data from DejaGNU's site.exp.
95 import re
96 site_exp = {}
97 # FIXME: Implement lit.site.cfg.
98 for line in open(os.path.join(config.llvm_obj_root, 'test', 'site.exp')):
99     m = re.match('set ([^ ]+) "([^"]*)"', line)
100     if m:
101         site_exp[m.group(1)] = m.group(2)
102
103 # Add substitutions.
104 config.substitutions.append(('%llvmgcc_only', site_exp['llvmgcc']))
105 for sub in ['llvmgcc', 'llvmgxx', 'compile_cxx', 'compile_c',
106             'link', 'shlibext', 'ocamlopt', 'llvmdsymutil', 'llvmlibsdir',
107             'bugpoint_topts']:
108     if sub in ('llvmgcc', 'llvmgxx'):
109         config.substitutions.append(('%' + sub,
110                                      site_exp[sub] + ' -emit-llvm -w'))
111     else:
112         config.substitutions.append(('%' + sub, site_exp[sub]))
113
114 excludes = []
115
116 # Provide target_triple for use in XFAIL and XTARGET.
117 config.target_triple = site_exp['target_triplet']
118
119 # Provide llvm_supports_target for use in local configs.
120 targets = set(site_exp["TARGETS_TO_BUILD"].split())
121 def llvm_supports_target(name):
122     return name in targets
123
124 langs = set(site_exp['llvmgcc_langs'].split(','))
125 def llvm_gcc_supports(name):
126     return name in langs
127
128 bindings = set(site_exp['llvm_bindings'].split(','))
129 def llvm_supports_binding(name):
130     return name in langs
131
132 # Provide on_clone hook for reading 'dg.exp'.
133 import os
134 simpleLibData = re.compile(r"""load_lib llvm.exp
135
136 RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\]""",
137                            re.MULTILINE)
138 conditionalLibData = re.compile(r"""load_lib llvm.exp
139
140 if.*\[ ?(llvm[^ ]*) ([^ ]*) ?\].*{
141  *RunLLVMTests \[lsort \[glob -nocomplain \$srcdir/\$subdir/\*\.(.*)\]\]
142 \}""", re.MULTILINE)
143 def on_clone(parent, cfg, for_path):
144     def addSuffixes(match):
145         if match[0] == '{' and match[-1] == '}':
146             cfg.suffixes = ['.' + s for s in match[1:-1].split(',')]
147         else:
148             cfg.suffixes = ['.' + match]
149
150     libPath = os.path.join(os.path.dirname(for_path),
151                            'dg.exp')
152     if not os.path.exists(libPath):
153         cfg.unsupported = True
154         return
155
156     # Reset unsupported, in case we inherited it.
157     cfg.unsupported = False
158     lib = open(libPath).read().strip()
159
160     # Check for a simple library.
161     m = simpleLibData.match(lib)
162     if m:
163         addSuffixes(m.group(1))
164         return
165
166     # Check for a conditional test set.
167     m = conditionalLibData.match(lib)
168     if m:
169         funcname,arg,match = m.groups()
170         addSuffixes(match)
171
172         func = globals().get(funcname)
173         if not func:
174             lit.error('unsupported predicate %r' % funcname)
175         elif not func(arg):
176             cfg.unsupported = True
177         return
178     # Otherwise, give up.
179     lit.error('unable to understand %r:\n%s' % (libPath, lib))
180
181 config.on_clone = on_clone