all.T 7.85 KB
Newer Older
1

2 3 4 5
# Args to compile_and_run are:
#	extra compile flags
#	extra run flags
#	expected process return value, if not zero
6

krc's avatar
krc committed
7
# Doesn't work with External Core due to __labels
ross's avatar
ross committed
8 9 10
test('fed001', compose(only_compiler_types(['ghc']),
			expect_fail_for(['extcore','optextcore'])),
		compile_and_run, [''])
11

12 13
# Omit GHCi for these two, as they use foreign export
test('ffi001', omit_ways(['ghci']), compile_and_run, [''])
14 15
test('ffi002', [ omit_ways(['ghci']),
                 extra_clean(['ffi002_c.o']),
Ian Lynagh's avatar
Ian Lynagh committed
16
                 compile_cmd_prefix('$MAKE ffi002_setup && ') ],
17 18 19
                 # The ffi002_setup hack is to ensure that we generate
                 # ffi002_stub.h before compiling ffi002_c.c, which
                 # needs it.
20
               compile_and_run, ['ffi002_c.c -no-hs-main'])
21

22
test('ffi003', normal, compile_and_run, [''])
23

24 25 26
# ffi004 calls printf, which is not supported (the FFI spec says that
# calling varargs functions is deprecated).  It stopped working in GHC 6.9.
test('ffi004', skip, compile_and_run, [''])
27

Simon Marlow's avatar
Simon Marlow committed
28 29
# omit prof ways, because this test exits before the RTS has a chance to
# generate profiling info.
30 31 32 33 34
#
# On x86, the test suffers from floating-point differences due to the
# use of 80-bit internal precision when using the native code generator.
#
test('ffi005', [ omit_ways(prof_ways), 
35
                 if_arch('i386', skip),
Ian Lynagh's avatar
Ian Lynagh committed
36
                 if_platform('i386-apple-darwin', expect_broken(4105)),
37
                 exit_code(3) ],
Simon Marlow's avatar
Simon Marlow committed
38
               compile_and_run, [''])
39

krc's avatar
krc committed
40 41
# ffi[006-009] don't work with External Core due to non-static-C foreign calls

