4e7417395ded77d385a3fd4ae5b20338c8a8a346
[ghc.git] / testsuite / tests / ffi / should_run / all.T
1
2 # Args to compile_and_run are:
3 #       extra compile flags
4 #       extra run flags
5 #       expected process return value, if not zero
6
7 test('fed001', normal, compile_and_run, [''])
8
9 # Omit GHCi for these two, as they use foreign export
10 test('ffi001', omit_ways(['ghci']), compile_and_run, [''])
11 test('ffi002', [ omit_ways(['ghci']),
12                  extra_clean(['ffi002_c.o']),
13                  pre_cmd('$MAKE -s --no-print-directory ffi002_setup') ],
14                  # The ffi002_setup hack is to ensure that we generate
15                  # ffi002_stub.h before compiling ffi002_c.c, which
16                  # needs it.
17                compile_and_run, ['ffi002_c.c -no-hs-main'])
18
19 test('ffi003', normal, compile_and_run, [''])
20
21 # ffi004 calls printf, which is not supported (the FFI spec says that
22 # calling varargs functions is deprecated).  It stopped working in GHC 6.9.
23 test('ffi004', skip, compile_and_run, [''])
24
25 # omit prof ways, because this test exits before the RTS has a chance to
26 # generate profiling info.
27 #
28 # On x86, the test suffers from floating-point differences due to the
29 # use of 80-bit internal precision when using the native code generator.
30 #
31 test('ffi005', [ omit_ways(prof_ways), 
32                  when(arch('i386'), skip),
33                  when(platform('i386-apple-darwin'), expect_broken(4105)),
34                  exit_code(3) ],
35                compile_and_run, [''])
36
37 test('ffi006', normal, compile_and_run, [''])
38
39 # Skip ffi00{7,8} for GHCi.  These tests both try to exit or raise an
40 # error from a foreign export, which shuts down the runtime.  When
41 # GHCi is running, this results in GHCi's main thread also trying to
42 # shut down, and a race ensues to see who gets to call exit() first.
43 # Sometimes we end up with the wrong exit code, or get an extra
44 # 'interrupted' message from the GHCi thread shutting down.
45
46 test('ffi007', omit_ways(['ghci']), compile_and_run, [''])
47 test('ffi008', [exit_code(1), omit_ways(['ghci'])], compile_and_run, [''])
48
49 # On i386, we need -msse2 to get reliable floating point results
50 if config.platform.startswith('i386-'):
51     opts = '-msse2'
52 else:
53     opts = ''
54
55 test('ffi009', [when(fast(), skip), reqlib('random')], compile_and_run, [opts])
56
57 test('ffi010', normal, compile_and_run, [''])
58 test('ffi011', normal, compile_and_run, [''])
59
60 # The stdcall calling convention works on Windows, and sometimes on
61 # Linux, and fails everywhhere else.  For now, we test only on Windows,
62 # because it's difficult to discover whether a given Linux supports
63 # it.
64
65 if config.os == 'mingw32':
66     skip_if_not_windows = normal
67 else:
68     skip_if_not_windows = skip
69
70 test('ffi012', skip_if_not_windows, compile_and_run, [''])
71 test('ffi013', normal, compile_and_run, [''])
72
73 # threaded2 sometimes gives ffi014: Main_dDu: interrupted
74 test('ffi014',
75      [only_ways(['threaded1','threaded2']), extra_clean(['ffi014_cbits.o'])],
76      compile_and_run, ['ffi014_cbits.c'])
77
78 # GHCi can't handle the separate C file (ToDo: fix this somehow)
79 test('ffi015', [ omit_ways(['ghci']), extra_clean(['ffi015_cbits.o']) ],
80                compile_and_run, ['ffi015_cbits.c'])
81
82 # GHCi can't handle foreign import "&"
83 test('ffi016', omit_ways(['ghci']), compile_and_run, [''])
84
85 test('ffi017', normal, compile_and_run, [''])
86
87 test('ffi018', [ omit_ways(['ghci']), extra_clean(['ffi018_c.o']) ],
88                compile_and_run, ['ffi018_c.c'])
89
90 test('ffi018_ghci', [ only_ways(['ghci']),
91                       pre_cmd('$MAKE -s --no-print-directory ffi018_ghci_setup'),
92                       extra_clean(['ffi018_ghci_c.o']) ],
93                     compile_and_run, ['ffi018_ghci_c.o'])
94
95 test('ffi019', normal, compile_and_run, [''])
96
97 # This one originally failed only GHCi, but doesn't hurt to test all ways.
98 test('T1679', normal, compile_and_run, [''])
99
100 test('T1288', [ omit_ways(['ghci']),
101                 extra_clean(['T1288_c.o']) ],
102               compile_and_run, ['T1288_c.c'])
103 test('T1288_ghci', [ only_ways(['ghci']),
104                      pre_cmd('$MAKE -s --no-print-directory T1288_ghci_setup'),
105                      extra_clean(['T1288_ghci_c.o']) ],
106                    compile_and_run, ['T1288_ghci_c.o'])
107
108 test('T2276', [ omit_ways(['ghci']), 
109                 extra_clean(['T2276_c.o']) ],
110               compile_and_run, ['T2276_c.c'])
111 test('T2276_ghci', [ only_ways(['ghci']),
112                      when(opsys('darwin'), skip), # stdcall not supported on OS X
113                      pre_cmd('$MAKE -s --no-print-directory T2276_ghci_setup'),
114                      extra_clean(['T2276_ghci_c.o']) ],
115                    compile_and_run, ['-fobject-code T2276_ghci_c.o'])
116
117 test('T2469', normal, compile_and_run, ['-optc-std=gnu99'])
118
119 test('T2594',
120      [extra_clean(['T2594_c.o']), omit_ways(['ghci'])],
121      compile_and_run,
122      ['T2594_c.c'])
123
124 test('fptr01', [ omit_ways(['ghci']), extra_clean(['fptr01_c.o']) ],
125                compile_and_run, ['fptr01_c.c'])
126 test('fptr02', normal, compile_and_run, [''])
127
128 test('fptrfail01', [ omit_ways(['ghci']), exit_code(1),
129                      extra_clean(['fptrfail01_c.o']) ],
130                    compile_and_run, ['fptrfail01_c.c'])
131
132 test('T2917a', normal, compile_and_run, [''])
133
134 # omit prof ways, because this test causes the RTS to exit (correctly)
135 # without generating profiling information.
136 test('ffi020', [ omit_ways(prof_ways),
137                  exit_code(1) ], compile_and_run, [''])
138
139
140 test('ffi021', normal, compile_and_run, [''])
141
142 test('ffi022', normal, compile_and_run, [''])
143
144 if config.os == 'mingw32':
145     # This test needs a larger C stack than we get by default on Windows
146         flagsForT4038 = ['-optl-Wl,--stack,10485760']
147 else:
148         flagsForT4038 = ['']
149 test('T4038', normal, compile_and_run, flagsForT4038)
150
151 test('T4221', [ omit_ways(['ghci']), extra_clean(['T4221_c.o']) ],
152                 compile_and_run, ['T4221_c.c'])
153
154 test('T5402', [ omit_ways(['ghci']),
155                 exit_code(42),
156                 extra_clean(['T5402_main.o']),
157                   # The T5402_setup hack is to ensure that we generate
158                   # T5402_stub.h before compiling T5402_main.c, which
159                   # needs it.
160                 pre_cmd('$MAKE -s --no-print-directory T5402_setup') ],
161               compile_and_run, ["-no-hs-main T5402_main.c"])
162
163 test('T5594', [ omit_ways(['ghci']),
164                 extra_clean(['T5594_c.o']),
165                 pre_cmd('$MAKE -s --no-print-directory T5594_setup') ],
166                 # The T5594_setup hack is to ensure that we generate
167                 # T5594_stub.h before compiling T5594_c.c, which
168                 # needs it.
169                 compile_and_run, ['T5594_c.c -no-hs-main'])
170
171 test('Capi_Ctype_001',
172      extra_clean(['Capi_Ctype_A_001.o', 'Capi_Ctype_A_001.hi',
173                   'capi_ctype_001_c.o',
174                   'Capi_Ctype_A_001.hs', 'Capi_Ctype_001.hs']),
175      run_command,
176      ['$MAKE -s --no-print-directory Capi_Ctype_001'])
177
178 test('Capi_Ctype_002',
179      extra_clean(['Capi_Ctype_A_002.o', 'Capi_Ctype_A_002.hi',
180                   'Capi_Ctype_A_002.hs']),
181      run_command,
182      ['$MAKE -s --no-print-directory Capi_Ctype_002'])
183
184 test('ffi_parsing_001',
185      [omit_ways(['ghci']), extra_clean(['ffi_parsing_001_c.o'])],
186      compile_and_run,
187      ['ffi_parsing_001_c.c'])
188
189 test('capi_value',
190      [omit_ways(['ghci']), extra_clean(['capi_value_c.o'])],
191      compile_and_run,
192      ['capi_value_c.c'])
193
194 test('T7170', exit_code(1), compile_and_run, [''])
195
196 test('T4012',
197      [extra_clean(['T4012_A.hi', 'T4012_A.o', 'T4012_B.hi', 'T4012_B.o']),
198       expect_broken_for(7388, ['ghci'])],
199      multimod_compile_and_run,
200      ['T4012', ''])
201
202 test('T8083',
203      [omit_ways(['ghci']), extra_clean(['T8083_c.o'])],
204      compile_and_run,
205      ['T8083_c.c'])
206
207 test('ffi023', [ omit_ways(['ghci']),
208                 extra_clean(['ffi023_c.o']),
209                 extra_run_opts('1000 4'),
210                 pre_cmd('$MAKE -s --no-print-directory ffi023_setup') ],
211                 # The ffi023_setup hack is to ensure that we generate
212                 # ffi023_stub.h before compiling ffi023_c.c, which
213                 # needs it.
214               compile_and_run, ['ffi023_c.c'])
215
216 test('T12134',
217      [omit_ways(['ghci']), extra_clean(['T12134_c.o'])],
218      compile_and_run,
219      ['T12134_c.c'])
220
221 test('T12614',
222      [omit_ways(['ghci']), extra_clean(['T12614_c.o'])],
223      compile_and_run,
224      ['T12614_c.c'])
225