04996317f57c65298bb80e818ed48e65842085ed
[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 maybe_skip = normal
51 opts = ''
52 if config.platform.startswith('i386-'):
53     if config.compiler_type == 'ghc' and \
54       version_ge(config.compiler_version, '6.13'):
55         opts = '-msse2'
56     else:
57         maybe_skip = only_ways(['ghci'])
58
59 test('ffi009', [when(fast(), skip),
60                 reqlib('random'),
61                 maybe_skip] ,compile_and_run, [opts])
62
63 test('ffi010', normal, compile_and_run, [''])
64 test('ffi011', normal, compile_and_run, [''])
65
66 # The stdcall calling convention works on Windows, and sometimes on
67 # Linux, and fails everywhhere else.  For now, we test only on Windows,
68 # because it's difficult to discover whether a given Linux supports
69 # it.
70
71 if config.os == 'mingw32':
72     skip_if_not_windows = normal
73 else:
74     skip_if_not_windows = skip
75
76 test('ffi012', skip_if_not_windows, compile_and_run, [''])
77 test('ffi013', normal, compile_and_run, [''])
78
79 # threaded2 sometimes gives ffi014: Main_dDu: interrupted
80 test('ffi014',
81      [only_ways(['threaded1','threaded2']), extra_clean(['ffi014_cbits.o'])],
82      compile_and_run, ['ffi014_cbits.c'])
83
84 # GHCi can't handle the separate C file (ToDo: fix this somehow)
85 test('ffi015', [ omit_ways(['ghci']), extra_clean(['ffi015_cbits.o']) ],
86                compile_and_run, ['ffi015_cbits.c'])
87
88 # GHCi can't handle foreign import "&"
89 test('ffi016', omit_ways(['ghci']), compile_and_run, [''])
90
91 test('ffi017', normal, compile_and_run, [''])
92
93 test('ffi018', [ omit_ways(['ghci']), extra_clean(['ffi018_c.o']) ],
94                compile_and_run, ['ffi018_c.c'])
95
96 test('ffi018_ghci', [ only_ways(['ghci']),
97                       pre_cmd('$MAKE -s --no-print-directory ffi018_ghci_setup'),
98                       extra_clean(['ffi018_ghci_c.o']) ],
99                     compile_and_run, ['ffi018_ghci_c.o'])
100
101 test('ffi019', normal, compile_and_run, [''])
102
103 # This one originally failed only GHCi, but doesn't hurt to test all ways.
104 test('T1679', normal, compile_and_run, [''])
105
106 test('T1288', [ omit_ways(['ghci']),
107                 extra_clean(['T1288_c.o']) ],
108               compile_and_run, ['T1288_c.c'])
109 test('T1288_ghci', [ only_ways(['ghci']),
110                      pre_cmd('$MAKE -s --no-print-directory T1288_ghci_setup'),
111                      extra_clean(['T1288_ghci_c.o']) ],
112                    compile_and_run, ['T1288_ghci_c.o'])
113
114 test('T2276', [ omit_ways(['ghci']), 
115                 extra_clean(['T2276_c.o']) ],
116               compile_and_run, ['T2276_c.c'])
117 test('T2276_ghci', [ only_ways(['ghci']),
118                      pre_cmd('$MAKE -s --no-print-directory T2276_ghci_setup'),
119                      extra_clean(['T2276_ghci_c.o']) ],
120                    compile_and_run, ['-fobject-code T2276_ghci_c.o'])
121
122 test('T2469', normal, compile_and_run, ['-optc-std=gnu99'])
123
124 test('T2594',
125      [extra_clean(['T2594_c.o']), omit_ways(['ghci'])],
126      compile_and_run,
127      ['T2594_c.c'])
128
129 test('fptr01', [ omit_ways(['ghci']), extra_clean(['fptr01_c.o']) ],
130                compile_and_run, ['fptr01_c.c'])
131 test('fptr02', normal, compile_and_run, [''])
132
133 test('fptrfail01', [ omit_ways(['ghci']), exit_code(1),
134                      extra_clean(['fptrfail01_c.o']) ],
135                    compile_and_run, ['fptrfail01_c.c'])
136
137 test('T2917a', normal, compile_and_run, [''])
138
139 # omit prof ways, because this test causes the RTS to exit (correctly)
140 # without generating profiling information.
141 test('ffi020', [ omit_ways(prof_ways),
142                  exit_code(1) ], compile_and_run, [''])
143
144
145 test('ffi021', normal, compile_and_run, [''])
146
147 test('ffi022', normal, compile_and_run, [''])
148
149 if config.os == 'mingw32':
150     # This test needs a larger C stack than we get by default on Windows
151         flagsForT4038 = ['-optl-Wl,--stack,10485760']
152 else:
153         flagsForT4038 = ['']
154 test('T4038', normal, compile_and_run, flagsForT4038)
155
156 test('T4221', [ omit_ways(['ghci']), extra_clean(['T4221_c.o']) ],
157                 compile_and_run, ['T4221_c.c'])
158
159 test('T5402', [ omit_ways(['ghci']),
160                 exit_code(42),
161                 extra_clean(['T5402_main.o']),
162                   # The T5402_setup hack is to ensure that we generate
163                   # T5402_stub.h before compiling T5402_main.c, which
164                   # needs it.
165                 pre_cmd('$MAKE -s --no-print-directory T5402_setup') ],
166               compile_and_run, ["-no-hs-main T5402_main.c"])
167
168 test('T5594', [ omit_ways(['ghci']),
169                 extra_clean(['T5594_c.o']),
170                 pre_cmd('$MAKE -s --no-print-directory T5594_setup') ],
171                 # The T5594_setup hack is to ensure that we generate
172                 # T5594_stub.h before compiling T5594_c.c, which
173                 # needs it.
174                 compile_and_run, ['T5594_c.c -no-hs-main'])
175
176 test('Capi_Ctype_001',
177      extra_clean(['Capi_Ctype_A_001.o', 'Capi_Ctype_A_001.hi',
178                   'capi_ctype_001_c.o',
179                   'Capi_Ctype_A_001.hs', 'Capi_Ctype_001.hs']),
180      run_command,
181      ['$MAKE -s --no-print-directory Capi_Ctype_001'])
182
183 test('Capi_Ctype_002',
184      extra_clean(['Capi_Ctype_A_002.o', 'Capi_Ctype_A_002.hi',
185                   'Capi_Ctype_A_002.hs']),
186      run_command,
187      ['$MAKE -s --no-print-directory Capi_Ctype_002'])
188
189 test('ffi_parsing_001',
190      [omit_ways(['ghci']), extra_clean(['ffi_parsing_001_c.o'])],
191      compile_and_run,
192      ['ffi_parsing_001_c.c'])
193
194 test('capi_value',
195      [omit_ways(['ghci']), extra_clean(['capi_value_c.o'])],
196      compile_and_run,
197      ['capi_value_c.c'])
198
199 test('T7170', exit_code(1), compile_and_run, [''])
200
201 test('T4012',
202      [extra_clean(['T4012_A.hi', 'T4012_A.o', 'T4012_B.hi', 'T4012_B.o']),
203       expect_broken_for(7388, ['ghci'])],
204      multimod_compile_and_run,
205      ['T4012', ''])
206
207 test('T8083',
208      [omit_ways(['ghci']), extra_clean(['T8083_c.o'])],
209      compile_and_run,
210      ['T8083_c.c'])
211
212 test('ffi023', [ omit_ways(['ghci']),
213                 extra_clean(['ffi023_c.o']),
214                 extra_run_opts('1000 4') ],
215               compile_and_run, ['ffi023_c.c'])