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