79e1461596d9a01ecd789667d9919053f2152b81
[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_files(['stack001.hs']),
90                   extra_run_opts('+RTS -K32m -k4m -RTS')],
91      compile_and_run, [''])
92
93 # run this test with very small stack chunks to exercise the stack
94 # overflow/underflow machinery.
95 test('stack003', [ omit_ways('ghci'), # uses unboxed tuples
96                    extra_run_opts('500000 +RTS -kc1k -kb100 -K96m -RTS') ],
97                  compile_and_run, [''])
98
99 test('atomicinc', [ c_src, only_ways(['normal','threaded1', 'threaded2']) ], compile_and_run, [''])
100 test('atomicxchg', [ c_src, only_ways(['threaded1', 'threaded2']) ],
101 compile_and_run, [''])
102
103 test('T3424', # it's slow:
104               [ when(fast(), skip), only_ways(['normal','threaded1','ghci']) ],
105               compile_and_run, [''])
106
107 # Test for out-of-range heap size
108 test('rtsflags001', [ only_ways(['normal']), exit_code(1), extra_run_opts('+RTS -H0m -RTS') ], compile_and_run, [''])
109
110 # Crashed with 7.2 and earlier
111 test('rtsflags002', [ only_ways(['normal']) ], compile_and_run, ['-with-rtsopts="-B -B -B"'])
112
113 # Test to see if linker scripts link properly to real ELF files
114 test('T2615',
115      [ when(opsys('mingw32'), skip),
116        # OS X doesn't seem to support linker scripts
117        when(opsys('darwin'), skip),
118        # Solaris' linker does not support GNUish linker scripts
119        when(opsys('solaris2'), skip),
120        pre_cmd('$MAKE -s --no-print-directory T2615-prep'),
121        # Add current directory to dlopen search path
122        cmd_prefix('LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. '),
123        extra_clean(['libfoo_T2615.so', 'libfoo_T2615.o'])],
124      compile_and_run,
125      ['-package ghc'])
126
127 # omit dyn and profiling ways, because we don't build dyn_l or p_l
128 # variants of the RTS by default
129 test('traceEvent', [ omit_ways(['dyn'] + prof_ways),
130                      extra_run_opts('+RTS -ls -RTS') ],
131                    compile_and_run, ['-eventlog'])
132
133 test('T4059', [], run_command, ['$MAKE -s --no-print-directory T4059'])
134
135 # Test for #4274
136 test('exec_signals',
137      [when(opsys('mingw32'), skip),
138       pre_cmd('$MAKE -s --no-print-directory exec_signals-prep'),
139       cmd_prefix('./exec_signals_prepare')],
140      compile_and_run, [''])
141
142 test('return_mem_to_os', normal, compile_and_run, [''])
143
144 test('T4850', when(opsys('mingw32'), expect_broken(4850)), run_command, ['$MAKE -s --no-print-directory T4850'])
145
146 def config_T5250(name, opts):
147     if not (config.arch in ['i386','x86_64']):
148         opts.skip = 1;
149
150 test('T5250', [ config_T5250,
151                 # stack ptr is not 16-byte aligned on 32-bit Windows
152                 when(platform('i386-unknown-mingw32'), expect_fail),
153                 when(platform('i386-unknown-linux'),
154                             expect_broken_for(4211,['llvm'])),
155                 extra_clean(['spalign.o']),
156                 omit_ways(['ghci']) ],
157               compile_and_run, ['spalign.c'])
158
159 test('T5423', [], run_command, ['$MAKE -s --no-print-directory T5423'])
160
161 # Workaround bug #8458: old dlopen opens sections in the wrong order,
162 # so we just accept both orders.
163 def checkDynAsm(actual_file, normaliser):
164     actual_raw = read_no_crs(actual_file)
165     actual_str = normaliser(actual_raw)
166     actual = actual_str.split()
167     if actual == ['initArray1', 'initArray2', 'ctors1', 'ctors2', 'success']:
168         return 1
169     elif actual == ['ctors1', 'ctors2', 'initArray1', 'initArray2', 'success']:
170         if_verbose(1, 'T5435_dyn_asm detected old-style dlopen, see #8458')
171         return 1
172     elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
173         return 1
174     elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
175         return 1
176     else:
177         if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
178         return 0
179
180 # These should have extra_clean() arguments, but I need
181 # to somehow extract out the name of DLLs to do that
182
183 test('T5435_v_asm', [extra_files(['T5435.hs', 'T5435_asm.c']),
184                      when(arch('powerpc64') or arch('powerpc64le'),
185                           expect_broken(11259))],
186      run_command, ['$MAKE -s --no-print-directory T5435_v_asm'])
187 test('T5435_v_gcc', [extra_files(['T5435.hs', 'T5435_gcc.c']),
188                      when(arch('powerpc64') or arch('powerpc64le'),
189                           expect_broken(11259))],
190      run_command, ['$MAKE -s --no-print-directory T5435_v_gcc'])
191 test('T5435_dyn_asm', [extra_files(['T5435.hs', 'T5435_asm.c']),
192                        check_stdout(checkDynAsm)],
193      run_command, ['$MAKE -s --no-print-directory T5435_dyn_asm'])
194 test('T5435_dyn_gcc', normal , run_command, ['$MAKE -s --no-print-directory T5435_dyn_gcc'])
195
196 test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
197
198 test('T6006', [ omit_ways(prof_ways + ['ghci']),
199                  extra_clean(['T6006_c.o']),
200                  pre_cmd('$MAKE -s --no-print-directory T6006_setup') ],
201                  # The T6006_setup hack is to ensure that we generate
202                  # T6006_stub.h before compiling T6006_c.c, which
203                  # needs it.
204                compile_and_run, ['T6006_c.c -no-hs-main'])
205
206 test('T7037', [], run_command, ['$MAKE -s --no-print-directory T7037'])
207
208 test('T7087', exit_code(1), compile_and_run, [''])
209 test('T7160', normal, compile_and_run, [''])
210
211 test('T7040', [omit_ways(['ghci'])], compile_and_run, ['T7040_c.c'])
212
213 test('T7040_ghci',
214      [only_ways(['ghci']),
215       pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup')],
216      compile_and_run, ['T7040_ghci_c.o'])
217
218 test('T7227', [extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS')],
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', [when(fast(), skip), omit_ways(prof_ways)], compile_and_run,
238      [config.ghc_th_way_flags])
239
240 test('T8035', normal, compile_and_run, [''])
241
242 test('linker_unload',
243      [when(arch('powerpc64') or arch('powerpc64le'), expect_broken(11259))],
244      run_command, ['$MAKE -s --no-print-directory linker_unload'])
245
246 test('T8209', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
247               compile_and_run, [''])
248
249 test('T8242', [ req_smp, only_ways(threaded_ways), ignore_stdout ],
250               compile_and_run, [''])
251
252 test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']),
253                  when(opsys('mingw32'), skip), # uses pthreads
254                  extra_clean(['T8124_c.o']),
255                  pre_cmd('$MAKE -s --no-print-directory T8124_setup') ],
256                  # The T8124_setup hack is to ensure that we generate
257                  # T8124_stub.h before compiling T8124_c.c, which
258                  # needs it.
259                compile_and_run, ['T8124_c.c -no-hs-main'])
260
261 # +RTS -A8k makes it fail faster
262 # The ghci way gets confused by the RTS options
263 test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], compile_and_run, [''])
264
265 # T9078 needs to be compiled with -debug, which threaded1 does for us.
266 # Assert failure is reproducible with ghc-7.8.2.
267 test('T9078', only_ways(['threaded1']), compile_and_run, [''])
268
269 test('T10017', [ when(opsys('mingw32'), skip)
270                , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, [''])
271
272 test('T11108', normal, compile_and_run, [''])
273
274 test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip)
275                  # this needs runtime infrastructure to do in ghci:
276                  #  '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more.
277                  , omit_ways(['ghci'])
278                  ],
279      compile_and_run, ['-rdynamic -package ghc'])
280
281 test('GcStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
282      compile_and_run, [''])
283 test('ListStaticPointers', [when(doing_ghci(), extra_hc_opts('-fobject-code'))],
284      compile_and_run, [''])
285
286 # 251 = RTS exit code for "out of memory"
287 test('overflow1', [ exit_code(251) ], compile_and_run, [''])
288 test('overflow2', [ exit_code(251) ], compile_and_run, [''])
289 test('overflow3', [ exit_code(251) ], compile_and_run, [''])
290
291 test('linker_error1', [ignore_stderr], run_command,
292      ['$MAKE -s --no-print-directory linker_error1'])
293
294 test('linker_error2', [ignore_stderr], run_command,
295      ['$MAKE -s --no-print-directory linker_error2'])
296
297 test('linker_error3', [ignore_stderr], run_command,
298      ['$MAKE -s --no-print-directory linker_error3'])
299
300 def grep_stderr(pattern):
301     def wrapper(cmd, pattern=pattern):
302         swap12 = '3>&1 1>&2 2>&3 3>&-' # Swap file descriptors 1 and 2.
303         return('{cmd} {swap12} | grep "{pattern}" {swap12}'.format(**locals()))
304     return cmd_wrapper(wrapper)
305
306 # The ghci way gets confused by the RTS options
307 test('T9839_01',
308      [omit_ways(['ghci']), extra_run_opts('+RTS -T-s'), no_check_hp,
309       grep_stderr('given an argument when none was expected')],
310      compile_and_run, [''])
311
312 test('T9839_02',
313      [only_ways(prof_ways), extra_run_opts('+RTS -Pax'), no_check_hp,
314       grep_stderr('given an argument when none was expected')],
315      compile_and_run, [''])
316
317 test('T9839_03',
318      [only_ways(prof_ways), extra_run_opts('+RTS -Px'), no_check_hp,
319       grep_stderr('given an argument when none was expected')],
320      compile_and_run, [''])
321
322 test('T9839_04',
323      [only_ways(prof_ways), extra_run_opts('+RTS -xc')],
324      compile_and_run, [''])
325
326 test('T9839_05',
327      [only_ways(prof_ways), extra_run_opts('+RTS -xcx'), no_check_hp,
328       grep_stderr('given an argument when none was expected')],
329      compile_and_run, [''])
330
331 test('T9839_06',
332      [only_ways(prof_ways), extra_run_opts('+RTS -xtx'), no_check_hp,
333       grep_stderr('given an argument when none was expected')],
334      compile_and_run, [''])
335
336 # ignore_stderr as RTS reports slightly different error messages
337 # in 'epoll' and 'select' backends on reading from EBADF
338 # mingw32 skip as UNIX pipe and close(fd) is used to exercise the problem
339 test('T10590', [ignore_stderr, when(opsys('mingw32'), skip)], compile_and_run, [''])
340
341 # 20000 was easily enough to trigger the bug with 7.10
342 test('T10904', [ omit_ways(['ghci']), extra_run_opts('20000') ],
343                compile_and_run, ['T10904lib.c'])
344
345 test('T10728', [extra_run_opts('+RTS -maxN3 -RTS'), only_ways(['threaded2'])],
346                compile_and_run, [''])
347
348 test('T9405', [when(msys(), expect_broken(12714))], run_command,
349      ['$MAKE -s --no-print-directory T9405'])
350
351 test('T11788', when(ghc_dynamic(), skip),
352               run_command, ['$MAKE -s --no-print-directory T11788'])
353
354 test('T10296a', [req_smp], run_command,
355      ['$MAKE -s --no-print-directory T10296a'])
356
357 test('T10296b', [only_ways('threaded2')], compile_and_run, [''])
358
359 test('numa001', [ extra_run_opts('8'), extra_ways(['debug_numa']) ]
360                 , compile_and_run, [''])
361
362 test('T12497', [ unless(opsys('mingw32'), skip)
363                ],
364                run_command, ['$MAKE -s --no-print-directory T12497'])
365
366 test('T12903', [when(opsys('mingw32'), skip)], compile_and_run, [''])
367