42
test('ffi006', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

# Skip ffi00{7,8} for GHCi.  These tests both try to exit or raise an
# error from a foreign export, which shuts down the runtime.  When
# GHCi is running, this results in GHCi's main thread also trying to
# shut down, and a race ensues to see who gets to call exit() first.
# Sometimes we end up with the wrong exit code, or get an extra
# 'interrupted' message from the GHCi thread shutting down.

test('ffi007', compose( omit_ways(['ghci']),
		        expect_fail_for(['extcore','optextcore']) ), 
	       compile_and_run, [''])

test('ffi008', compose(expect_fail_for(['extcore','optextcore']), 
		       compose(exit_code(1),
			       omit_ways(['ghci']))), 
	       compile_and_run, [''])
59

60 61 62 63 64 65 66 67
# On i386, we need -msse2 to get reliable floating point results
maybe_skip = normal
opts = ''
if config.platform.startswith('i386-'):
   if config.compiler_type == 'ghc' and \
      version_ge(config.compiler_version, '6.13'):
	opts = '-msse2'
   else:
68
        maybe_skip = only_ways(['ghci'])
69 70

test('ffi009', [skip_if_fast, expect_fail_for(['extcore','optextcore']),
Simon Marlow's avatar
Simon Marlow committed
71
                reqlib('random'),
72
                maybe_skip] ,compile_and_run, [opts])
73

krc's avatar
krc committed
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 80 81 82
# The stdcall calling convention works on Windows, and sometimes on
# Linux, and fails everywhhere else.  For now, we test only on Windows,
# because it's difficult to discover whether a given Linux supports
# it.
83

Ian Lynagh's avatar
Ian Lynagh committed
84
if config.os == 'mingw32':
Simon Marlow's avatar
Simon Marlow committed
85
	skip_if_not_windows = normal
86
else:
Simon Marlow's avatar
Simon Marlow committed
87
	skip_if_not_windows = skip
88

Simon Marlow's avatar
Simon Marlow committed
89
test('ffi012', skip_if_not_windows, compile_and_run, [''])
ross's avatar
ross committed
90 91 92

# Doesn't work with External Core due to __labels
test('ffi013', expect_fail_for(['extcore','optextcore']), compile_and_run, [''])
93

Simon Marlow's avatar
Simon Marlow committed
94
# threaded2 sometimes gives ffi014: Main_dDu: interrupted
95 96 97
test('ffi014',
     [only_ways(['threaded1','threaded2']), extra_clean(['ffi014_cbits.o'])],
     compile_and_run, ['ffi014_cbits.c'])
98

99
# GHCi can't handle the separate C file (ToDo: fix this somehow)
100 101
test('ffi015', [ omit_ways(['ghci']), extra_clean(['ffi015_cbits.o']) ],
               compile_and_run, ['ffi015_cbits.c'])
Simon Marlow's avatar
Simon Marlow committed
102

Simon Marlow's avatar
Simon Marlow committed
103
# GHCi can't handle foreign import "&"
ei@vuokko.info's avatar
ei@vuokko.info committed
104
test('ffi016', omit_ways(['ghci']), compile_and_run, [''])
105 106

test('ffi017', normal, compile_and_run, [''])
Ian Lynagh's avatar
Ian Lynagh committed
107

108 109 110
test('ffi018', [ omit_ways(['ghci']), extra_clean(['ffi018_c.o']) ],
               compile_and_run, ['ffi018_c.c'])

111 112 113 114
test('ffi018_ghci', [ only_ways(['ghci']),
                      cmd_prefix('$MAKE ffi018_ghci_setup && '),
                      extra_clean(['ffi018_ghci_c.o']) ],
                    compile_and_run, ['ffi018_ghci_c.o'])
115

Simon Marlow's avatar
Simon Marlow committed
116
test('ffi019', normal, compile_and_run, [''])
Simon Marlow's avatar
Simon Marlow committed
117 118 119

# This one originally failed only GHCi, but doesn't hurt to test all ways.
test('1679', normal, compile_and_run, [''])
Simon Marlow's avatar
Simon Marlow committed
120

121
test('1288', [ omit_ways(['ghci']),
Simon Marlow's avatar
Simon Marlow committed
122 123
               extra_clean(['1288_c.o']) ],
             compile_and_run, ['1288_c.c'])
124
test('1288_ghci', [ only_ways(['ghci']),
125 126 127
                    cmd_prefix('$MAKE --no-print-directory 1288_ghci_setup && '),
                    extra_clean(['1288_ghci_c.o']) ],
                  compile_and_run, ['1288_ghci_c.o'])
Simon Marlow's avatar
Simon Marlow committed
128

129
test('2276', [ omit_ways(['ghci']), 
Simon Marlow's avatar
Simon Marlow committed
130 131
               extra_clean(['2276_c.o']) ],
             compile_and_run, ['2276_c.c'])
132
test('2276_ghci', [ only_ways(['ghci']),
133 134 135
                    cmd_prefix('$MAKE --no-print-directory 2276_ghci_setup && '),
                    extra_clean(['2276_ghci_c.o']) ],
                  compile_and_run, ['-fobject-code 2276_ghci_c.o'])
Simon Marlow's avatar
Simon Marlow committed
136 137

test('2469', normal, compile_and_run, ['-optc-std=gnu99'])
Simon Marlow's avatar
Simon Marlow committed
138

139 140 141 142
test('2594',
     [extra_clean(['2594_c.o']), omit_ways(['ghci'])],
     compile_and_run,
     ['2594_c.c'])
143 144 145

test('fptr01', [ omit_ways(['ghci']), extra_clean(['fptr01_c.o']) ],
               compile_and_run, ['fptr01_c.c'])
146
test('fptr02', normal, compile_and_run, [''])
147 148 149 150

test('fptrfail01', [ compose(omit_ways(['ghci']), exit_code(1)),
                     extra_clean(['fptrfail01_c.o']) ],
                   compile_and_run, ['fptrfail01_c.c'])
Simon Marlow's avatar
Simon Marlow committed
151 152 153

test('2917a', normal, compile_and_run, [''])

Simon Marlow's avatar
Simon Marlow committed
154 155
# omit prof ways, because this test causes the RTS to exit (correctly)
# without generating profiling information.
Simon Marlow's avatar
Simon Marlow committed
156
test('ffi020', [ omit_ways(prof_ways),
Simon Marlow's avatar
Simon Marlow committed
157
                 exit_code(1) ], compile_and_run, [''])
158

159 160

test('ffi021', normal, compile_and_run, [''])
Simon Marlow's avatar
Simon Marlow committed
161

Edward Z. Yang's avatar
Edward Z. Yang committed
162 163
test('ffi022', normal, compile_and_run, [''])

Ian Lynagh's avatar
Ian Lynagh committed
164
if config.os == 'mingw32':
165 166 167 168 169 170
    # This test needs a larger C stack than we get by default on Windows
	flagsFor4038 = ['-optl-Wl,--stack,10485760']
else:
	flagsFor4038 = ['']
test('4038', normal, compile_and_run, flagsFor4038)

171 172 173
test('4221', [ omit_ways(['ghci']), extra_clean(['4221_c.o']) ],
               compile_and_run, ['4221_c.c'])

Simon Marlow's avatar
Simon Marlow committed
174 175 176 177 178 179 180 181 182
test('5402', [ omit_ways(['ghci']),
               exit_code(42),
               extra_clean(['5402_main.o']),
                 # The 5402_setup hack is to ensure that we generate
                 # 5402_stub.h before compiling 5402_main.c, which
                 # needs it.
               compile_cmd_prefix('$MAKE --no-print-directory 5402_setup && ') ],
             compile_and_run, ["-no-hs-main 5402_main.c"])

Simon Marlow's avatar
Simon Marlow committed
183 184 185 186 187 188 189
test('5594', [ omit_ways(['ghci']),
               extra_clean(['5594_c.o']),
               compile_cmd_prefix('$MAKE --no-print-directory 5594_setup && ') ],
               # The 5594_setup hack is to ensure that we generate
               # 5594_stub.h before compiling 5594_c.c, which
               # needs it.
               compile_and_run, ['5594_c.c -no-hs-main'])
190 191 192

test('Capi_Ctype_001',
     extra_clean(['Capi_Ctype_A_001.o', 'Capi_Ctype_A_001.hi',
193
                  'capi_ctype_001_c.o',
194 195 196 197
                  'Capi_Ctype_A_001.hs', 'Capi_Ctype_001.hs']),
     run_command,
     ['$MAKE -s --no-print-directory Capi_Ctype_001'])

Ian Lynagh's avatar
Ian Lynagh committed
198 199 200 201 202 203
test('Capi_Ctype_002',
     extra_clean(['Capi_Ctype_A_002.o', 'Capi_Ctype_A_002.hi',
                  'Capi_Ctype_A_002.hs']),
     run_command,
     ['$MAKE -s --no-print-directory Capi_Ctype_002'])

Ian Lynagh's avatar
Ian Lynagh committed
204
test('ffi_parsing_001',
205
     [omit_ways(['ghci']), extra_clean(['ffi_parsing_001_c.o'])],
Ian Lynagh's avatar
Ian Lynagh committed
206 207 208
     compile_and_run,
     ['ffi_parsing_001_c.c'])

Ian Lynagh's avatar
Ian Lynagh committed
209
test('capi_value',
210
     [omit_ways(['ghci']), extra_clean(['capi_value_c.o'])],
Ian Lynagh's avatar
Ian Lynagh committed
211 212 213
     compile_and_run,
     ['capi_value_c.c'])

Simon Marlow's avatar
Simon Marlow committed
214
test('7170', exit_code(1), compile_and_run, [''])