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