Fix rdynamic flag and test on Windows
[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', extra_run_opts('+RTS -M5m -RTS'),
59                   run_command, ['$MAKE -s --no-print-directory outofmem2'])
60
61 test('T2047', [ignore_output, extra_run_opts('+RTS -c -RTS')],
62               compile_and_run, ['-package containers'])
63
64 # Blackhole-detection test.
65 # Skip GHCi due to #2786
66 test('T2783', [ omit_ways(['ghci']), exit_code(1) ], compile_and_run, [''])
67
68 # Test the work-stealing deque implementation.  We run this test in
69 # both threaded1 (-threaded -debug) and threaded2 (-threaded) ways.
70 test('testwsdeque', [unless(in_tree_compiler(), skip),
71                     req_smp, # needs atomic 'cas'
72                     c_src, only_ways(['threaded1', 'threaded2'])],
73                     compile_and_run, ['-I../../../rts'])
74
75 test('T3236', [c_src, only_ways(['normal','threaded1']), exit_code(1)], compile_and_run, [''])
76
77 test('stack001', extra_run_opts('+RTS -K32m -RTS'), compile_and_run, [''])
78 test('stack002', extra_run_opts('+RTS -K32m -k4m -RTS'), compile_and_run, [''])
79
80 # run this test with very small stack chunks to exercise the stack
81 # overflow/underflow machinery.
82 test('stack003', [ omit_ways('ghci'), # uses unboxed tuples
83                    extra_run_opts('500000 +RTS -kc1k -kb100 -K96m -RTS') ],
84                  compile_and_run, [''])
85
86 test('atomicinc', [ c_src, only_ways(['normal','threaded1', 'threaded2']) ], compile_and_run, [''])
87
88 test('T3424', # it's slow:
89               [ when(fast(), skip), only_ways(['normal','threaded1','ghci']) ],
90               compile_and_run, [''])
91
92 # Test for out-of-range heap size
93 test('rtsflags001', [ only_ways(['normal']), exit_code(1), extra_run_opts('+RTS -H0m -RTS') ], compile_and_run, [''])
94
95 # Crashed with 7.2 and earlier
96 test('rtsflags002', [ only_ways(['normal']) ], compile_and_run, ['-with-rtsopts="-B -B -B"'])
97
98 # Test to see if linker scripts link properly to real ELF files
99 test('T2615',
100      [ when(opsys('mingw32'), skip),
101        # OS X doesn't seem to support linker scripts
102        when(opsys('darwin'), skip),
103        # Solaris' linker does not support GNUish linker scripts
104        when(opsys('solaris2'), skip),
105        pre_cmd('$MAKE -s --no-print-directory T2615-prep'),
106        # Add current directory to dlopen search path
107        cmd_prefix('LD_LIBRARY_PATH=$LD_LIBRARY_PATH:. '),
108        extra_clean(['libfoo_T2615.so', 'libfoo_T2615.o'])],
109      compile_and_run,
110      ['-package ghc'])
111
112 # omit dyn and profiling ways, because we don't build dyn_l or p_l
113 # variants of the RTS by default
114 test('traceEvent', [ omit_ways(['dyn'] + prof_ways), 
115                      extra_run_opts('+RTS -ls -RTS') ], 
116                    compile_and_run, ['-eventlog'])
117
118 test('T4059',
119      extra_clean(['T4059_c.o']),
120      run_command,
121      ['$MAKE -s --no-print-directory T4059'])
122
123 # Test for #4274
124 test('exec_signals', [
125      when(opsys('mingw32'), skip),
126      pre_cmd('$MAKE -s --no-print-directory exec_signals-prep'),
127      cmd_prefix('./exec_signals_prepare'),
128      extra_clean(['exec_signals_child', 'exec_signals_prepare'])
129     ], compile_and_run, [''])
130
131 test('return_mem_to_os', normal, compile_and_run, [''])
132
133 test('T4850', when(opsys('mingw32'), expect_broken(4850)), run_command, ['$MAKE -s --no-print-directory T4850'])
134
135 def config_T5250(name, opts):
136     if not (config.arch in ['i386','x86_64']):
137         opts.skip = 1;
138
139 test('T5250', [ config_T5250,
140                 # stack ptr is not 16-byte aligned on 32-bit Windows
141                 when(platform('i386-unknown-mingw32'), expect_fail),
142                 when(platform('i386-unknown-linux'),
143                             expect_broken_for(4211,['llvm'])),
144                 extra_clean(['spalign.o']),
145                 omit_ways(['ghci']) ],
146               compile_and_run, ['spalign.c'])
147
148 test('T5423',
149      extra_clean(['T5423_cmm.o']),
150      run_command,
151      ['$MAKE -s --no-print-directory T5423'])
152
153 # Workaround bug #8458: old dlopen opens sections in the wrong order,
154 # so we just accept both orders.
155 def checkDynAsm(actual_file, normaliser):
156     actual_raw = read_no_crs(actual_file)
157     actual_str = normaliser(actual_raw)
158     actual = actual_str.split()
159     if actual == ['initArray1', 'initArray2', 'ctors1', 'ctors2', 'success']:
160         return 1
161     elif actual == ['ctors1', 'ctors2', 'initArray1', 'initArray2', 'success']:
162         if_verbose(1, 'T5435_dyn_asm detected old-style dlopen, see #8458')
163         return 1
164     elif opsys('darwin') and actual == ['modInitFunc1', 'modInitFunc2', 'success']:
165         return 1
166     elif opsys('mingw32') and actual == ['ctors1', 'ctors2', 'success']:
167         return 1
168     else:
169         if_verbose(1, 'T5435_dyn_asm failed with %s, see all.T for details' % actual)
170         return 0
171
172 # These should have extra_clean() arguments, but I need
173 # to somehow extract out the name of DLLs to do that
174
175 test('T5435_v_asm', normal, run_command, ['$MAKE -s --no-print-directory T5435_v_asm'])
176 test('T5435_v_gcc', normal, run_command, ['$MAKE -s --no-print-directory T5435_v_gcc'])
177 test('T5435_dyn_asm', check_stdout(checkDynAsm), run_command, ['$MAKE -s --no-print-directory T5435_dyn_asm'])
178 test('T5435_dyn_gcc', normal , run_command, ['$MAKE -s --no-print-directory T5435_dyn_gcc'])
179
180 test('T5993', extra_run_opts('+RTS -k8 -RTS'), compile_and_run, [''])
181
182 test('T6006', [ omit_ways(prof_ways + ['ghci']),
183                  extra_clean(['T6006_c.o']),
184                  pre_cmd('$MAKE -s --no-print-directory T6006_setup') ],
185                  # The T6006_setup hack is to ensure that we generate
186                  # T6006_stub.h before compiling T6006_c.c, which
187                  # needs it.
188                compile_and_run, ['T6006_c.c -no-hs-main'])
189
190 test('T7037',
191      [ extra_clean(['T7037_main.o','T7037_main']) ],
192      run_command,
193      ['$MAKE -s --no-print-directory T7037'])
194
195 test('T7087', exit_code(1), compile_and_run, [''])
196 test('T7160', normal, compile_and_run, [''])
197
198 test('T7040', [ extra_clean(['T7040_c.o']), omit_ways(['ghci']) ],
199      compile_and_run, ['T7040_c.c'])
200
201 test('T7040_ghci', [ only_ways(['ghci']),
202                       pre_cmd('$MAKE -s --no-print-directory T7040_ghci_setup'),
203                       extra_clean(['T7040_ghci_c.o']) ],
204                     compile_and_run, ['T7040_ghci_c.o'])
205
206 test('T7227', [ extra_run_opts('+RTS -tT7227.stat --machine-readable -RTS'),
207                 extra_clean(['T7227.stat']) ]
208             , compile_and_run, [''] )
209
210 test('T7636', [ exit_code(1), extra_run_opts('100000') ], compile_and_run, [''] )
211
212 test('stablename001', expect_fail_for(['hpc']), compile_and_run, [''])
213 # hpc should fail this, because it tags every variable occurrence with
214 # a different tick.  It's probably a bug if it works, hence expect_fail.
215
216 test('T7815', [ multi_cpu_race,
217                 extra_run_opts('50000 +RTS -N2 -RTS'),
218                 req_smp,
219                 only_ways(['threaded1', 'threaded2']) ], compile_and_run, [''] )
220
221 # ignore_output because it contains a unique:
222 #   ffishutdown: Main_dul: interrupted
223 test('ffishutdown', [ ignore_output, only_ways(['threaded1','threaded2']) ], compile_and_run, [''])
224
225 test('T7919', [extra_clean(['T7919A.o','T7919A.hi',
226                             'T7919A.dyn_o','T7919A.dyn_hi']),
227                when(fast(),skip) ],
228              compile_and_run, [config.ghc_th_way_flags])
229
230 test('T8035', normal, compile_and_run, [''])
231
232 test('linker_unload',
233      [ extra_clean(['Test.o','Test.hi', 'linker_unload']) ],
234      run_command,
235      ['$MAKE -s --no-print-directory linker_unload'])
236
237 test('T8209', [ only_ways(threaded_ways), ignore_output ],
238               compile_and_run, [''])
239
240 test('T8242', [ only_ways(threaded_ways), ignore_output ],
241               compile_and_run, [''])
242
243 test('T8124', [ only_ways(threaded_ways), omit_ways(['ghci']),
244                  when(opsys('mingw32'), skip), # uses pthreads
245                  extra_clean(['T8124_c.o']),
246                  pre_cmd('$MAKE -s --no-print-directory T8124_setup') ],
247                  # The T8124_setup hack is to ensure that we generate
248                  # T8124_stub.h before compiling T8124_c.c, which
249                  # needs it.
250                compile_and_run, ['T8124_c.c -no-hs-main'])
251
252 # +RTS -A8k makes it fail faster
253 # The ghci way gets confused by the RTS options
254 test('T9045', [ omit_ways(['ghci']), extra_run_opts('10000 +RTS -A8k -RTS') ], compile_and_run, [''])
255
256 # I couldn't reproduce 9078 with the -threaded runtime, but could easily
257 # with the non-threaded one.
258 test('T9078', [ omit_ways(threaded_ways) ], compile_and_run, ['-with-rtsopts="-DS" -debug'])
259
260 test('T10017', [ when(opsys('mingw32'), skip)
261                , only_ways(threaded_ways), extra_run_opts('+RTS -N2 -RTS') ], compile_and_run, [''])
262
263 test('rdynamic', [ unless(opsys('linux') or opsys('mingw32'), skip)
264                  # this needs runtime infrastructure to do in ghci:
265                  #  '-rdynamic' ghc, load modules only via dlopen(RTLD_BLOBAL) and more.
266                  , omit_ways(['ghci'])
267                  ],
268      compile_and_run, ['-rdynamic -package ghc'])
269
270 test('GcStaticPointers',
271      [ when(compiler_lt('ghc', '7.9'), skip)
272      , when(doing_ghci(), extra_hc_opts('-fobject-code'))
273      ],
274      compile_and_run, [''])
275 test('ListStaticPointers',
276      [ when(compiler_lt('ghc', '7.9'), skip)
277      , when(doing_ghci(), extra_hc_opts('-fobject-code'))
278      ],
279      compile_and_run, [''])
280
281 # 251 = RTS exit code for "out of memory"
282 test('overflow1', [ exit_code(251) ], compile_and_run, [''])
283 test('overflow2', [ exit_code(251) ], compile_and_run, [''])
284 test('overflow3', [ exit_code(251) ], compile_and_run, [''])
285
286 test('linker_error1',
287      [ extra_clean(['linker_error1.o','linker_error1']), ignore_output ],
288      run_command,
289      ['$MAKE -s --no-print-directory linker_error1'])
290
291 test('linker_error2',
292      [ extra_clean(['linker_error2.o','linker_error2_c.o', 'linker_error2']),
293        ignore_output ],
294      run_command,
295      ['$MAKE -s --no-print-directory linker_error2'])
296
297 test('linker_error3',
298      [ extra_clean(['linker_error3.o','linker_error3_c.o', 'linker_error3']),
299        ignore_output ],
300      run_command,
301      ['$MAKE -s --no-print-directory linker_error3'])
302
303 test('T9839_01', [ no_stdin, ignore_output],
304                 run_command,
305                 ['{compiler} -e 1 +RTS -T-s 2>&1 | \
306                   grep "flag -T given an argument when none was expected: -T-s"'])
307
308 test('T9839_02', [ only_ways(prof_ways), ignore_output, exit_code(1), extra_run_opts('+RTS -Pax')],
309                 compile_and_run,
310                 [''])
311
312 test('T9839_03', [ only_ways(prof_ways), ignore_output, exit_code(1), extra_run_opts('+RTS -Px')],
313                 compile_and_run,
314                 [''])
315
316 test('T9839_04', [ only_ways(prof_ways), ignore_output, exit_code(0), extra_run_opts('+RTS -xc')],
317                 compile_and_run,
318                 [''])
319
320 test('T9839_05', [ only_ways(prof_ways), ignore_output, exit_code(1), extra_run_opts('+RTS -xcx')],
321                 compile_and_run,
322                 [''])
323
324 test('T9839_06', [ only_ways(prof_ways), ignore_output, exit_code(1), extra_run_opts('+RTS -xtx')],
325                 compile_and_run,
326                 [''])
327
328 # ignore_output as RTS reports slightly different error messages
329 # in 'epoll' and 'select' backends on reading from EBADF
330 # mingw32 skip as UNIX pipe and close(fd) is used to exercise the problem
331 test('T10590', [ignore_output, when(opsys('mingw32'),skip)], compile_and_run, [''])