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