84921e43bcf8e60a2884c2ed84008f775f618ec0
[ghc.git] / testsuite / driver / testglobals.py
1 #
2 # (c) Simon Marlow 2002
3 #
4
5 # -----------------------------------------------------------------------------
6 # Configuration info
7
8 # There is a single global instance of this structure, stored in the
9 # variable config below. The fields of the structure are filled in by
10 # the appropriate config script(s) for this compiler/platform, in
11 # ../config.
12 #
13 # Bits of the structure may also be filled in from the command line,
14 # via the build system, using the '-e' option to runtests.
15
16 class TestConfig:
17 def __init__(self):
18
19 # Where the testsuite root is
20 self.top = ''
21
22 # Directories below which to look for test description files (foo.T)
23 self.rootdirs = []
24
25 # Run these tests only (run all tests if empty)
26 self.run_only_some_tests = False
27 self.only = set()
28
29 # Accept new output which differs from the sample?
30 self.accept = 0
31
32 # File in which to save the summary
33 self.summary_file = ''
34
35 # Should we print the summary?
36 # Disabling this is useful for Phabricator/Harbormaster
37 # logfiles, which are truncated to 30 lines. TODO. Revise if
38 # this is still true.
39 # Note that we have a separate flag for this, instead of
40 # overloading --verbose, as you might want to see the summary
41 # with --verbose=0.
42 self.no_print_summary = False
43
44 # File in which to save the times
45 self.times_file = ''
46
47 # What platform are we running on?
48 self.platform = ''
49 self.os = ''
50 self.arch = ''
51
52 # What is the wordsize (in bits) of this platform?
53 self.wordsize = ''
54
55 # Verbosity level
56 self.verbose = 3
57
58 # See Note [validate and testsuite speed] in toplevel Makefile.
59 self.speed = 1
60
61 self.list_broken = False
62
63 # Path to the compiler (stage2 by default)
64 self.compiler = ''
65 # and ghc-pkg
66 self.ghc_pkg = ''
67
68 # Is self.compiler a stage 1, 2 or 3 compiler?
69 self.stage = 2
70
71 # Flags we always give to this compiler
72 self.compiler_always_flags = []
73
74 # Which ways to run tests (when compiling and running respectively)
75 # Other ways are added from the command line if we have the appropriate
76 # libraries.
77 self.compile_ways = []
78 self.run_ways = []
79 self.other_ways = []
80
81 # The ways selected via the command line.
82 self.cmdline_ways = []
83
84 # Lists of flags for each way
85 self.way_flags = {}
86 self.way_rts_flags = {}
87
88 # Do we have vanilla libraries?
89 self.have_vanilla = False
90
91 # Do we have dynamic libraries?
92 self.have_dynamic = False
93
94 # Do we have profiling support?
95 self.have_profiling = False
96
97 # Do we have interpreter support?
98 self.have_interp = False
99
100 # Do we have shared libraries?
101 self.have_shared_libs = False
102
103 # Do we have SMP support?
104 self.have_smp = False
105
106 # Are we testing an in-tree compiler?
107 self.in_tree_compiler = True
108
109 # the timeout program
110 self.timeout_prog = ''
111 self.timeout = 300
112
113 # threads
114 self.threads = 1
115 self.use_threads = 0
116
117 # Should we skip performance tests
118 self.skip_perf_tests = False
119
120 global config
121 config = TestConfig()
122
123 def getConfig():
124 return config
125
126 # -----------------------------------------------------------------------------
127 # Information about the current test run
128
129 class TestRun:
130 def __init__(self):
131 self.start_time = None
132 self.total_tests = 0
133 self.total_test_cases = 0
134 self.n_framework_failures = 0
135 self.framework_failures = {}
136 self.n_tests_skipped = 0
137 self.tests_skipped = {}
138 self.n_expected_passes = 0
139 self.expected_passes = {}
140 self.n_expected_failures = 0
141 self.expected_failures = {}
142 self.n_missing_libs = 0
143 self.missing_libs = {}
144 self.n_unexpected_passes = 0
145 self.unexpected_passes = {}
146 self.n_unexpected_failures = 0
147 self.unexpected_failures = {}
148 self.n_unexpected_stat_failures = 0
149 self.unexpected_stat_failures = {}
150
151 global t
152 t = TestRun()
153
154 def getTestRun():
155 return t
156
157 # -----------------------------------------------------------------------------
158 # Information about the current test
159
160 class TestOptions:
161 def __init__(self):
162 # skip this test?
163 self.skip = 0
164
165 # skip these ways
166 self.omit_ways = []
167
168 # skip all ways except these (None == do all ways)
169 self.only_ways = None
170
171 # add these ways to the default set
172 self.extra_ways = []
173
174 # the result we normally expect for this test
175 self.expect = 'pass'
176
177 # override the expected result for certain ways
178 self.expect_fail_for = []
179
180 # the stdin file that this test will use (empty for <name>.stdin)
181 self.stdin = ''
182
183 # don't compare output
184 self.ignore_output = 0
185
186 # We sometimes want to modify the compiler_always_flags, so
187 # they are copied from config.compiler_always_flags when we
188 # make a new instance of TestOptions.
189 self.compiler_always_flags = []
190
191 # extra compiler opts for this test
192 self.extra_hc_opts = ''
193
194 # extra run opts for this test
195 self.extra_run_opts = ''
196
197 # expected exit code
198 self.exit_code = 0
199
200 # extra files to clean afterward
201 self.clean_files = []
202
203 # extra files to copy to the testdir
204 self.extra_files = []
205
206 # which -t numeric fields do we want to look at, and what bounds must
207 # they fall within?
208 # Elements of these lists should be things like
209 # ('bytes allocated',
210 # 9300000000,
211 # 10)
212 # To allow a 10% deviation from 9300000000.
213 self.compiler_stats_range_fields = {}
214 self.stats_range_fields = {}
215
216 # should we run this test alone, i.e. not run it in parallel with
217 # any other threads
218 self.alone = False
219
220 # Does this test use a literate (.lhs) file?
221 self.literate = 0
222
223 # Does this test use a .c, .m or .mm file?
224 self.c_src = 0
225 self.objc_src = 0
226 self.objcpp_src = 0
227
228 # Does this test use a .cmm file?
229 self.cmm_src = 0
230
231 # Should we put .hi/.o files in a subdirectory?
232 self.outputdir = None
233
234 # Command to run before the test
235 self.pre_cmd = None
236
237 # Command to run for extra cleaning
238 self.clean_cmd = None
239
240 # Command wrapper: a function to apply to the command before running it
241 self.cmd_wrapper = None
242
243 # Prefix to put on the command before compiling it
244 self.compile_cmd_prefix = ''
245
246 # Extra output normalisation
247 self.extra_normaliser = lambda x: x
248
249 # Custom output checker, otherwise do a comparison with expected
250 # stdout file. Accepts two arguments: filename of actual stdout
251 # output, and a normaliser function given other test options
252 self.check_stdout = None
253
254 # Extra normalisation for compiler error messages
255 self.extra_errmsg_normaliser = lambda x: x
256
257 # Keep profiling callstacks.
258 self.keep_prof_callstacks = False
259
260 # The directory the test is in
261 self.testdir = '.'
262
263 # Should we redirect stdout and stderr to a single file?
264 self.combined_output = False
265
266 # How should the timeout be adjusted on this test?
267 self.compile_timeout_multiplier = 1.0
268 self.run_timeout_multiplier = 1.0
269
270 self.cleanup = True
271
272 # Sould we run tests in a local subdirectory (<testname>-run) or
273 # in temporary directory in /tmp? See Note [Running tests in /tmp].
274 self.local = True
275
276 # The default set of options
277 global default_testopts
278 default_testopts = TestOptions()
279
280 # (bug, directory, name) of tests marked broken
281 global brokens
282 brokens = []
283