Add a test case for bug #79125
[mono.git] / mono / tests / Makefile.am
1 SUBDIRS = cas
2
3 check-local: test
4
5 TEST_PROG = ../interpreter/mint
6 JITTEST_PROG = ../mini/mono
7
8 TEST_PROG_RUN = MONO_SHARED_DIR=$(mono_build_root)/runtime $(LIBTOOL) --mode=execute $(TEST_PROG)
9 JITTEST_PROG_RUN = MONO_SHARED_DIR=$(mono_build_root)/runtime $(LIBTOOL) --mode=execute $(JITTEST_PROG)
10
11 RUNTIME_ARGS=--config tests-config --optimize=all
12
13 with_mono_path = MONO_PATH=$(mcs_topdir)/class/lib/default
14 with_mono_path2 = MONO_PATH=$(mcs_topdir)/class/lib/net_2_0
15
16 RUNTIME = $(with_mono_path) $(top_builddir)/runtime/mono-wrapper
17 RUNTIME2 = $(with_mono_path2) $(top_builddir)/runtime/mono-wrapper
18
19 MKBUNDLE = \
20         PKG_CONFIG_PATH=$(top_builddir):$(PKG_CONFIG_PATH) \
21         $(RUNTIME) $(mcs_topdir)/tools/mkbundle/mkbundle.exe
22
23 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/default/mcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219
24 GMCS = $(RUNTIME2) $(mcs_topdir)/class/lib/net_2_0/gmcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219
25 ILASM = $(RUNTIME) $(mcs_topdir)/class/lib/default/ilasm.exe
26 ILASM2 = $(RUNTIME2) $(mcs_topdir)/class/lib/net_2_0/ilasm.exe
27
28 BENCHSRC=fib.cs random.cs nested-loops.cs ackermann.cs tight-loop.cs sieve.cs
29
30 STRESS_TESTS_SRC=       \
31         abort-stress-1.cs       \
32         abort-stress-2.cs       \
33         abort-stress-3.cs       \
34         domain-stress.cs        \
35         gchandle-stress.cs      \
36         monitor-stress.cs       \
37         thread-stress.cs        \
38         gc-stress.cs
39
40 TEST_CS_SRC=                    \
41         array-init.cs           \
42         arraylist.cs            \
43         checked.cs              \
44         char-isnumber.cs        \
45         create-instance.cs      \
46         field-layout.cs         \
47         pack-layout.cs          \
48         hash-table.cs           \
49         test-ops.cs             \
50         obj.cs                  \
51         string.cs               \
52         stringbuilder.cs        \
53         switch.cs               \
54         outparm.cs              \
55         delegate.cs             \
56         bitconverter.cs         \
57         exception.cs            \
58         exception2.cs           \
59         exception3.cs           \
60         exception4.cs           \
61         exception5.cs           \
62         exception6.cs           \
63         exception7.cs           \
64         exception8.cs           \
65         exception10.cs          \
66         exception11.cs          \
67         exception12.cs          \
68         exception13.cs          \
69         exception14.cs          \
70         exception15.cs          \
71         exception16.cs          \
72         struct.cs               \
73         valuetype-gettype.cs    \
74         typeof-ptr.cs           \
75         static-constructor.cs   \
76         pinvoke.cs              \
77         pinvoke2.cs             \
78         pinvoke3.cs             \
79         pinvoke11.cs            \
80         pinvoke13.cs            \
81         pinvoke17.cs            \
82         invoke.cs               \
83         invoke2.cs              \
84         runtime-invoke.cs               \
85         invoke-string-ctors.cs          \
86         reinit.cs               \
87         box.cs                  \
88         array.cs                \
89         enum.cs                 \
90         enum2.cs                \
91         property.cs             \
92         enumcast.cs             \
93         assignable-tests.cs     \
94         array-cast.cs           \
95         cattr-compile.cs        \
96         cattr-field.cs          \
97         cattr-object.cs         \
98         custom-attr.cs          \
99         double-cast.cs          \
100         newobj-valuetype.cs     \
101         arraylist-clone.cs      \
102         setenv.cs               \
103         vtype.cs                \
104         isvaluetype.cs          \
105         iface6.cs               \
106         ipaddress.cs            \
107         array-vt.cs             \
108         interface1.cs           \
109         reflection-enum.cs      \
110         reflection-prop.cs      \
111         reflection4.cs          \
112         reflection5.cs          \
113         reflection-const-field.cs \
114         many-locals.cs          \
115         string-compare.cs       \
116         test-prime.cs           \
117         params.cs               \
118         reflection.cs           \
119         interface.cs            \
120         iface.cs                \
121         iface2.cs               \
122         iface3.cs               \
123         iface4.cs               \
124         iface-large.cs          \
125         virtual-method.cs       \
126         intptrcast.cs           \
127         indexer.cs              \
128         stream.cs               \
129         console.cs              \
130         shift.cs                \
131         jit-int.cs              \
132         jit-uint.cs             \
133         jit-long.cs             \
134         long.cs                 \
135         jit-ulong.cs            \
136         jit-float.cs            \
137         pop.cs                  \
138         time.cs                 \
139         appdomain.cs        \
140         appdomain1.cs           \
141         appdomain2.cs           \
142         appdomain-client.cs     \
143         appdomain-unload.cs \
144         loader.cs       \
145         pointer.cs              \
146         hashcode.cs             \
147         delegate1.cs            \
148         delegate2.cs            \
149         delegate3.cs            \
150         delegate5.cs            \
151         delegate6.cs            \
152         delegate7.cs            \
153         delegate8.cs            \
154         remoting1.cs            \
155         remoting2.cs            \
156         remoting3.cs            \
157         remoting4.cs            \
158         remoting5.cs            \
159         nonvirt.cs              \
160         largeexp.cs             \
161         largeexp2.cs            \
162         marshalbyref1.cs        \
163         static-ctor.cs          \
164         inctest.cs              \
165         bound.cs                \
166         array-invoke.cs         \
167         test-arr.cs             \
168         decimal.cs              \
169         decimal-array.cs        \
170         marshal.cs              \
171         marshal1.cs             \
172         marshal2.cs             \
173         marshal3.cs             \
174         marshal5.cs             \
175         marshal6.cs             \
176         marshal7.cs             \
177         marshal8.cs             \
178         marshal9.cs             \
179         test-byval-in-struct.cs \
180         thread.cs               \
181         thread5.cs              \
182         thread6.cs              \
183         thread-static.cs        \
184         thread-static-init.cs   \
185         context-static.cs       \
186         float-pop.cs            \
187         interfacecast.cs        \
188         array3.cs               \
189         classinit.cs            \
190         classinit2.cs           \
191         synchronized.cs         \
192         async_read.cs           \
193         threadpool.cs           \
194         threadpool1.cs          \
195         base-definition.cs      \
196         bug-27420.cs            \
197         bug-47295.cs            \
198         bug-46781.cs            \
199         bug-48015.cs            \
200         bug-42136.cs            \
201         bug-70561.cs            \
202         bug-78311.cs            \
203         bug-78653.cs            \
204         bug-78656.cs            \
205         interlocked.cs          \
206         cross-domain.cs         \
207         appdomain-exit.cs       \
208         delegate-async-exit.cs  \
209         delegate-delegate-exit.cs       \
210         delegate-exit.cs        \
211         finalizer-abort.cs      \
212         finalizer-exception.cs  \
213         finalizer-exit.cs       \
214         main-exit.cs    \
215         main-returns-abort-resetabort.cs        \
216         main-returns-background-abort-resetabort.cs     \
217         main-returns-background-resetabort.cs   \
218         main-returns-background.cs      \
219         main-returns-background-change.cs       \
220         main-returns.cs \
221         subthread-exit.cs       \
222         desweak.cs      \
223         cominterop.cs
224
225 if X86
226 # bug #71274
227 PLATFORM_DISABLED_TESTS=finalizer-abort.exe finalizer-exception.exe finalizer-exit.exe
228 endif
229
230 if POWERPC
231 # bug #71274
232 PLATFORM_DISABLED_TESTS=finalizer-abort.exe finalizer-exception.exe finalizer-exit.exe
233 endif
234
235 DISABLED_TESTS=                 \
236         delegate-async-exception.exe    \
237         delegate-delegate-exception.exe \
238         appdomain-unload.exe            \
239         $(PLATFORM_DISABLED_TESTS)
240
241 # These only compile with MS CSC
242 TEST_CSC_SRC=                   \
243         vararg.cs
244
245 TEST_IL_SRC=                    \
246         cpblkTest.il            \
247         vbinterface.il          \
248         jmpTest.il              \
249         calliTest.il            \
250         ckfiniteTest.il         \
251         locallocTest.il         \
252         initblkTest.il          \
253         qt-instance.il          \
254         vararg.il               \
255         bug-29859.il            \
256         bug-78549.il            \
257         static-fields-nonconst.il       \
258         reload-at-bb-end.il     \
259         test-enum-indstoreil.il \
260         even-odd.il
261
262 TEST_CS2_SRC = interlocked-2.2.cs pinvoke-2.2.cs
263 TEST_IL2_SRC = find-method.2.il
264
265 TESTSI_CS=$(TEST_CS_SRC:.cs=.exe)
266 TESTSI_IL=$(TEST_IL_SRC:.il=.exe)
267 TESTSI_CS2=$(TEST_CS2_SRC:.2.cs=.exe)
268 TESTSI_IL2=$(TEST_IL2_SRC:.2.il=.exe)
269 TESTBS=$(BENCHSRC:.cs=.exe)
270 STRESS_TESTS=$(STRESS_TESTS_SRC:.cs=.exe)
271
272 EXTRA_DIST=test-driver $(TEST_CS_SRC) $(TEST_CS2_SRC) $(TEST_IL_SRC) $(TEST_IL2_SRC) $(BENCHSRC) $(STRESS_TESTS_SRC) stress-runner.pl
273
274 %.exe: %.2.il
275         $(ILASM2) -out:$@ $<
276
277 %.exe: %.il
278         $(ILASM) -out:$@ $<
279
280 %.exe: %.2.cs TestDriver.dll
281         $(GMCS) -r:TestDriver.dll -out:$@ $<
282
283 %.exe: %.cs TestDriver.dll
284         $(MCS) -r:TestDriver.dll -out:$@ $<
285
286 # mkbundle works on ppc, but the pkg-config POC doesn't when run with make test
287 if POWERPC
288 test:   testjit test-type-load test-inline-call-stack
289 else
290 test:   testjit testbundle test-type-load test-inline-call-stack
291 endif
292
293 TestDriver.dll:
294         $(MCS) -target:library -out:$@ $(srcdir)/../mini/TestDriver.cs
295
296 test_cs: $(TEST_PROG) $(TESTSI_CS) libtest.la
297         @failed=0; \
298         passed=0; \
299         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
300         for i in $(TESTSI_CS); do       \
301                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
302                 then \
303                         passed=`expr $${passed} + 1`; \
304                 else \
305                         if [ $$? = 2 ]; then break; fi; \
306                         failed=`expr $${failed} + 1`; \
307                 fi \
308         done; \
309         echo; echo ".cs: $${passed} test(s) passed. $${failed} test(s) did not pass."; echo
310
311 test_il: $(TEST_PROG) $(TESTSI_IL) libtest.la
312         @failed=0; \
313         passed=0; \
314         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
315         for i in $(TESTSI_IL); do       \
316                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
317                 then \
318                         passed=`expr $${passed} + 1`; \
319                 else \
320                         if [ $$? = 2 ]; then break; fi; \
321                         failed=`expr $${failed} + 1`; \
322                 fi \
323         done; \
324         echo; echo ".il: $${passed} test(s) passed. $${failed} test(s) did not pass."; echo
325
326 testb: $(TEST_PROG) $(TESTBS)
327         for i in $(TESTBS); do  \
328                 $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS);     \
329         done
330
331 testjit: testjit-default testjit-net_2_0
332
333 testjit-default: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la
334         @failed=0; \
335         passed=0; \
336         failed_tests="";\
337         for i in $(TESTSI_CS) $(TESTBS) $(TESTSI_IL); do        \
338                 rm -f $${i}.so; \
339                 if $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
340                 then \
341                         passed=`expr $${passed} + 1`; \
342                 else \
343                         if [ $$? = 2 ]; then break; fi; \
344                         failed=`expr $${failed} + 1`; \
345                         failed_tests="$${failed_tests} $$i"; \
346                 fi \
347         done; \
348         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
349         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
350           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
351
352 testjit-net_2_0: $(TESTSI_CS2) $(TESTSI_IL2) libtest.la
353         @failed=0; \
354         passed=0; \
355         failed_tests="";\
356         for i in $(TESTSI_CS2) $(TESTSI_IL2); do        \
357                 rm -f $${i}.so; \
358                 if $(srcdir)/test-driver '$(with_mono_path2) $(JITTEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
359                 then \
360                         passed=`expr $${passed} + 1`; \
361                 else \
362                         if [ $$? = 2 ]; then break; fi; \
363                         failed=`expr $${failed} + 1`; \
364                         failed_tests="$${failed_tests} $$i"; \
365                 fi \
366         done; \
367         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
368         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
369           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
370
371 testaot: $(TESTSI_CS) $(TESTBS) libtest.la
372         @failed=0; \
373         passed=0; \
374         failed_tests="";\
375         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
376         for i in $(TESTSI_CS) $(TESTBS); do     \
377                 rm -f $${i}.so; \
378                 $(JITTEST_PROG_RUN) --aot $${i} > /dev/null; \
379                 if $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
380                 then \
381                         passed=`expr $${passed} + 1`; \
382                 else \
383                         if [ $$? = 2 ]; then break; fi; \
384                         failed=`expr $${failed} + 1`; \
385                         failed_tests="$${failed_tests} $$i"; \
386                 fi \
387         done; \
388         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
389         if [ $$failed != 0 ]; then echo -e "\nFailed tests:\n"; \
390           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
391
392 testtrace:
393         $(MAKE) RUNTIME_ARGS="$${RUNTIME_ARGS} --trace" testjit
394
395 testinterp: $(TESTSI_CS) $(TESTSI_IL) libtest.la
396         @failed=0; \
397         passed=0; \
398         failed_tests="";\
399         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
400         for i in $(TESTSI_CS) $(TESTSI_IL); do \
401                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
402                 then \
403                         passed=`expr $${passed} + 1`; \
404                 else \
405                         if [ $$? = 2 ]; then break; fi; \
406                         failed=`expr $${failed} + 1`; \
407                         failed_tests="$${failed_tests} $$i"; \
408                 fi \
409         done; \
410         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
411         if [ $$failed != 0 ]; then echo -e "\nFailed tests:\n"; \
412           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
413
414 testjitspeed: $(JITTEST_PROG) $(TESTBS)
415         for i in $(TESTBS); do  \
416                 echo $$i;       \
417                 time $(JITTEST_PROG) $$i;       \
418         done
419
420 stresstest: $(STRESS_TESTS)
421         @failed=0; \
422         passed=0; \
423         failed_tests="";\
424         for i in $(STRESS_TESTS); do    \
425                 if $(srcdir)/stress-runner.pl $$i ../mini/mono $(RUNTIME_ARGS); \
426                 then \
427                         passed=`expr $${passed} + 1`; \
428                 else \
429                         if [ $$? = 2 ]; then break; fi; \
430                         failed=`expr $${failed} + 1`; \
431                         failed_tests="$${failed_tests} $$i"; \
432                 fi \
433         done; \
434         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
435         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
436           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
437
438 testbundle: console.exe
439         $(MKBUNDLE) --static console.exe
440         $(with_mono_path) MONO_CFG_DIR=$(mono_cfg_dir) MONO_SHARED_DIR=$(mono_build_root)/runtime ./a.out
441         - rm -rf a.out
442
443 EXTRA_DIST += load-missing.il t-missing.cs load-exceptions.cs
444 test-type-load: TestDriver.dll
445         $(ILASM) /dll /output:load-missing.dll $(srcdir)/load-missing.il
446         $(MCS) -t:library -out:t.dll -d:FOUND $(srcdir)/t-missing.cs
447         $(MCS) -r:TestDriver.dll -r:load-missing.dll -r:t.dll -out:load-exceptions.exe $(srcdir)/load-exceptions.cs
448         $(MCS) -t:library -out:t.dll $(srcdir)/t-missing.cs
449         $(RUNTIME) load-exceptions.exe
450
451 EXTRA_DIST += test-inline-call-stack-library.cs test-inline-call-stack.cs
452 test-inline-call-stack-library.dll: TestDriver.dll $(srcdir)/test-inline-call-stack-library.cs
453         $(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs
454 test-inline-call-stack.exe: TestDriver.dll test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack.cs
455         $(MCS) -r:TestDriver.dll -r:test-inline-call-stack-library.dll -out:test-inline-call-stack.exe $(srcdir)/test-inline-call-stack.cs
456 test-inline-call-stack: TestDriver.dll test-inline-call-stack-library.dll test-inline-call-stack.exe
457         $(RUNTIME) test-inline-call-stack.exe
458
459 # Useful if mono is compiled with --enable-shared=no
460 patch-libtool:
461         cp "../../libtool" .
462         sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool
463         sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = bash ./libtool" > 1 && cat 1 2 > Makefile
464         touch libtest.c
465
466 noinst_LTLIBRARIES = libtest.la
467
468 INCLUDES = $(GLIB_CFLAGS)
469
470 if PLATFORM_WIN32
471 # gcc-3.4.4 emits incorrect code when making indirect calls to stdcall functions using a tail call
472 # This shows up when compiling mono_test_marshal_delegate ()
473 libtest_la_CFLAGS=-fno-optimize-sibling-calls
474 # the exported names created by gcc for stdcall functions are missing the leading _, so MS.NET
475 # can't find them. So we use --kill-at to remove the @ suffix as well.
476 libtest_la_LDFLAGS=-no-undefined -rpath `pwd` -Wl,--kill-at
477 else
478 libtest_la_LDFLAGS = -rpath `pwd`
479 endif
480 libtest_la_SOURCES = libtest.c
481 libtest_la_LIBADD = $(GLIB_LIBS)
482
483 CLEANFILES = $(TESTSI_CS) $(TESTSI_IL) $(STRESS_TESTS) *.dll *.stdout *.exe stest.dat