Revert "Batch merge"
[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(opsys('mingw32'), [ignore_stderr, exit_code(11)]),
38       # since these test are supposed to crash the
39       # profile report will be empty always.
40       # so disable the check for profiling
41       when(opsys('mingw32'), omit_ways(prof_ways))],
42      compile_and_run, ['-with-rtsopts="--generate-stack-traces=no"'])
43 test('divbyzero',
44      [# SIGFPE on Linux
45       exit_code(136),
46       # Apparently the output can be different on different
47       # Linux setups, so just ignore it. As long as we get
48       # the right exit code we're OK.
49       when(opsys('linux'), ignore_stderr),
50       # PowerPC 64 bit and most likely PowerPC 32 bit processors
51       # do not generate an exception (interrupt) for integer
52       # division by zero but the result is undefined.
53       # C programs compiled with gcc exit normally, so do we.
54       when(platform('powerpc64-unknown-linux'), [ignore_stdout, exit_code(0)]),
55       when(platform('powerpc64le-unknown-linux'), [ignore_stdout, exit_code(0)]),
56       when(opsys('mingw32'), [ignore_stderr, exit_code(8)]),
57       # The output under OS X is too unstable to readily compare
58       when(platform('i386-apple-darwin'), [ignore_stderr, exit_code(136)]),
59       when(platform('x86_64-apple-darwin'), [ignore_stderr, exit_code(136)]),
60       # since these test are supposed to crash the
61       # profile report will be empty always.
62       # so disable the check for profiling
63       when(opsys('mingw32'), omit_ways(prof_ways))],
64      compile_and_run, ['-with-rtsopts="--generate-stack-traces=no"'])
65
66 test('outofmem', when(opsys('darwin'), skip),
67                  run_command, ['$MAKE -s --no-print-directory outofmem'])
68 test('outofmem2', normal, run_command, ['$MAKE -s --no-print-directory outofmem2'])
69
70 test('T2047', [ignore_stdout, extra_run_opts('+RTS -c -RTS')],
71               compile_and_run, ['-package containers'])
72
73 # Blackhole-detection test.
74 # Skip GHCi due to #2786
75 test('T2783', [ omit_ways(['ghci']), exit_code(1)
76               , expect_broken_for(2783, ['threaded1'])
77               ], 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', [extra_files(['../../../rts/WSDeque.h']),
82                      unless(in_tree_compiler(), skip),
83                     req_smp, # needs atomic 'cas'
84                     c_src, only_ways(['threaded1', 'threaded2'])],
85                     compile_and_run, [''])
86
87 test('T3236', [c_src, only_ways(['normal','threaded1']), exit_code(1)], compile_and_run, [''])
88
89 test('stack001', extra_run_opts('+RTS -K32m -RTS'), compile_and_run, [''])
90 test('stack002', [extra_files(['stack001.hs']),
91                   extra_run_opts('+RTS -K32m -k4m -RTS')],
92      compile_and_run, [''])
93
94 # run this test with very small stack chunks to exercise the stack
95 # overflow/underflow machinery.
96 test('stack003', [ omit_ways('ghci'), # uses unboxed tuples
97                    extra_run_opts('500000 +RTS -kc1k -kb100 -K96m -RTS') ],
98                  compile_and_run, [''])
99
100 # Test that +RTS -K0 (e.g. no stack limit) parses correctly
101 test('stack004', [ extra_run_opts('+RTS -K0 -RTS')
102                  , expect_broken_for(14913, ['ghci'])
103                  ], compile_and_run, [''])
104
105 test('atomicinc', [ c_src, only_ways(['normal','threaded1', 'threaded2']) ], compile_and_run, [''])
106 test('atomicxchg', [ c_src, only_ways(['threaded1', 'threaded2']) ],
107 compile_and_run, [''])
108
109 test('T3424', # it's slow:
110               [ when(fast(), skip), only_ways(['normal','threaded1','ghci']) ],
111               compile_and_run, [''])
112
113 # Test for out-of-range heap size
114 test('rtsflags001', [ only_ways(['normal']), exit_code(1), extra_run_opts('+RTS -H0m -RTS') ], compile_and_run, [''])
115
116 # Crashed with 7.2 and earlier
117 test('rtsflags002', [ only_ways(['normal']) ], compile_and_run, ['-with-rtsopts="-B -B -B"'])
118
119 # Test to see if linker scripts link properly to real ELF files
120 test('T2615',
121      [extra_files(['libfoo_T2615.c', 'libfoo_script_T2615.so']),
122        when(opsys('mingw32'), skip),
123        # OS X doesn't seem to support linker scripts
124        when(opsys('darwin'), skip),
125        # Solaris' linker does not support GNUish linker scripts
126        when(opsys('solaris2'), skip),
127        pre_cmd('$MAKE -s --no-print-directory T2615-prep'),
128        # Add current directory to dlopen search path
129        cmd_prefix('LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. '),
130        extra_clean(['libfoo_T2615.so', 'libfoo_T2615.o'])],
131      compile_and_run,
132      ['-package ghc'])
133
134 # omit dyn and profiling ways, because we don't build dyn_l or p_l
135 # variants of the RTS by default
136 test('traceEvent', [ omit_ways(['dyn', 'ghci'] + prof_ways),
137                      extra_run_opts('+RTS -ls -RTS') ],
138                    compile_and_run, ['-eventlog'])
139
140 test('traceBinaryEvent', [ omit_ways(['dyn', 'ghci'] + prof_ways),
141                            extra_run_opts('+RTS -ls -RTS') ],
142                          compile_and_run, ['-eventlog'])
143
144 # Test that -ol flag works as expected
145 test('EventlogOutput1',
146      [ extra_files(["EventlogOutput.hs"]),
147        omit_ways(['dyn', 'ghci'] + prof_ways) ],
148      run_command, ['$MAKE -s --no-print-directory EventlogOutput1'])
149
150 # Test that -ol flag defaults to <program>.eventlog
151 test('EventlogOutput2',
152      [ extra_files(["EventlogOutput.hs"]),
153        omit_ways(['dyn', 'ghci'] + prof_ways) ],
154      run_command, ['$MAKE -s --no-print-directory EventlogOutput2'])
155
156 test('T4059', [], run_command, ['$MAKE -s --no-print-directory T4059'])
157
158 # Test for #4274
159 test('exec_signals',
160      [when(opsys('mingw32'), skip),
161       pre_cmd('$MAKE -s --no-print-directory exec_signals-prep'),
162       cmd_prefix('./exec_signals_prepare')],
163      compile_and_run, [''])
164
165 test('return_mem_to_os', normal, compile_and_run, [''])
166
167 test('T4850', when(opsys('mingw32'), expect_broken(4850)), run_command, ['$MAKE -s --no-print-directory T4850'])
168
169 def config_T5250(name, opts):
170     if not (config.arch in ['i386','x86_64']):
171         opts.skip = 1;
172
173 test('T5250', [extra_files(['spalign.c']),
174                 config_T5250,
175                 # stack ptr is not 16-byte aligned on 32-bit Windows
176                 when(platform('i386-unknown-mingw32'), expect_fail),
177                 when(platform('i386-unknown-linux'),
178                             expect_broken_for(4211,['llvm'])),
179                 extra_clean(['spalign.o']),
180                 omit_ways(['ghci']) ],
181               compile_and_run, ['spalign.c'])
182
183 test('T5423', [], run_command, ['$MAKE -s --no-print-directory T5423'])
184
185 # Workaround bug #8458: old dlopen opens sections in the wrong order,
186 # so we just accept both orders.
187 def checkDynAsm(actual_file, normaliser):
188     actual_raw = read_no_crs(actual_file)
189     actual_str = normaliser(actual_raw)
190     actual = actual_str.split()
191     if actual == ['initArray1', 'initArray2', 'success']:
192         return True
193     elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
194         return True
195     elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
196         return True
197     else:
198         if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
199         return False
200
201 # T5435_v_asm got split into two tests because depending
202 # on the linker, .init_array and .ctors sections are loaded
203 # in a different order (but all entries within a section
204 # do get loaded in a deterministic order). So we test each
205 # separately now.
206 # These should have extra_clean() arguments, but I need
207 # to somehow extract out the name of DLLs to do that
208 test('T5435_v_asm_a', [extra_files(['T5435.hs', 'T5435_asm.c']),
209                      when(arch('powerpc64') or arch('powerpc64le'),
210                           expect_broken(11259))],
211      run_command, ['$MAKE -s --no-print-directory T5435_v_asm_a'])
212 # this one just needs to run on linux, as darwin/mingw32 are covered
213 # by the _a test already.
214 test('T5435_v_asm_b', [extra_files(['T5435.hs', 'T5435_asm.c']),
215                       when(arch('powerpc64') or arch('powerpc64le'),
216                           expect_broken(11259)),
217                       when(opsys('darwin') or opsys('mingw32'), skip)],
218      run_command, ['$MAKE -s --no-print-directory T5435_v_asm_b'])
219 test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']),
220                      when(arch('powerpc64') or arch('powerpc64le'),
221                           expect_broken(11259))],
222      run_command, ['$MAKE -s --no-print-directory T5435_v_gcc'])
223 test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']),
224                        check_stdout(checkDynAsm)],
225      run_command, ['$MAKE -s --no-print-directory T5435_dyn_asm'])
226 test('T5435_dyn_gcc', extra_files(['T5435.hs', 'T5435_gcc.c']) , run_command, ['$MAKE -s --no-print-directory T5435_dyn_gcc'])
227
228 test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
229
230 test('T6006', [ omit_ways(prof_ways + ['ghci']),
231                  extra_clean(['T6006_c.o']),
232                  pre_cmd('$MAKE -s --no-print-directory T6006_setup') ],
233                  # The T6006_setup hack is to ensure that we generate
234                  # T6006_stub.h before compiling T6006_c.c, which
235                  # needs it.
236                compile_and_run, ['T6006_c.c -no-hs-main'])
237
238 test('T7037', [], run_command, ['$MAKE -s --no-print-directory T7037'])
239
240 test('T7087', exit_code(1), compile_and_run, [''])
241 test('T7160', normal, compile_and_run, [''])
242
243 test('T7040', [omit_ways(['ghci'])], compile_and_run, ['T7040_c.c'])
244
245 test('T7040_ghci',
246      [extra_files(['T7040_c.h']),
247       only_ways(['ghci']),
248       # Fragile when unregisterised; see #16085
249       when(unregisterised(), skip),
250       pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')],
251      compile_and_run, ['T7040_ghci_c.o'])
252
253 test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')],
254      compile_and_run, [''])
255
256 test('T7636', [ exit_code(1), extra_run_opts('100000') ], compile_and_run, [''] )
257
258 test('stablename001', expect_fail_for(['hpc']), compile_and_run, [''])
259 # hpc should fail this, because it tags every variable occurrence with
260 # a different tick.  It's probably a bug if it works, hence expect_fail.
261
262 test('T7815', [ multi_cpu_race,
263                 extra_run_opts('50000 +RTS -N2 -RTS'),
264                 req_smp,
265                 only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] )
266
267 # ignore_stderr because it contains a unique:
268 #   ffishutdown: Main_dul: interrupted
269 test('ffishutdown', [ignore_stderr, only_ways(['threaded1','threaded2'])],
270      compile_and_run, [''])
271
272 test('T7919', [when(fast(), skip), omit_ways(prof_ways)], compile_and_run,
273      [config.ghc_th_way_flags])
274
275 test('T8035', normal, compile_and_run, [''])
276
277 test('linker_unload',
278      [extra_files(['LinkerUnload.hs', 'Test.hs']),
279       when(arch('powerpc64') or arch('powerpc64le'), expect_broken(11259))],
280      run_command, ['$MAKE -s --no-print-directory linker_unload'])
281
282 test('T8209', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
283               compile_and_run, [''])
284
285 test('T8242', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
286               compile_and_run, [''])
287
288 test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']),
289                  when(opsys('mingw32'), skip), # uses pthreads
290                  extra_clean(['T8124_c.o']),
291                  pre_cmd('$MAKE -s --no-print-directory T8124_setup') ],
292                  # The T8124_setup hack is to ensure that we generate
293                  # T8124_stub.h before compiling T8124_c.c, which
294                  # needs it.
295                compile_and_run, ['T8124_c.c -no-hs-main'])
296
297 # +RTS -A8k makes it fail faster
298 # The ghci way gets confused by the RTS options
299 test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], compile_and_run, [''])
300
301 # T9078 needs to be compiled with -debug, which threaded1 does for us.
302 # Assert failure is reproducible with ghc-7.8.2.
303 test('T9078', only_ways(['threaded1']), compile_and_run, [''])
304
305 test('T10017', [ when(opsys('mingw32'), skip)
306                , when(unregisterised(), skip)
307                , req_smp
308                , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, [''])
309
310 test('T11108', normal, compile_and_run, [''])
311
312 test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip)
313                  # this needs runtime infrastructure to do in ghci:
314                  #  '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more.
315                  , omit_ways(['ghci'])
316                  ],
317      compile_and_run, ['-rdynamic -package ghc'])
318
319 test('GcStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
320      compile_and_run, [''])
321 test('ListStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
322      compile_and_run, [''])
323
324 # 251 = RTS exit code for "out of memory"
325 test('overflow1', [ exit_code(251), when(wordsize(32), expect_broken(15255)) ],
326      compile_and_run, [''])
327 test('overflow2', [ exit_code(251) ], compile_and_run, [''])
328 test('overflow3', [ exit_code(251) ], compile_and_run, [''])
329
330 test('linker_error1', [extra_files(['linker_error.c']),
331                        ignore_stderr], run_command,
332      ['$MAKE -s --no-print-directory linker_error1'])
333
334 test('linker_error2', [extra_files(['linker_error.c']),
335                        ignore_stderr], run_command,
336      ['$MAKE -s --no-print-directory linker_error2'])
337
338 test('linker_error3', [extra_files(['linker_error.c']),
339                        ignore_stderr], run_command,
340      ['$MAKE -s --no-print-directory linker_error3'])
341
342 def grep_stderr(pattern):
343     def wrapper(cmd, pattern=pattern):
344         swap12 = '3>&1 1>&2 2>&3 3>&-' # Swap file descriptors 1 and 2.
345         return('{cmd} {swap12} | grep "{pattern}" {swap12}'.format(**locals()))
346     return cmd_wrapper(wrapper)
347
348 # The ghci way gets confused by the RTS options
349 test('T9839_01',
350      [omit_ways(['ghci']), extra_run_opts('+RTS -T-s'), no_check_hp,
351       grep_stderr('given an argument when none was expected')],
352      compile_and_run, [''])
353
354 test('T9839_02',
355      [only_ways(prof_ways), extra_run_opts('+RTS -Pax'), no_check_hp,
356       grep_stderr('given an argument when none was expected')],
357      compile_and_run, [''])
358
359 test('T9839_03',
360      [only_ways(prof_ways), extra_run_opts('+RTS -Px'), no_check_hp,
361       grep_stderr('given an argument when none was expected')],
362      compile_and_run, [''])
363
364 test('T9839_04',
365      [only_ways(prof_ways), extra_run_opts('+RTS -xc')],
366      compile_and_run, [''])
367
368 test('T9839_05',
369      [only_ways(prof_ways), extra_run_opts('+RTS -xcx'), no_check_hp,
370       grep_stderr('given an argument when none was expected')],
371      compile_and_run, [''])
372
373 test('T9839_06',
374      [only_ways(prof_ways), extra_run_opts('+RTS -xtx'), no_check_hp,
375       grep_stderr('given an argument when none was expected')],
376      compile_and_run, [''])
377
378 # ignore_stderr as RTS reports slightly different error messages
379 # in 'epoll' and 'select' backends on reading from EBADF
380 # mingw32 skip as UNIX pipe and close(fd) is used to exercise the problem
381 test('T10590', [ignore_stderr, when(opsys('mingw32'), skip)], compile_and_run, [''])
382
383 # 20000 was easily enough to trigger the bug with 7.10
384 test('T10904', [ omit_ways(['ghci']), extra_run_opts('20000') ],
385                compile_and_run, ['T10904lib.c'])
386
387 test('T10728', [extra_run_opts('+RTS -maxN3 -RTS'), only_ways(['threaded2'])],
388                compile_and_run, [''])
389
390 test('T9405', [when(msys(), expect_broken(12714))], run_command,
391      ['$MAKE -s --no-print-directory T9405'])
392
393 test('T11788', when(ghc_dynamic(), skip),
394               run_command, ['$MAKE -s --no-print-directory T11788'])
395
396 test('T10296a', [req_smp], run_command,
397      ['$MAKE -s --no-print-directory T10296a'])
398
399 test('T10296b', [only_ways('threaded2')], compile_and_run, [''])
400
401 test('numa001', [ extra_run_opts('8'), unless(unregisterised(), extra_ways(['debug_numa'])) ]
402                 , compile_and_run, [''])
403
404 test('T12497', [ unless(opsys('mingw32'), skip)
405                ],
406                run_command, ['$MAKE -s --no-print-directory T12497'])
407
408 test('T13617', [ unless(opsys('mingw32'), skip)],
409                run_command, ['$MAKE -s --no-print-directory T13617'])
410
411 # This test sometimes produces out of sequence samples in the profasm way, but
412 # not reliably, so we just skip it. See ticket #15065.
413 # Test is being skipped on darwin due to it's flakiness.
414 test('T12903', [ when(opsys('mingw32'), skip)
415                , when(opsys('darwin'), skip)
416                    , omit_ways(['ghci', 'profasm'])]
417                , compile_and_run, [''])
418
419 test('T13832', exit_code(1), compile_and_run, ['-threaded'])
420 test('T13894', normal, compile_and_run, [''])
421 # this test fails with the profasm way on some machines but not others,
422 # so we just skip it.
423 test('T14497', [omit_ways(['profasm']), multi_cpu_race], compile_and_run, ['-O'])
424 test('T14695', [normal, ignore_stderr]
425              , run_command, ['$MAKE -s --no-print-directory T14695'])
426 test('T14702', [ ignore_stdout
427                , when(unregisterised(), skip)
428                , only_ways(['threaded1', 'threaded2'])
429                , extra_run_opts('+RTS -A32m -N8 -T -RTS')
430                ]
431                , compile_and_run, [''])
432
433 test('T14900', normal, compile_and_run, ['-package ghc-compact'])
434 test('InternalCounters', normal, run_command,
435   ['$MAKE -s --no-print-directory InternalCounters'])
436 test('alloccounter1', normal, compile_and_run,
437   [
438     # avoid allocating stack chunks, which counts as
439     # allocation and messes up the results:
440     '-with-rtsopts=-k1m'
441   ])
442
443 test('nursery-chunks1',
444   [ extra_run_opts('4 100 +RTS -n32k -A1m -RTS')
445   , req_smp
446   , only_ways(['threaded1','threaded2'])
447   ],
448   compile_and_run,
449   [''])
450
451 # Test for the "Evaluated a CAF that was GC'd" assertion in the debug
452 # runtime, by dynamically loading code that re-evaluates the CAF.
453 # Also tests the -rdynamic and -fwhole-archive-hs-libs flags for constructing
454 # binaries that support runtime dynamic loading.
455 test('keep-cafs-fail',
456   [ extra_files(['KeepCafsBase.hs', 'KeepCafs1.hs',
457                  'KeepCafs2.hs', 'KeepCafsMain.hs']),
458     when(opsys('mingw32'), expect_broken (5987)),
459     when(platform('powerpc64le-unknown-linux'), expect_broken(11261)),
460     when(opsys('freebsd'), expect_broken(16035)),
461     filter_stdout_lines('Evaluated a CAF|exit.*'),
462     ignore_stderr, # on OS X the shell emits an "Abort trap" message to stderr
463   ],
464   run_command,
465   ['$MAKE -s --no-print-directory KeepCafsFail'])
466
467 # Test the -fkeep-cafs flag
468 test('keep-cafs',
469   [ extra_files(['KeepCafsBase.hs', 'KeepCafs1.hs',
470                  'KeepCafs2.hs', 'KeepCafsMain.hs']),
471     when(opsys('mingw32'), expect_broken (5987)),
472     when(platform('powerpc64le-unknown-linux'), expect_broken(11261)),
473     when(opsys('freebsd'), expect_broken(16035)),
474   ],
475   run_command,
476   ['$MAKE -s --no-print-directory KeepCafs'])
477