Remove clean_cmd and extra_clean usage from .T files
[ghc.git] / testsuite / tests / rts / all.T
1 test('testblockalloc',
2      [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0')],
3      compile_and_run, [''])
4
5 test('testmblockalloc',
6      [c_src, only_ways(['normal','threaded1']), extra_run_opts('+RTS -I0')],
7      compile_and_run, [''])
8 # -I0 is important: the idle GC will run the memory leak detector,
9 # which will crash because the mblocks we allocate are not in a state
10 # the leak detector is expecting.
11
12
13 # See bug #101, test requires +RTS -c (or equivalently +RTS -M<something>)
14 # only GHCi triggers the bug, but we run the test all ways for completeness.
15 test('bug1010', normal, compile_and_run, ['+RTS -c -RTS'])
16
17 def normalise_address(str):
18     return re.sub('Access violation in generated code when reading [0]+',
19                   'Access violation in generated code when reading ADDRESS',
20                   str)
21
22 test('derefnull',
23      [# LLVM Optimiser considers dereference of a null pointer
24       # undefined and marks the code as unreachable which means
25       # that later optimisations remove it altogether.
26       omit_ways(['optllvm']),
27       # SIGSEGV on Linux (which we make the default)
28       exit_code(139),
29       # Apparently the output can be different on different
30       # Linux setups, so just ignore it. As long as we get
31       # the right exit code we're OK.
32       when(opsys('linux'), ignore_stderr),
33       # SIGBUS on OX X (PPC and x86 only; amd64 gives SEGV)
34       # The output under OS X is too unstable to readily compare
35       when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(139)]),
36       when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(139)]),
37       when(platform('powerpc-apple-darwin'), [ignore_stderr, exit_code(139)]),
38       when(opsys('mingw32'), [exit_code(1), normalise_fun(normalise_address)]),
39       # since these test are supposed to crash the
40       # profile report will be empty always.
41       # so disable the check for profiling
42       when(opsys('mingw32'), omit_ways(prof_ways))],
43      compile_and_run, [''])
44 test('divbyzero',
45      [# SIGFPE on Linux
46       exit_code(136),
47       # Apparently the output can be different on different
48       # Linux setups, so just ignore it. As long as we get
49       # the right exit code we're OK.
50       when(opsys('linux'), ignore_stderr),
51       # PowerPC 64 bit and most likely PowerPC 32 bit processors
52       # do not generate an exception (interrupt) for integer
53       # division by zero but the result is undefined.
54       # C programs compiled with gcc exit normally, so do we.
55       when(platform('powerpc64-unknown-linux'), [ignore_stdout, exit_code(0)]),
56       when(platform('powerpc64le-unknown-linux'), [ignore_stdout, exit_code(0)]),
57       when(opsys('mingw32'), exit_code(1)),
58       # The output under OS X is too unstable to readily compare
59       when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(136)]),
60       when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]),
61       when(platform('powerpc-apple-darwin'), [ignore_stderr, exit_code(136)]),
62       # since these test are supposed to crash the
63       # profile report will be empty always.
64       # so disable the check for profiling
65       when(opsys('mingw32'), omit_ways(prof_ways))],
66      compile_and_run, [''])
67
68 test('outofmem', when(opsys('darwin'), skip),
69                  run_command, ['$MAKE -s --no-print-directory outofmem'])
70 test('outofmem2', normal, run_command, ['$MAKE -s --no-print-directory outofmem2'])
71
72 test('T2047', [ignore_stdout, extra_run_opts('+RTS -c -RTS')],
73               compile_and_run, ['-package containers'])
74
75 # Blackhole-detection test.
76 # Skip GHCi due to #2786
77 test('T2783', [ omit_ways(['ghci']), exit_code(1) ], compile_and_run, [''])
78
79 # Test the work-stealing deque implementation.  We run this test in
80 # both threaded1 (-threaded -debug) and threaded2 (-threaded) ways.
81 test('testwsdeque', [unless(in_tree_compiler(), skip),
82                     req_smp, # needs atomic 'cas'
83                     c_src, only_ways(['threaded1', 'threaded2'])],
84                     compile_and_run, [''])
85
86 test('T3236', [c_src, only_ways(['normal','threaded1']), exit_code(1)], compile_and_run, [''])
87
88 test('stack001', extra_run_opts('+RTS -K32m -RTS'), compile_and_run, [''])
89 test('stack002', extra_run_opts('+RTS -K32m -k4m -RTS'), compile_and_run, [''])
90
91 # run this test with very small stack chunks to exercise the stack
92 # overflow/underflow machinery.
93 test('stack003', [ omit_ways('ghci'), # uses unboxed tuples
94                    extra_run_opts('500000 +RTS -kc1k -kb100 -K96m -RTS') ],
95                  compile_and_run, [''])
96
97 test('atomicinc', [ c_src, only_ways(['normal','threaded1', 'threaded2']) ], compile_and_run, [''])
98 test('atomicxchg', [ c_src, only_ways(['threaded1', 'threaded2']) ],
99 compile_and_run, [''])
100
101 test('T3424', # it's slow:
102               [ when(fast(), skip), only_ways(['normal','threaded1','ghci']) ],
103               compile_and_run, [''])
104
105 # Test for out-of-range heap size
106 test('rtsflags001', [ only_ways(['normal']), exit_code(1), extra_run_opts('+RTS -H0m -RTS') ], compile_and_run, [''])
107
108 # Crashed with 7.2 and earlier
109 test('rtsflags002', [ only_ways(['normal']) ], compile_and_run, ['-with-rtsopts="-B -B -B"'])
110
111 # Test to see if linker scripts link properly to real ELF files
112 test('T2615',
113      [ when(opsys('mingw32'), skip),
114        # OS X doesn't seem to support linker scripts
115        when(opsys('darwin'), skip),
116        # Solaris' linker does not support GNUish linker scripts
117        when(opsys('solaris2'), skip),
118        pre_cmd('$MAKE -s --no-print-directory T2615-prep'),
119        # Add current directory to dlopen search path
120        cmd_prefix('LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. '),
121        extra_clean(['libfoo_T2615.so', 'libfoo_T2615.o'])],
122      compile_and_run,
123      ['-package ghc'])
124
125 # omit dyn and profiling ways, because we don't build dyn_l or p_l
126 # variants of the RTS by default
127 test('traceEvent', [ omit_ways(['dyn'] + prof_ways),
128                      extra_run_opts('+RTS -ls -RTS') ],
129                    compile_and_run, ['-eventlog'])
130
131 test('T4059', [], run_command, ['$MAKE -s --no-print-directory T4059'])
132
133 # Test for #4274
134 test('exec_signals',
135      [when(opsys('mingw32'), skip),
136       pre_cmd('$MAKE -s --no-print-directory exec_signals-prep'),
137       cmd_prefix('./exec_signals_prepare')],
138      compile_and_run, [''])
139
140 test('return_mem_to_os', normal, compile_and_run, [''])
141
142 test('T4850', when(opsys('mingw32'), expect_broken(4850)), run_command, ['$MAKE -s --no-print-directory T4850'])
143
144 def config_T5250(name, opts):
145     if not (config.arch in ['i386','x86_64']):
146         opts.skip = 1;
147
148 test('T5250', [ config_T5250,
149                 # stack ptr is not 16-byte aligned on 32-bit Windows
150                 when(platform('i386-unknown-mingw32'), expect_fail),
151                 when(platform('i386-unknown-linux'),
152                             expect_broken_for(4211,['llvm'])),
153                 extra_clean(['spalign.o']),
154                 omit_ways(['ghci']) ],
155               compile_and_run, ['spalign.c'])
156
157 test('T5423', [], run_command, ['$MAKE -s --no-print-directory T5423'])
158
159 # Workaround bug #8458: old dlopen opens sections in the wrong order,
160 # so we just accept both orders.
161 def checkDynAsm(actual_file, normaliser):
162     actual_raw = read_no_crs(actual_file)
163     actual_str = normaliser(actual_raw)
164     actual = actual_str.split()
165     if actual == ['initArray1', 'initArray2', 'ctors1', 'ctors2', 'success']:
166         return 1
167     elif actual == ['ctors1', 'ctors2', 'initArray1', 'initArray2', 'success']:
168         if_verbose(1, 'T5435_dyn_asm detected old-style dlopen, see #8458')
169         return 1
170     elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
171         return 1
172     elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
173         return 1
174     else:
175         if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
176         return 0
177
178 # These should have extra_clean() arguments, but I need
179 # to somehow extract out the name of DLLs to do that
180
181 test('T5435_v_asm', when(arch('powerpc64') or arch('powerpc64le'),
182      expect_broken(11259)),
183      run_command, ['$MAKE -s --no-print-directory T5435_v_asm'])
184 test('T5435_v_gcc', when(arch('powerpc64') or arch('powerpc64le'),
185      expect_broken(11259)),
186      run_command, ['$MAKE -s --no-print-directory T5435_v_gcc'])
187 test('T5435_dyn_asm', check_stdout(checkDynAsm), run_command, ['$MAKE -s --no-print-directory T5435_dyn_asm'])
188 test('T5435_dyn_gcc', normal , run_command, ['$MAKE -s --no-print-directory T5435_dyn_gcc'])
189
190 test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
191
192 test('T6006', [ omit_ways(prof_ways + ['ghci']),
193                  extra_clean(['T6006_c.o']),
194                  pre_cmd('$MAKE -s --no-print-directory T6006_setup') ],
195                  # The T6006_setup hack is to ensure that we generate
196                  # T6006_stub.h before compiling T6006_c.c, which
197                  # needs it.
198                compile_and_run, ['T6006_c.c -no-hs-main'])
199
200 test('T7037', [], run_command, ['$MAKE -s --no-print-directory T7037'])
201
202 test('T7087', exit_code(1), compile_and_run, [''])
203 test('T7160', normal, compile_and_run, [''])
204
205 test('T7040', [omit_ways(['ghci'])], compile_and_run, ['T7040_c.c'])
206
207 test('T7040_ghci',
208      [only_ways(['ghci']),
209       pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')],
210      compile_and_run, ['T7040_ghci_c.o'])
211
212 test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')],
213      compile_and_run, [''])
214
215 test('T7636', [ exit_code(1), extra_run_opts('100000') ], compile_and_run, [''] )
216
217 test('stablename001', expect_fail_for(['hpc']), compile_and_run, [''])
218 # hpc should fail this, because it tags every variable occurrence with
219 # a different tick.  It's probably a bug if it works, hence expect_fail.
220
221 test('T7815', [ multi_cpu_race,
222                 extra_run_opts('50000 +RTS -N2 -RTS'),
223                 req_smp,
224                 only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] )
225
226 # ignore_stderr because it contains a unique:
227 #   ffishutdown: Main_dul: interrupted
228 test('ffishutdown', [ignore_stderr, only_ways(['threaded1','threaded2'])],
229      compile_and_run, [''])
230
231 test('T7919', [when(fast(), skip), omit_ways(prof_ways)], compile_and_run,
232      [config.ghc_th_way_flags])
233
234 test('T8035', normal, compile_and_run, [''])
235
236 test('linker_unload',
237      [when(arch('powerpc64') or arch('powerpc64le'), expect_broken(11259))],
238      run_command, ['$MAKE -s --no-print-directory linker_unload'])
239
240 test('T8209', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
241               compile_and_run, [''])
242
243 test('T8242', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
244               compile_and_run, [''])
245
246 test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']),
247                  when(opsys('mingw32'), skip), # uses pthreads
248                  extra_clean(['T8124_c.o']),
249                  pre_cmd('$MAKE -s --no-print-directory T8124_setup') ],
250                  # The T8124_setup hack is to ensure that we generate
251                  # T8124_stub.h before compiling T8124_c.c, which
252                  # needs it.
253                compile_and_run, ['T8124_c.c -no-hs-main'])
254
255 # +RTS -A8k makes it fail faster
256 # The ghci way gets confused by the RTS options
257 test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], compile_and_run, [''])
258
259 # T9078 needs to be compiled with -debug, which threaded1 does for us.
260 # Assert failure is reproducible with ghc-7.8.2.
261 test('T9078', only_ways(['threaded1']), compile_and_run, [''])
262
263 test('T10017', [ when(opsys('mingw32'), skip)
264                , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, [''])
265
266 test('T11108', normal, compile_and_run, [''])
267
268 test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip)
269                  # this needs runtime infrastructure to do in ghci:
270                  #  '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more.
271                  , omit_ways(['ghci'])
272                  ],
273      compile_and_run, ['-rdynamic -package ghc'])
274
275 test('GcStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
276      compile_and_run, [''])
277 test('ListStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
278      compile_and_run, [''])
279
280 # 251 = RTS exit code for "out of memory"
281 test('overflow1', [ exit_code(251) ], compile_and_run, [''])
282 test('overflow2', [ exit_code(251) ], compile_and_run, [''])
283 test('overflow3', [ exit_code(251) ], compile_and_run, [''])
284
285 test('linker_error1', [ignore_stderr], run_command,
286      ['$MAKE -s --no-print-directory linker_error1'])
287
288 test('linker_error2', [ignore_stderr], run_command,
289      ['$MAKE -s --no-print-directory linker_error2'])
290
291 test('linker_error3', [ignore_stderr], run_command,
292      ['$MAKE -s --no-print-directory linker_error3'])
293
294 def grep_stderr(pattern):
295     def wrapper(cmd, pattern=pattern):
296         swap12 = '3>&1 1>&2 2>&3 3>&-' # Swap file descriptors 1 and 2.
297         return('{cmd} {swap12} | grep "{pattern}" {swap12}'.format(**locals()))
298     return cmd_wrapper(wrapper)
299
300 # The ghci way gets confused by the RTS options
301 test('T9839_01',
302      [omit_ways(['ghci']), extra_run_opts('+RTS -T-s'), no_check_hp,
303       grep_stderr('given an argument when none was expected')],
304      compile_and_run, [''])
305
306 test('T9839_02',
307      [only_ways(prof_ways), extra_run_opts('+RTS -Pax'), no_check_hp,
308       grep_stderr('given an argument when none was expected')],
309      compile_and_run, [''])
310
311 test('T9839_03',
312      [only_ways(prof_ways), extra_run_opts('+RTS -Px'), no_check_hp,
313       grep_stderr('given an argument when none was expected')],
314      compile_and_run, [''])
315
316 test('T9839_04',
317      [only_ways(prof_ways), extra_run_opts('+RTS -xc')],
318      compile_and_run, [''])
319
320 test('T9839_05',
321      [only_ways(prof_ways), extra_run_opts('+RTS -xcx'), no_check_hp,
322       grep_stderr('given an argument when none was expected')],
323      compile_and_run, [''])
324
325 test('T9839_06',
326      [only_ways(prof_ways), extra_run_opts('+RTS -xtx'), no_check_hp,
327       grep_stderr('given an argument when none was expected')],
328      compile_and_run, [''])
329
330 # ignore_stderr as RTS reports slightly different error messages
331 # in 'epoll' and 'select' backends on reading from EBADF
332 # mingw32 skip as UNIX pipe and close(fd) is used to exercise the problem
333 test('T10590', [ignore_stderr, when(opsys('mingw32'), skip)], compile_and_run, [''])
334
335 # 20000 was easily enough to trigger the bug with 7.10
336 test('T10904', [ omit_ways(['ghci']), extra_run_opts('20000') ],
337                compile_and_run, ['T10904lib.c'])
338
339 test('T10728', [extra_run_opts('+RTS -maxN3 -RTS'), only_ways(['threaded2'])],
340                compile_and_run, [''])
341
342 test('T9405', [when(msys(), expect_broken(12714))], run_command,
343      ['$MAKE -s --no-print-directory T9405'])
344
345 test('T11788', when(ghc_dynamic(), skip),
346               run_command, ['$MAKE -s --no-print-directory T11788'])
347
348 test('T10296a', [req_smp], run_command,
349      ['$MAKE -s --no-print-directory T10296a'])
350
351 test('T10296b', [only_ways('threaded2')], compile_and_run, [''])
352
353 test('numa001', [ extra_run_opts('8'), extra_ways(['debug_numa']) ]
354                 , compile_and_run, [''])
355
356 test('T12497', [ unless(opsys('mingw32'), skip)
357                ],
358                run_command, ['$MAKE -s --no-print-directory T12497'])
359
360 test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])
361