d6fdc8cde4aa59295887fc2f659ecf0b412db552
[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 # Doesn't work with External Core due to __labels
8 test('fed001', compose(only_compiler_types(['ghc']),
9                         expect_fail_for(['extcore','optextcore'])),
10                 compile_and_run, [''])
11
12 # Omit GHCi for these two, as they use foreign export
13 test('ffi001', omit_ways(['ghci']), compile_and_run, [''])
14 test('ffi002', [ omit_ways(['ghci']),
15                  extra_clean(['ffi002_c.o']),
16                  compile_cmd_prefix('$MAKE ffi002_setup && ') ],
17                  # The ffi002_setup hack is to ensure that we generate
18                  # ffi002_stub.h before compiling ffi002_c.c, which
19                  # needs it.
20                compile_and_run, ['ffi002_c.c -no-hs-main'])
21
22 test('ffi003', normal, compile_and_run, [''])
23
24 # ffi004 calls printf, which is not supported (the FFI spec says that
25 # calling varargs functions is deprecated).  It stopped working in GHC 6.9.
26 test('ffi004', skip, compile_and_run, [''])
27
28 # omit prof ways, because this test exits before the RTS has a chance to
29 # generate profiling info.
30 #
31 # On x86, the test suffers from floating-point differences due to the
32 # use of 80-bit internal precision when using the native code generator.
33 #
34 test('ffi005', [ omit_ways(prof_ways), 
35                  if_arch('i386', skip),
36                  if_platform('i386-apple-darwin', expect_broken(4105)),
37                  exit_code(3) ],
38                compile_and_run, [''])
39
40 # ffi[006-009] don't work with External Core due to non-static-C foreign calls
41
42 test('ffi006', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
43
44 # Skip ffi00{7,8} for GHCi.  These tests both try to exit or raise an
45 # error from a foreign export, which shuts down the runtime.  When
46 # GHCi is running, this results in GHCi's main thread also trying to
47 # shut down, and a race ensues to see who gets to call exit() first.
48 # Sometimes we end up with the wrong exit code, or get an extra
49 # 'interrupted' message from the GHCi thread shutting down.
50
51 test('ffi007', compose( omit_ways(['ghci']),
52                         expect_fail_for(['extcore','optextcore']) ), 
53                compile_and_run, [''])
54
55 test('ffi008', compose(expect_fail_for(['extcore','optextcore']), 
56                        compose(exit_code(1),
57                                omit_ways(['ghci']))), 
58                compile_and_run, [''])
59
60 # On i386, we need -msse2 to get reliable floating point results
61 maybe_skip = normal
62 opts = ''
63 if config.platform.startswith('i386-'):
64    if config.compiler_type == 'ghc' and \
65       version_ge(config.compiler_version, '6.13'):
66         opts = '-msse2'
67    else:
68         maybe_skip = only_ways(['ghci'])
69
70 test('ffi009', [skip_if_fast, expect_fail_for(['extcore','optextcore']),
71                 reqlib('random'),
72                 maybe_skip] ,compile_and_run, [opts])
73
74 # Doesn't work with External Core due to __labels
75 test('ffi010', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
76
77 test('ffi011', normal, compile_and_run, [''])
78
79 # The stdcall calling convention works on Windows, and sometimes on
80 # Linux, and fails everywhhere else.  For now, we test only on Windows,
81 # because it's difficult to discover whether a given Linux supports
82 # it.
83
84 if config.platform == 'i386-unknown-mingw32':
85         skip_if_not_windows = normal
86 else:
87         skip_if_not_windows = skip
88
89 test('ffi012', skip_if_not_windows, compile_and_run, [''])
90
91 # Doesn't work with External Core due to __labels
92 test('ffi013', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
93
94 # threaded2 sometimes gives ffi014: Main_dDu: interrupted
95 test('ffi014', only_ways(['threaded1','threaded2']), compile_and_run, ['ffi014_cbits.c'])
96
97 # GHCi can't handle the separate C file (ToDo: fix this somehow)
98 test('ffi015', [ omit_ways(['ghci']), extra_clean(['ffi015_cbits.o']) ],
99                compile_and_run, ['ffi015_cbits.c'])
100
101 # GHCi can't handle foreign import "&"
102 test('ffi016', omit_ways(['ghci']), compile_and_run, [''])
103
104 test('ffi017', normal, compile_and_run, [''])
105
106 test('ffi018', [ omit_ways(['ghci']), extra_clean(['ffi018_c.o']) ],
107                compile_and_run, ['ffi018_c.c'])
108
109 test('ffi018_ghci', [ only_ways(['ghci']),
110                       cmd_prefix('$MAKE ffi018_ghci_setup && '),
111                       extra_clean(['ffi018_ghci_c.o']) ],
112                     compile_and_run, ['ffi018_ghci_c.o'])
113
114 test('ffi019', normal, compile_and_run, [''])
115
116 # This one originally failed only GHCi, but doesn't hurt to test all ways.
117 test('1679', normal, compile_and_run, [''])
118
119 test('1288', [ omit_ways(['ghci']),
120                extra_clean(['1288_c.o']) ],
121              compile_and_run, ['1288_c.c'])
122 test('1288_ghci', [ only_ways(['ghci']),
123                     cmd_prefix('$MAKE --no-print-directory 1288_ghci_setup && '),
124                     extra_clean(['1288_ghci_c.o']) ],
125                   compile_and_run, ['1288_ghci_c.o'])
126
127 test('2276', [ omit_ways(['ghci']), 
128                extra_clean(['2276_c.o']) ],
129              compile_and_run, ['2276_c.c'])
130 test('2276_ghci', [ only_ways(['ghci']),
131                     cmd_prefix('$MAKE --no-print-directory 2276_ghci_setup && '),
132                     extra_clean(['2276_ghci_c.o']) ],
133                   compile_and_run, ['-fobject-code 2276_ghci_c.o'])
134
135 test('2469', normal, compile_and_run, ['-optc-std=gnu99'])
136
137 test('2594', omit_ways(['ghci']), compile_and_run, ['2594_c.c'])
138
139 test('fptr01', [ omit_ways(['ghci']), extra_clean(['fptr01_c.o']) ],
140                compile_and_run, ['fptr01_c.c'])
141 test('fptr02', normal, compile_and_run, [''])
142
143 test('fptrfail01', [ compose(omit_ways(['ghci']), exit_code(1)),
144                      extra_clean(['fptrfail01_c.o']) ],
145                    compile_and_run, ['fptrfail01_c.c'])
146
147 test('2917a', normal, compile_and_run, [''])
148
149 # omit prof ways, because this test causes the RTS to exit (correctly)
150 # without generating profiling information.
151 test('ffi020', [ omit_ways(prof_ways),
152                  exit_code(1) ], compile_and_run, [''])
153
154
155 test('ffi021', normal, compile_and_run, [''])
156
157 test('ffi022', normal, compile_and_run, [''])
158
159 if config.platform == 'i386-unknown-mingw32':
160     # This test needs a larger C stack than we get by default on Windows
161         flagsFor4038 = ['-optl-Wl,--stack,10485760']
162 else:
163         flagsFor4038 = ['']
164 test('4038', normal, compile_and_run, flagsFor4038)
165
166 test('4221', [ omit_ways(['ghci']), extra_clean(['4221_c.o']) ],
167                compile_and_run, ['4221_c.c'])
168
169 test('5402', [ omit_ways(['ghci']),
170                exit_code(42),
171                extra_clean(['5402_main.o']),
172                  # The 5402_setup hack is to ensure that we generate
173                  # 5402_stub.h before compiling 5402_main.c, which
174                  # needs it.
175                compile_cmd_prefix('$MAKE --no-print-directory 5402_setup && ') ],
176              compile_and_run, ["-no-hs-main 5402_main.c"])
177