New tests.
[mono.git] / mono / tests / Makefile.am
1 SUBDIRS = cas assemblyresolve
2
3 # avoid including eglib twice since GLIB_LIBS == GMODULE_LIBS for eglib builds
4 if EGLIB_BUILD
5 glib_libs = $(GLIB_LIBS)
6 else
7 glib_libs = $(GLIB_LIBS) $(GMODULE_LIBS)
8 endif
9
10 check-local: test
11
12 aotcheck: testaot gshared-aot
13
14 TEST_PROG = ../interpreter/mint
15 JITTEST_PROG = ../mini/mono
16
17 TEST_PROG_RUN = MONO_SHARED_DIR=$(mono_build_root)/runtime MONO_CFG_DIR=$(mono_build_root)/runtime/etc $(LIBTOOL) --mode=execute $(TEST_PROG)
18 JITTEST_PROG_RUN = MONO_SHARED_DIR=$(mono_build_root)/runtime MONO_CFG_DIR=$(mono_build_root)/runtime/etc $(LIBTOOL) --mode=execute $(JITTEST_PROG)
19
20 RUNTIME_ARGS=--config tests-config --optimize=all --debug
21
22 with_mono_path = MONO_PATH=$(mcs_topdir)/class/lib/net_2_0
23 with_mono_path_moonlight = MONO_PATH=$(mcs_topdir)/class/lib/moonlight_raw
24
25 RUNTIME = $(with_mono_path) $(top_builddir)/runtime/mono-wrapper
26 RUNTIME_MOONLIGHT = $(with_mono_path_moonlight) $(top_builddir)/runtime/mono-wrapper
27
28 MKBUNDLE = \
29         PKG_CONFIG_PATH=$(top_builddir):$(PKG_CONFIG_PATH) \
30         $(RUNTIME) $(mcs_topdir)/class/lib/net_2_0/mkbundle.exe
31
32 MCS = $(RUNTIME) $(mcs_topdir)/class/lib/net_2_0/gmcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219 -debug
33 SMCS = $(RUNTIME_MOONLIGHT) --runtime=moonlight --security=temporary-smcs-hack $(mcs_topdir)/class/lib/moonlight_raw/smcs.exe -unsafe -nowarn:0162 -nowarn:0168 -nowarn:0219
34 ILASM = $(RUNTIME) $(mcs_topdir)/class/lib/net_2_0/ilasm.exe
35
36 BENCHSRC=fib.cs random.cs nested-loops.cs ackermann.cs tight-loop.cs sieve.cs
37
38 STRESS_TESTS_SRC=       \
39         abort-stress-1.cs       \
40         abort-stress-2.cs       \
41         abort-stress-3.cs       \
42         domain-stress.cs        \
43         gchandle-stress.cs      \
44         monitor-stress.cs       \
45         thread-stress.cs        \
46         gc-stress.cs            \
47         exit-stress.cs          \
48         process-stress.cs       \
49         assembly-load-stress.cs
50
51 BASE_TEST_CS_SRC=               \
52         array-init.cs           \
53         arraylist.cs            \
54         assemblyresolve_event.cs        \
55         assemblyresolve_event3.cs       \
56         checked.cs              \
57         char-isnumber.cs        \
58         create-instance.cs      \
59         field-layout.cs         \
60         pack-layout.cs          \
61         pack-bug.cs             \
62         hash-table.cs           \
63         test-ops.cs             \
64         obj.cs                  \
65         test-dup-mp.cs          \
66         string.cs               \
67         stringbuilder.cs        \
68         switch.cs               \
69         outparm.cs              \
70         delegate.cs             \
71         bitconverter.cs         \
72         exception.cs            \
73         exception2.cs           \
74         exception3.cs           \
75         exception4.cs           \
76         exception5.cs           \
77         exception6.cs           \
78         exception7.cs           \
79         exception8.cs           \
80         exception10.cs          \
81         exception11.cs          \
82         exception12.cs          \
83         exception13.cs          \
84         exception14.cs          \
85         exception15.cs          \
86         exception16.cs          \
87         exception17.cs          \
88         typeload-unaligned.cs   \
89         struct.cs               \
90         valuetype-gettype.cs    \
91         typeof-ptr.cs           \
92         static-constructor.cs   \
93         pinvoke.cs              \
94         pinvoke2.cs             \
95         pinvoke3.cs             \
96         pinvoke11.cs            \
97         pinvoke13.cs            \
98         pinvoke17.cs            \
99         invoke.cs               \
100         invoke2.cs              \
101         runtime-invoke.cs               \
102         invoke-string-ctors.cs          \
103         reinit.cs               \
104         box.cs                  \
105         array.cs                \
106         enum.cs                 \
107         enum2.cs                \
108         property.cs             \
109         enumcast.cs             \
110         assignable-tests.cs     \
111         array-cast.cs           \
112         array-subtype-attr.cs   \
113         cattr-compile.cs        \
114         cattr-field.cs          \
115         cattr-object.cs         \
116         custom-attr.cs          \
117         double-cast.cs          \
118         newobj-valuetype.cs     \
119         arraylist-clone.cs      \
120         setenv.cs               \
121         vtype.cs                \
122         isvaluetype.cs          \
123         iface6.cs               \
124         iface7.cs               \
125         ipaddress.cs            \
126         array-vt.cs             \
127         interface1.cs           \
128         reflection-enum.cs      \
129         reflection-prop.cs      \
130         reflection4.cs          \
131         reflection5.cs          \
132         reflection-const-field.cs \
133         many-locals.cs          \
134         string-compare.cs       \
135         test-prime.cs           \
136         params.cs               \
137         reflection.cs           \
138         interface.cs            \
139         iface.cs                \
140         iface2.cs               \
141         iface3.cs               \
142         iface4.cs               \
143         iface-large.cs          \
144         virtual-method.cs       \
145         intptrcast.cs           \
146         indexer.cs              \
147         stream.cs               \
148         console.cs              \
149         shift.cs                \
150         jit-int.cs              \
151         jit-uint.cs             \
152         jit-long.cs             \
153         long.cs                 \
154         jit-ulong.cs            \
155         jit-float.cs            \
156         pop.cs                  \
157         time.cs                 \
158         appdomain.cs        \
159         appdomain1.cs           \
160         appdomain2.cs           \
161         appdomain-client.cs     \
162         appdomain-unload.cs \
163         appdomain-async-invoke.cs       \
164         loader.cs       \
165         pointer.cs              \
166         hashcode.cs             \
167         delegate1.cs            \
168         delegate2.cs            \
169         delegate3.cs            \
170         delegate5.cs            \
171         delegate6.cs            \
172         delegate7.cs            \
173         delegate8.cs            \
174         delegate9.cs            \
175         remoting1.cs            \
176         remoting2.cs            \
177         remoting3.cs            \
178         remoting4.cs            \
179         remoting5.cs            \
180         largeexp.cs             \
181         largeexp2.cs            \
182         marshalbyref1.cs        \
183         static-ctor.cs          \
184         inctest.cs              \
185         bound.cs                \
186         array-invoke.cs         \
187         test-arr.cs             \
188         decimal.cs              \
189         decimal-array.cs        \
190         marshal.cs              \
191         marshal1.cs             \
192         marshal2.cs             \
193         marshal3.cs             \
194         marshal5.cs             \
195         marshal6.cs             \
196         marshal7.cs             \
197         marshal8.cs             \
198         marshal9.cs             \
199         marshalbool.cs          \
200         marshal-valuetypes.cs   \
201         test-byval-in-struct.cs \
202         thread.cs               \
203         thread5.cs              \
204         thread6.cs              \
205         thread-static.cs        \
206         thread-static-init.cs   \
207         context-static.cs       \
208         float-pop.cs            \
209         interfacecast.cs        \
210         array3.cs               \
211         classinit.cs            \
212         classinit2.cs           \
213         synchronized.cs         \
214         async_read.cs           \
215         threadpool.cs           \
216         threadpool1.cs          \
217         base-definition.cs      \
218         bug-27420.cs            \
219         bug-47295.cs            \
220         bug-46781.cs            \
221         bug-48015.cs            \
222         bug-42136.cs            \
223         bug-59286.cs            \
224         bug-70561.cs            \
225         bug-78311.cs            \
226         bug-78653.cs            \
227         bug-78656.cs            \
228         bug-77127.cs            \
229         bug-323114.cs           \
230         bug-331958.cs           \
231         interlocked.cs          \
232         cross-domain.cs         \
233         appdomain-exit.cs       \
234         delegate-async-exit.cs  \
235         delegate-delegate-exit.cs       \
236         delegate-exit.cs        \
237         finalizer-abort.cs      \
238         finalizer-exception.cs  \
239         finalizer-exit.cs       \
240         main-exit.cs    \
241         main-returns-abort-resetabort.cs        \
242         main-returns-background-abort-resetabort.cs     \
243         main-returns-background-resetabort.cs   \
244         main-returns-background.cs      \
245         main-returns-background-change.cs       \
246         main-returns.cs         \
247         subthread-exit.cs       \
248         desweak.cs              \
249         cominterop.cs           \
250         exists.cs               \
251         handleref.cs    \
252         transparentproxy.cs \
253         dbnull-missing.cs       \
254         test-type-ctor.cs       \
255         soft-float-tests.cs     \
256         thread-exit.cs          \
257         finalize-parent.cs      \
258         assemblyresolve_event2.2.cs     \
259         interlocked-2.2.cs      \
260         pinvoke-2.2.cs          \
261         bug-78431.2.cs          \
262         bug-79684.2.cs          \
263         catch-generics.2.cs     \
264         event-get.2.cs          \
265         safehandle.2.cs         \
266         stackframes-async.2.cs          \
267         module-cctor-loader.2.cs        \
268         generics-invoke-byref.2.cs      \
269         generic-signature-compare.2.cs  \
270         generics-sharing.2.cs   \
271         shared-generic-methods.2.cs     \
272         shared-generic-synchronized.2.cs        \
273         generic-inlining.2.cs   \
274         generic-initobj.2.cs    \
275         generic-delegate.2.cs   \
276         generic-sizeof.2.cs     \
277         generic-virtual.2.cs    \
278         generic-interface-methods.2.cs  \
279         generic-array-type.2.cs \
280         generic-method-patching.2.cs    \
281         generic-static-methods.2.cs     \
282         generic-null-call.2.cs  \
283         generic-special.2.cs    \
284         generic-exceptions.2.cs \
285         generic-virtual2.2.cs   \
286         generic-valuetype-interface.2.cs        \
287         generic-getgenericarguments.2.cs        \
288         generic-type-builder.2.cs       \
289         generic-synchronized.2.cs       \
290         generic-delegate-ctor.2.cs      \
291         generic-array-iface-set.2.cs    \
292         generic-typedef.2.cs    \
293         generic-marshalbyref.2.cs       \
294         generic-xdomain.2.cs    \
295         bug-431413.2.cs \
296         bug-459285.2.cs \
297         generic-virtual-invoke.2.cs     \
298         bug-461198.2.cs \
299         generic-sealed-virtual.2.cs     \
300         generic-system-arrays.2.cs      \
301         generic-stack-traces.2.cs       \
302         generic-stack-traces2.2.cs      \
303         bug-472600.2.cs \
304         recursive-generics.2.cs \
305         bug-473482.2.cs \
306         bug-473999.2.cs \
307         bug-479763.2.cs \
308         bug-80392.2.cs          \
309         dynamic-method-access.2.cs      \
310         dynamic-method-finalize.2.cs    \
311         bug-82194.2.cs  \
312         anonarray.2.cs  \
313         ienumerator-interfaces.2.cs     \
314         array-enumerator-ifaces.2.cs    \
315         generic_type_definition_encoding.2.cs \
316         generic_type_definition.2.cs    \
317         bug-333798.2.cs         \
318         bug-333798-tb.2.cs              \
319         bug-335131.2.cs         \
320         bug-322722_patch_bx.2.cs                \
321         bug-348522.2.cs         \
322         bug-340662_bug.cs       \
323         bug-322722_dyn_method_throw.2.cs        \
324         bug-389886-2.cs \
325         bug-325283.2.cs \
326         thunks.cs \
327         winx64structs.cs \
328         bug-349190.2.cs \
329         nullable_boxing.2.cs    \
330         valuetype-equals.cs     \
331         custom-modifiers.2.cs   \
332         bug-382986.cs   \
333         test-inline-call-stack.cs       \
334         bug-324535.cs   \
335         modules.cs      \
336         bug-81673.cs    \
337         bug-81691.cs    \
338         bug-80307.cs    \
339         bug-415577.cs   \
340         filter-stack.cs \
341         vararg2.cs      \
342         bug-389886-sre-generic-interface-instances.cs   \
343         bug-461867.cs   \
344         bug-461941.cs   \
345         bug-461261.cs   \
346         bug-400716.cs   \
347         bug-462592.cs   \
348         bug-459094.cs   \
349         generic-unloading.2.cs  \
350         generic-unloading-sub.2.cs      \
351         bug-467456.cs   \
352         appdomain-unload-callback.cs    \
353         bug-508538.cs   \
354         bug-472692.2.cs         \
355         gchandles.cs    \
356         interlocked-3.cs        \
357         interlocked-4.2.cs      \
358         finalizer-wait.cs       \
359         critical-finalizers.cs  \
360         appdomain-thread-abort.cs \
361         xdomain-threads.cs      \
362         w32message.cs   \
363         bug-544446.cs   \
364         gc-altstack.cs  \
365         large-gc-bitmap.cs      \
366         bug-561239.cs   \
367         bug-562150.cs   \
368         bug-575941.cs   \
369         bug-599469.cs
370
371 TEST_CS_SRC_DIST=       \
372         $(BASE_TEST_CS_SRC)     \
373         async-exc-compilation.cs \
374         filter-stack.cs
375
376 if AMD64
377 TEST_CS_SRC = $(BASE_TEST_CS_SRC) async-exc-compilation.cs
378 else
379 if X86
380 TEST_CS_SRC = $(BASE_TEST_CS_SRC) async-exc-compilation.cs
381 else
382 TEST_CS_SRC = $(BASE_TEST_CS_SRC)
383 endif
384 endif
385
386 if IA64
387 TEST_CS_SRC+=async-exc-compilation.cs filter-stack.cs
388 # bug #319249
389 PLATFORM_DISABLED_TESTS=exception17.exe
390 PLATFORM_DISABLED_TESTS+=winx64structs.exe
391 endif
392
393 if X86
394
395 if HOST_WIN32
396 PLATFORM_DISABLED_TESTS=async-exc-compilation.exe
397 endif
398
399 endif
400
401 if POWERPC
402 # bug #71274
403 PLATFORM_DISABLED_TESTS=finalizer-abort.exe finalizer-exception.exe finalizer-exit.exe
404 endif
405
406 if ARM
407 PLATFORM_DISABLED_TESTS=filter-stack.exe
408 endif
409
410 # The two finalizer tests only work under sgen
411 DISABLED_TESTS=                 \
412         delegate-async-exception.exe    \
413         bug-348522.2.exe        \
414         finalizer-wait.exe      \
415         critical-finalizers.exe \
416         $(PLATFORM_DISABLED_TESTS)
417
418 AOT_DISABLED_TESTS=constraints-load.exe
419
420 # These only compile with MS CSC
421 TEST_CSC_SRC=                   \
422         vararg.cs
423
424 TEST_IL_SRC=                    \
425         field-access.il         \
426         method-access.il        \
427         ldftn-access.il         \
428         cpblkTest.il            \
429         vbinterface.il          \
430         calliTest.il            \
431         ckfiniteTest.il         \
432         fault-handler.il                \
433         locallocTest.il         \
434         initblkTest.il          \
435         qt-instance.il          \
436         vararg.il               \
437         bug-29859.il            \
438         bug-78549.il            \
439         static-fields-nonconst.il       \
440         reload-at-bb-end.il     \
441         test-enum-indstoreil.il \
442         filter-bug.il           \
443         even-odd.il             \
444         bug-82022.il    \
445         vt-sync-method.il       \
446         enum_types.il   \
447         invalid-token.il        \
448         call_missing_method.il  \
449         call_missing_class.il   \
450         ldfld_missing_field.il  \
451         ldfld_missing_class.il  \
452         find-method.2.il        \
453         bug-79215.2.il  \
454         bug-79956.2.il  \
455         bug-327438.2.il \
456         bug-387274.2.il \
457         bug-426309.2.il \
458         ldtoken_with_byref_typespec.2.il \
459         resolve_method_bug.2.il \
460         resolve_field_bug.2.il \
461         resolve_type_bug.2.il   \
462         generics-sharing-other-exc.2.il \
463         generic-ldobj.2.il      \
464         generic-mkrefany.2.il   \
465         generic-refanyval.2.il  \
466         generic-ldtoken.2.il    \
467         generic-ldtoken-method.2.il     \
468         generic-ldtoken-field.2.il      \
469         generic-tailcall.2.il   \
470         generic-tailcall2.2.il  \
471         generic-array-exc.2.il  \
472         generic-valuetype-newobj2.2.il  \
473         generic-valuetype-newobj.2.il   \
474         generic-constrained.2.il        \
475         generic-type-load-exception.2.il        \
476         bug-81466.il    \
477         bug457574.il    \
478         bug445361.il    \
479         bug-463303.il   \
480         bug469742.2.il  \
481         bug-528055.il   \
482         constraints-load.il     \
483         array_load_exception.il \
484         bug-481403.il   \
485         interface-with-static-method.il \
486         bug-515884.il
487
488 #       bug-318677.il
489
490 # pre-requisite test sources: files that are not test themselves
491 # but that need to be compiled
492 PREREQ_IL_SRC=event-il.il module-cctor.il
493 PREREQ_CS_SRC=
494 PREREQ_IL_DLL_SRC=event-il.il module-cctor.il
495 PREREQ_CS_DLL_SRC=
496
497 PREREQSI_IL=$(PREREQ_IL_SRC:.il=.exe)
498 PREREQSI_CS=$(PREREQ_CS_SRC:.cs=.exe)
499 TESTSI_CS=$(TEST_CS_SRC:.cs=.exe)
500 TESTSI_IL=$(TEST_IL_SRC:.il=.exe)
501 TESTBS=$(BENCHSRC:.cs=.exe)
502 STRESS_TESTS=$(STRESS_TESTS_SRC:.cs=.exe)
503
504 EXTRA_DIST=test-driver $(TEST_CS_SRC_DIST) $(TEST_IL_SRC) \
505         $(BENCHSRC) $(STRESS_TESTS_SRC) stress-runner.pl $(PREREQ_IL_SRC) $(PREREQ_CS_SRC)
506
507 %.exe: %.il
508         $(ILASM) -out:$@ $<
509
510 %.exe: %.cs TestDriver.dll
511         $(MCS) -r:TestDriver.dll -out:$@ $<
512
513 # mkbundle works on ppc, but the pkg-config POC doesn't when run with make test
514 if POWERPC
515 test_platform:  testbundle
516 else
517 # Can't use mkbundle on win32 since there is no static build there
518 # Can't run test-unhandled-exception on Windows because of all the debug popups...
519 if HOST_WIN32
520 test_platform:
521 else
522 # mkbundle uses the installed mono-2.pc so it won't work if there is no system mono
523 #test_platform: testbundle test-iomap-regression
524 test_platform:  test-iomap-regression
525 endif
526 endif
527
528 #
529 # Tests that the internals in mono/io-layer/messages.c are ok by triggering the 
530 # code that checks that the table is properly sorted
531 #
532 test_messages: w32message.exe
533         > test_messages.zero
534         $(JITTEST_PROG_RUN) w32message.exe >& w32message.allout && cmp test_messages.zero w32message.allout
535
536 if MOONLIGHT
537 test_2_1 : test-coreclr-security
538 else
539 test_2_1 :
540 endif
541
542 # test_messages fails on the buildbots
543 #test: assemblyresolve/test/asm.dll testjit test-type-load test-generic-sharing test_platform test_2_1 test_messages
544 test: assemblyresolve/test/asm.dll testjit test-type-load test-generic-sharing test_platform test-runtime-invoke test-imt-big-iface test_2_1
545
546 assemblyresolve/test/asm.dll:
547         $(MAKE) -C assemblyresolve prereq
548
549 TestDriver.dll:
550         $(MCS) -target:library -out:$@ $(srcdir)/../mini/TestDriver.cs
551
552 test_cs: $(TEST_PROG) $(TESTSI_CS) libtest.la
553         @failed=0; \
554         passed=0; \
555         for i in $(TESTSI_CS); do       \
556                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
557                 then \
558                         passed=`expr $${passed} + 1`; \
559                 else \
560                         if [ $$? = 2 ]; then break; fi; \
561                         failed=`expr $${failed} + 1`; \
562                 fi \
563         done; \
564         echo; echo ".cs: $${passed} test(s) passed. $${failed} test(s) did not pass."; echo
565
566 test_il: $(TEST_PROG) $(TESTSI_IL) libtest.la
567         @failed=0; \
568         passed=0; \
569         for i in $(TESTSI_IL); do       \
570                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
571                 then \
572                         passed=`expr $${passed} + 1`; \
573                 else \
574                         if [ $$? = 2 ]; then break; fi; \
575                         failed=`expr $${failed} + 1`; \
576                 fi \
577         done; \
578         echo; echo ".il: $${passed} test(s) passed. $${failed} test(s) did not pass."; echo
579
580 testb: $(TEST_PROG) $(TESTBS)
581         for i in $(TESTBS); do  \
582                 $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS);     \
583         done
584
585 runtest: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
586         @failed=0; \
587         passed=0; \
588         failed_tests="";\
589         for i in $(TESTSI_CS) $(TESTBS) $(TESTSI_IL); do        \
590                 rm -f $${i}.so; \
591                 if [ x$(AOT) = x1 ]; then if echo $(AOT_DISABLED_TESTS) | grep -v -q $${i}; then $(with_mono_path) $(JITTEST_PROG_RUN) --aot --debug $${i} > $${i}.aotlog 2>&1 || exit 1; fi; fi; \
592                 if $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
593                 then \
594                         passed=`expr $${passed} + 1`; \
595                 else \
596                         if [ $$? = 2 ]; then break; fi; \
597                         failed=`expr $${failed} + 1`; \
598                         failed_tests="$${failed_tests} $$i"; \
599                 fi \
600         done; \
601         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
602         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
603           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
604
605 runtest-managed: test-runner.exe $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la $(PREREQSI_IL) $(PREREQSI_CS)
606         @$(RUNTIME) ./test-runner.exe -j a --disabled '$(DISABLED_TESTS)' $(TESTSI_CS) $(TESTBS) $(TESTSI_IL)
607
608 testjit:
609         @if test x$(M) != x; then $(MAKE) runtest-managed; else $(MAKE) runtest; fi
610
611 testaot:
612         @$(MAKE) AOT=1 runtest
613
614 testtrace:
615         @$(MAKE) RUNTIME_ARGS="$${RUNTIME_ARGS} --trace" runtest
616
617 testinterp:
618         @$(MAKE) JITTEST_PROG_RUN="$(TEST_PROG_RUN)" runtest
619
620 testjitspeed: $(JITTEST_PROG) $(TESTBS)
621         for i in $(TESTBS); do  \
622                 echo $$i;       \
623                 time $(JITTEST_PROG) $$i;       \
624         done
625
626 test-iomap-regression: exists.cs
627         @$(MCS) $(srcdir)/exists.cs -out:exists.exe
628         @echo "Testing exists.exe..."
629         @MONO_IOMAP=all $(RUNTIME) exists.exe
630
631 stresstest: $(STRESS_TESTS)
632         @failed=0; \
633         passed=0; \
634         failed_tests="";\
635         for i in $(STRESS_TESTS); do    \
636                 if $(srcdir)/stress-runner.pl $$i ../mini/mono $(RUNTIME_ARGS); \
637                 then \
638                         passed=`expr $${passed} + 1`; \
639                 else \
640                         if [ $$? = 2 ]; then break; fi; \
641                         failed=`expr $${failed} + 1`; \
642                         failed_tests="$${failed_tests} $$i"; \
643                 fi \
644         done; \
645         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
646         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
647           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
648
649 testbundle: console.exe
650         @echo "Testing mkbundle..."
651         @$(MKBUNDLE) --static console.exe > mkbundle.stdout
652         @$(with_mono_path) MONO_CFG_DIR=$(mono_cfg_dir) MONO_SHARED_DIR=$(mono_build_root)/runtime ./a.out >> mkbundle.stdout
653         @- rm -rf a.out
654
655 EXTRA_DIST += load-missing.il t-missing.cs load-exceptions.cs
656 test-type-load: TestDriver.dll
657         @$(ILASM) /dll /output:load-missing.dll $(srcdir)/load-missing.il > /dev/null
658         @$(MCS) -t:library -out:t.dll -d:FOUND $(srcdir)/t-missing.cs
659         @$(MCS) -r:TestDriver.dll -r:load-missing.dll -r:t.dll -out:load-exceptions.exe $(srcdir)/load-exceptions.cs
660         @$(MCS) -t:library -out:t.dll $(srcdir)/t-missing.cs
661         @echo "Testing load-exception.exe..."
662         @$(RUNTIME) load-exceptions.exe > load-exceptions.exe.stdout 2> load-exceptions.exe.stderr
663
664 # Generated tests for runtime invoke
665 EXTRA_DIST += gen-runtime-invoke.cs
666 test-runtime-invoke: TestDriver.dll gen-runtime-invoke.exe
667         @$(RUNTIME) gen-runtime-invoke.exe > runtime-invoke.gen.cs
668         @$(MCS) -out:runtime-invoke.gen.exe -r:TestDriver.dll runtime-invoke.gen.cs
669         @echo "Testing runtime-invoke.gen.exe..."
670         @$(RUNTIME) runtime-invoke.gen.exe > runtime-invoke.gen.exe.stdout 2> runtime-invoke.gen.exe.stderr
671
672 EXTRA_DIST += make-imt-test.cs
673 test-imt-big-iface: TestDriver.dll make-imt-test.exe
674         @$(RUNTIME) make-imt-test.exe > imt_big_iface_test.cs
675         @$(MCS) -out:imt_big_iface_test.exe -r:TestDriver.dll imt_big_iface_test.cs
676         @echo "Testing imt_big_iface_test.exe..."
677         @$(RUNTIME) imt_big_iface_test.exe > imt_big_iface_test.exe.stdout 2> imt_big_iface_test.exe.stderr
678
679 EXTRA_DIST += test-inline-call-stack-library.cs test-inline-call-stack.cs
680 test-inline-call-stack-library.dll: TestDriver.dll $(srcdir)/test-inline-call-stack-library.cs
681         $(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs
682 test-inline-call-stack.exe: TestDriver.dll test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack.cs
683         $(MCS) -r:TestDriver.dll -r:test-inline-call-stack-library.dll -out:test-inline-call-stack.exe $(srcdir)/test-inline-call-stack.cs
684
685 EXTRA_DIST += unhandled-exception-base-configuration.config
686 EXTRA_DIST += unhandled-exception-legacy-configuration.config
687 EXTRA_DIST += unhandled-exception-test-case.2.cs
688 EXTRA_DIST += unhandled-exception-test-runner.2.cs
689 unhandled-exception-test-case.1.cs: unhandled-exception-test-case.2.cs
690         cp unhandled-exception-test-case.2.cs unhandled-exception-test-case.1.cs
691 unhandled-exception-test-case-legacy.1.cs: unhandled-exception-test-case.1.cs
692         cp unhandled-exception-test-case.1.cs unhandled-exception-test-case-legacy.1.cs
693 unhandled-exception-test-case-legacy.2.cs: unhandled-exception-test-case.2.cs
694         cp unhandled-exception-test-case.2.cs unhandled-exception-test-case-legacy.2.cs
695 unhandled-exception-config_files: unhandled-exception-base-configuration.config unhandled-exception-legacy-configuration.config
696         cp unhandled-exception-base-configuration.config unhandled-exception-test-case.1.exe.config
697         cp unhandled-exception-base-configuration.config unhandled-exception-test-case.2.exe.config
698         cp unhandled-exception-legacy-configuration.config unhandled-exception-test-case-legacy.1.exe.config
699         cp unhandled-exception-legacy-configuration.config unhandled-exception-test-case-legacy.2.exe.config
700 unhandled-exception-test-case.1.exe: unhandled-exception-test-case.1.cs
701         $(MCS) /debug unhandled-exception-test-case.1.cs
702 unhandled-exception-test-case-legacy.1.exe: unhandled-exception-test-case-legacy.1.cs
703         $(MCS) /debug unhandled-exception-test-case-legacy.1.cs
704 unhandled-exception-test-case.2.exe: unhandled-exception-test-case.2.cs
705         $(MCS) /debug unhandled-exception-test-case.2.cs
706 unhandled-exception-test-case-legacy.2.exe: unhandled-exception-test-case-legacy.2.cs
707         $(MCS) /debug unhandled-exception-test-case-legacy.2.cs
708 unhandled-exception-test-runner.2.exe: unhandled-exception-test-runner.2.cs
709         $(MCS) /debug unhandled-exception-test-runner.2.cs
710
711 test-unhandled-exception: unhandled-exception-test-runner.2.exe unhandled-exception-config_files unhandled-exception-test-case.1.exe unhandled-exception-test-case-legacy.1.exe  unhandled-exception-test-case.2.exe unhandled-exception-test-case-legacy.2.exe
712         $(RUNTIME) unhandled-exception-test-runner.2.exe RUNTIME:../mini/mono,GTC:F
713
714 # We use 'test-support-files' to handle an ordering issue between the 'mono/' and 'runtime/' directories
715 bug-80307.exe: $(srcdir)/bug-80307.cs
716         $(MCS) -r:System.Web -out:$@ $(srcdir)/bug-80307.cs
717         cd $(top_builddir)/runtime && $(MAKE) test-support-files
718
719 EXTRA_DIST += bug-81673-interface.cs
720 bug-81673.exe bug-81673-interface.dll: $(srcdir)/bug-81673.cs $(srcdir)/bug-81673-interface.cs
721         $(MCS) -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
722         $(MCS) -out:bug-81673.exe -r:bug-81673-interface.dll $(srcdir)/bug-81673.cs
723         $(MCS) -define:WITH_STOP -target:library -out:bug-81673-interface.dll $(srcdir)/bug-81673-interface.cs
724
725 EXTRA_DIST += bug-81691-a.cs bug-81691-b.cs
726 bug-81691.exe bug-81691-b.dll: $(srcdir)/bug-81691.cs $(srcdir)/bug-81691-a.cs $(srcdir)/bug-81691-b.cs
727         $(MCS) -target:library -out:bug-81691-a.dll $(srcdir)/bug-81691-a.cs
728         $(MCS) -target:library -out:bug-81691-b.dll -r:bug-81691-a.dll $(srcdir)/bug-81691-b.cs
729         $(MCS) -r:bug-81691-b.dll -out:bug-81691.exe $(srcdir)/bug-81691.cs
730         rm -f bug-81691-a.dll
731
732 EXTRA_DIST += bug-81466-lib.il
733 bug-81466-lib.dll: bug-81466-lib.il
734         $(ILASM) /dll /output:bug-81466-lib.dll $(srcdir)/bug-81466-lib.il
735 bug-81466.exe: bug-81466.il bug-81466-lib.dll
736         $(ILASM) /exe /output:bug-81466.exe $(srcdir)/bug-81466.il
737
738 EXTRA_DIST += bug-324535-il.il
739 bug-324535-il.dll : bug-324535-il.il
740         $(ILASM) /dll /output:bug-324535-il.dll $(srcdir)/bug-324535-il.il
741 bug-324535.exe : bug-324535.cs bug-324535-il.dll
742         $(MCS) -r:bug-324535-il.dll -out:bug-324535.exe $(srcdir)/bug-324535.cs
743
744 EXTRA_DIST += custom-modifiers.2.cs custom-modifiers-lib.il
745 custom-modifiers-lib.dll: custom-modifiers-lib.il
746         $(ILASM) /dll /output:custom-modifiers-lib.dll $(srcdir)/custom-modifiers-lib.il
747 custom-modifiers.2.exe: custom-modifiers.2.cs custom-modifiers-lib.dll
748         $(MCS) -r:custom-modifiers-lib.dll -out:custom-modifiers.2.exe $(srcdir)/custom-modifiers.2.cs
749
750 EXTRA_DIST += bug-382986-lib.cs
751 bug-382986-lib.dll: bug-382986-lib.cs
752         $(MCS) -target:library -out:$@ $(srcdir)/bug-382986-lib.cs
753 bug-382986.exe: bug-382986.cs bug-382986-lib.dll
754         $(MCS) -out:$@ -r:bug-382986-lib.dll $(srcdir)/bug-382986.cs
755
756 EXTRA_DIST += coreclr-security.cs
757
758 if MOONLIGHT
759 coreclr-security.exe : coreclr-security.cs
760         $(SMCS) -out:coreclr-security.exe $(srcdir)/coreclr-security.cs
761
762 test-coreclr-security : coreclr-security.exe
763         @echo "Testing coreclr-security.exe..."
764         @$(RUNTIME_MOONLIGHT) --security=core-clr-test coreclr-security.exe
765 endif
766
767 EXTRA_DIST += generic-unboxing.2.il
768 generic-unboxing.2.dll : generic-unboxing.2.il
769         $(ILASM) /dll /output:generic-unboxing.2.dll $(srcdir)/generic-unboxing.2.il
770
771 EXTRA_DIST += generic-boxing.2.il
772 generic-boxing.2.dll : generic-boxing.2.il generic-unboxing.2.dll
773         $(ILASM) /dll /output:generic-boxing.2.dll $(srcdir)/generic-boxing.2.il
774
775 EXTRA_DIST += generic-unbox.2.cs
776 generic-unbox.2.exe : generic-unbox.2.cs generic-unboxing.2.dll
777         $(MCS) -r:generic-unboxing.2.dll -out:$@ $(srcdir)/generic-unbox.2.cs
778
779 EXTRA_DIST += generic-box.2.cs
780 generic-box.2.exe : generic-box.2.cs generic-unboxing.2.dll generic-boxing.2.dll
781         $(MCS) -r:generic-unboxing.2.dll,generic-boxing.2.dll -out:$@ $(srcdir)/generic-box.2.cs
782
783 EXTRA_DIST += generic-delegate2.2.cs generic-delegate2-lib.2.il
784 generic-delegate2-lib.2.dll : generic-delegate2-lib.2.il
785         $(ILASM) /dll /output:$@ $(srcdir)/generic-delegate2-lib.2.il
786 generic-delegate2.2.exe : generic-delegate2.2.cs generic-delegate2-lib.2.dll
787         $(MCS) -r:generic-delegate2-lib.2.dll -out:$@ $(srcdir)/generic-delegate2.2.cs
788
789 gshared: test-generic-sharing
790
791 gshared-aot:
792         @$(MAKE) AOT=1 gshared
793
794 GSHARED_TESTS = \
795                 generics-sharing.2.exe shared-generic-methods.2.exe     \
796                 shared-generic-synchronized.2.exe generic-initobj.2.exe         \
797                 generics-sharing-other-exc.2.exe generic-box.2.exe              \
798                 generic-unbox.2.exe generic-delegate.2.exe generic-sizeof.2.exe \
799                 generic-ldobj.2.exe generic-mkrefany.2.exe                      \
800                 generic-refanyval.2.exe generic-ldtoken.2.exe                   \
801                 generic-ldtoken-method.2.exe  generic-ldtoken-field.2.exe       \
802                 generic-virtual.2.exe generic-tailcall.2.exe                    \
803                 generic-interface-methods.2.exe generic-array-type.2.exe        \
804                 generic-method-patching.2.exe generic-static-methods.2.exe      \
805                 generic-null-call.2.exe generic-tailcall2.2.exe                 \
806                 generic-array-exc.2.exe generic-special.2.exe                   \
807                 generic-exceptions.2.exe generic-delegate2.2.exe                \
808                 generic-virtual2.2.exe generic-valuetype-interface.2.exe        \
809                 generic-valuetype-newobj.2.exe generic-valuetype-newobj2.2.exe  \
810                 generic-getgenericarguments.2.exe generic-type-builder.2.exe    \
811                 generic-synchronized.2.exe generic-delegate-ctor.2.exe          \
812                 generic-constrained.2.exe bug-431413.2.exe                      \
813                 generic-virtual-invoke.2.exe generic-typedef.2.exe              \
814                 generic-marshalbyref.2.exe bug-459285.2.exe bug-461198.2.exe    \
815                 generic-sealed-virtual.2.exe generic-system-arrays.2.exe        \
816                 generic-stack-traces.2.exe generic-stack-traces2.2.exe          \
817                 bug-472600.2.exe bug-473482.2.exe bug-473999.2.exe              \
818                 bug-479763.2.exe generic-xdomain.2.exe                          \
819                 generic-type-load-exception.2.exe
820
821 test-generic-sharing-normal: $(GSHARED_TESTS)
822         @for fn in $+ ; do      \
823                 echo "Testing $$fn ...";        \
824                 MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared                $$fn > $$fn.stdout || exit 1;     \
825                 MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared,shared         $$fn > $$fn.stdout || exit 1;     \
826                 MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared,-inline        $$fn > $$fn.stdout || exit 1;     \
827                 MONO_GENERIC_SHARING=all $(RUNTIME) -O=gshared,-inline,shared $$fn > $fn.stdout || exit 1;      \
828                 if [ x$(AOT) = x1 ]; then MONO_GENERIC_SHARING=all $(with_mono_path) $(JITTEST_PROG_RUN) --aot --debug $$fn > /dev/null || exit 1; MONO_GENERIC_SHARING=all $(RUNTIME) $$fn > $$fn.stdout || exit 1; fi; \
829         done
830
831 test-generic-sharing-managed: test-runner.exe $(GSHARED_TESTS)
832         @$(RUNTIME) ./test-runner.exe -j a --opt-sets "gshared gshared,shared gshared,-inline gshared,-inline,shared" $(GSHARED_TESTS)
833
834 test-generic-sharing:
835         @if test x$(M) != x; then $(MAKE) test-generic-sharing-managed; else $(MAKE) test-generic-sharing-normal; fi
836
837 EXTRA_DIST += async-exceptions.cs
838 async-exceptions.exe : async-exceptions.cs
839         $(MCS) -out:async-exceptions.exe $(srcdir)/async-exceptions.cs
840 test-async-exceptions : async-exceptions.exe
841         for i in `echo 0 1 2 3 4 5 6 7 8 9 10`; do $(RUNTIME) --inject-async-exc Tests:foo $$i async-exceptions.exe || exit 1; done
842         for i in `echo 0 1 2 3 4 5 6 7 8 9 10`; do $(RUNTIME) --inject-async-exc Tests:bar $$i async-exceptions.exe || exit 1; done
843
844 EXTRA_DIST += modules.cs modules-m1.cs
845 modules-m1.netmodule: modules-m1.cs
846         $(MCS) -out:$@ /target:module $(srcdir)/modules-m1.cs
847 modules.exe: modules.cs modules-m1.netmodule TestDriver.dll
848         $(MCS) -out:$@ /addmodule:modules-m1.netmodule -r:TestDriver.dll $(srcdir)/modules.cs
849
850 EXTRA_DIST += dtest.cs dtest-app.cs
851
852 dcheck: dtest.dll dtest-app.exe
853         @echo "Testing soft-debugger..."
854         @nunit-console2 -labels dtest.dll > dcheck.stdout 2> dcheck.stderr
855
856 dtest.dll:
857         $(MCS) -r:Mono.Debugger.Soft.dll -pkg:mono-nunit /target:library -r:`pkg-config --variable Libraries cecil` /debug $(srcdir)/dtest.cs
858
859 dtest-app.exe:
860         $(MCS) /debug /unsafe $(srcdir)/dtest-app.cs
861
862 # Useful if mono is compiled with --enable-shared=no
863 patch-libtool:
864         cp "../../libtool" .
865         sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool
866         sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = bash ./libtool" > 1 && cat 1 2 > Makefile
867         touch libtest.c
868
869 noinst_LTLIBRARIES = libtest.la
870
871 INCLUDES = $(GLIB_CFLAGS) $(GMODULE_CFLAGS)
872
873 if HOST_WIN32
874 # gcc-3.4.4 emits incorrect code when making indirect calls to stdcall functions using a tail call
875 # This shows up when compiling mono_test_marshal_delegate ()
876 libtest_la_CFLAGS=-fno-optimize-sibling-calls
877 # the exported names created by gcc for stdcall functions are missing the leading _, so MS.NET
878 # can't find them. So we use --kill-at to remove the @ suffix as well.
879 libtest_la_LDFLAGS=-no-undefined -rpath `pwd` -Wl,--kill-at
880 else
881 libtest_la_LDFLAGS = -rpath `pwd`
882 endif
883 libtest_la_SOURCES = libtest.c
884 libtest_la_LIBADD = $(glib_libs)
885
886 CLEANFILES = $(TESTSI_CS) $(TESTSI_IL) $(STRESS_TESTS) *.dll *.stdout *.aotlog *.exe stest.dat