* Makefile: Don't build make-map.exe.
[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 # Can't use mkbundle on win32 since there is no static build there
291 if PLATFORM_WIN32
292 test:   testjit test-type-load test-inline-call-stack
293 else
294 test:   testjit testbundle test-type-load test-inline-call-stack
295 endif
296 endif
297
298 TestDriver.dll:
299         $(MCS) -target:library -out:$@ $(srcdir)/../mini/TestDriver.cs
300
301 test_cs: $(TEST_PROG) $(TESTSI_CS) libtest.la
302         @failed=0; \
303         passed=0; \
304         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
305         for i in $(TESTSI_CS); do       \
306                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
307                 then \
308                         passed=`expr $${passed} + 1`; \
309                 else \
310                         if [ $$? = 2 ]; then break; fi; \
311                         failed=`expr $${failed} + 1`; \
312                 fi \
313         done; \
314         echo; echo ".cs: $${passed} test(s) passed. $${failed} test(s) did not pass."; echo
315
316 test_il: $(TEST_PROG) $(TESTSI_IL) libtest.la
317         @failed=0; \
318         passed=0; \
319         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
320         for i in $(TESTSI_IL); do       \
321                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
322                 then \
323                         passed=`expr $${passed} + 1`; \
324                 else \
325                         if [ $$? = 2 ]; then break; fi; \
326                         failed=`expr $${failed} + 1`; \
327                 fi \
328         done; \
329         echo; echo ".il: $${passed} test(s) passed. $${failed} test(s) did not pass."; echo
330
331 testb: $(TEST_PROG) $(TESTBS)
332         for i in $(TESTBS); do  \
333                 $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS);     \
334         done
335
336 testjit: testjit-default testjit-net_2_0
337
338 testjit-default: $(TESTSI_CS) $(TESTSI_IL) $(TESTBS) libtest.la
339         @failed=0; \
340         passed=0; \
341         failed_tests="";\
342         for i in $(TESTSI_CS) $(TESTBS) $(TESTSI_IL); do        \
343                 rm -f $${i}.so; \
344                 if $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
345                 then \
346                         passed=`expr $${passed} + 1`; \
347                 else \
348                         if [ $$? = 2 ]; then break; fi; \
349                         failed=`expr $${failed} + 1`; \
350                         failed_tests="$${failed_tests} $$i"; \
351                 fi \
352         done; \
353         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
354         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
355           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
356
357 testjit-net_2_0: $(TESTSI_CS2) $(TESTSI_IL2) libtest.la
358         @failed=0; \
359         passed=0; \
360         failed_tests="";\
361         for i in $(TESTSI_CS2) $(TESTSI_IL2); do        \
362                 rm -f $${i}.so; \
363                 if $(srcdir)/test-driver '$(with_mono_path2) $(JITTEST_PROG_RUN)' $$i '$(DISABLED_TESTS)' $(RUNTIME_ARGS); \
364                 then \
365                         passed=`expr $${passed} + 1`; \
366                 else \
367                         if [ $$? = 2 ]; then break; fi; \
368                         failed=`expr $${failed} + 1`; \
369                         failed_tests="$${failed_tests} $$i"; \
370                 fi \
371         done; \
372         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
373         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
374           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
375
376 testaot: $(TESTSI_CS) $(TESTBS) libtest.la
377         @failed=0; \
378         passed=0; \
379         failed_tests="";\
380         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
381         for i in $(TESTSI_CS) $(TESTBS); do     \
382                 rm -f $${i}.so; \
383                 $(JITTEST_PROG_RUN) --aot $${i} > /dev/null; \
384                 if $(srcdir)/test-driver '$(with_mono_path) $(JITTEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
385                 then \
386                         passed=`expr $${passed} + 1`; \
387                 else \
388                         if [ $$? = 2 ]; then break; fi; \
389                         failed=`expr $${failed} + 1`; \
390                         failed_tests="$${failed_tests} $$i"; \
391                 fi \
392         done; \
393         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
394         if [ $$failed != 0 ]; then echo -e "\nFailed tests:\n"; \
395           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
396
397 testtrace:
398         $(MAKE) RUNTIME_ARGS="$${RUNTIME_ARGS} --trace" testjit
399
400 testinterp: $(TESTSI_CS) $(TESTSI_IL) libtest.la
401         @failed=0; \
402         passed=0; \
403         failed_tests="";\
404         export LD_LIBRARY_PATH="`pwd`/.libs:$${LD_LIBRARY_PATH}"; \
405         for i in $(TESTSI_CS) $(TESTSI_IL); do \
406                 if $(srcdir)/test-driver '$(with_mono_path) $(TEST_PROG_RUN)' $$i "$(DISABLED_TESTS)" $(RUNTIME_ARGS); \
407                 then \
408                         passed=`expr $${passed} + 1`; \
409                 else \
410                         if [ $$? = 2 ]; then break; fi; \
411                         failed=`expr $${failed} + 1`; \
412                         failed_tests="$${failed_tests} $$i"; \
413                 fi \
414         done; \
415         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
416         if [ $$failed != 0 ]; then echo -e "\nFailed tests:\n"; \
417           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
418
419 testjitspeed: $(JITTEST_PROG) $(TESTBS)
420         for i in $(TESTBS); do  \
421                 echo $$i;       \
422                 time $(JITTEST_PROG) $$i;       \
423         done
424
425 stresstest: $(STRESS_TESTS)
426         @failed=0; \
427         passed=0; \
428         failed_tests="";\
429         for i in $(STRESS_TESTS); do    \
430                 if $(srcdir)/stress-runner.pl $$i ../mini/mono $(RUNTIME_ARGS); \
431                 then \
432                         passed=`expr $${passed} + 1`; \
433                 else \
434                         if [ $$? = 2 ]; then break; fi; \
435                         failed=`expr $${failed} + 1`; \
436                         failed_tests="$${failed_tests} $$i"; \
437                 fi \
438         done; \
439         echo "$${passed} test(s) passed. $${failed} test(s) did not pass."; \
440         if [ $${failed} != 0 ]; then echo -e "\nFailed tests:\n"; \
441           for i in $${failed_tests}; do echo $${i}; done; exit 1; fi
442
443 testbundle: console.exe
444         $(MKBUNDLE) --static console.exe
445         $(with_mono_path) MONO_CFG_DIR=$(mono_cfg_dir) MONO_SHARED_DIR=$(mono_build_root)/runtime ./a.out
446         - rm -rf a.out
447
448 EXTRA_DIST += load-missing.il t-missing.cs load-exceptions.cs
449 test-type-load: TestDriver.dll
450         $(ILASM) /dll /output:load-missing.dll $(srcdir)/load-missing.il
451         $(MCS) -t:library -out:t.dll -d:FOUND $(srcdir)/t-missing.cs
452         $(MCS) -r:TestDriver.dll -r:load-missing.dll -r:t.dll -out:load-exceptions.exe $(srcdir)/load-exceptions.cs
453         $(MCS) -t:library -out:t.dll $(srcdir)/t-missing.cs
454         $(RUNTIME) load-exceptions.exe
455
456 EXTRA_DIST += test-inline-call-stack-library.cs test-inline-call-stack.cs
457 test-inline-call-stack-library.dll: TestDriver.dll $(srcdir)/test-inline-call-stack-library.cs
458         $(MCS) -t:library -out:test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack-library.cs
459 test-inline-call-stack.exe: TestDriver.dll test-inline-call-stack-library.dll $(srcdir)/test-inline-call-stack.cs
460         $(MCS) -r:TestDriver.dll -r:test-inline-call-stack-library.dll -out:test-inline-call-stack.exe $(srcdir)/test-inline-call-stack.cs
461 test-inline-call-stack: TestDriver.dll test-inline-call-stack-library.dll test-inline-call-stack.exe
462         $(RUNTIME) test-inline-call-stack.exe
463
464 # Useful if mono is compiled with --enable-shared=no
465 patch-libtool:
466         cp "../../libtool" .
467         sed -e 's,build_libtool_libs=no,build_libtool_libs=yes,g' libtool > 2; mv 2 libtool
468         sed -e 's,LIBTOOL =,LIBTOOL2 =,g' Makefile > 2 && echo "LIBTOOL = bash ./libtool" > 1 && cat 1 2 > Makefile
469         touch libtest.c
470
471 noinst_LTLIBRARIES = libtest.la
472
473 INCLUDES = $(GLIB_CFLAGS)
474
475 if PLATFORM_WIN32
476 # gcc-3.4.4 emits incorrect code when making indirect calls to stdcall functions using a tail call
477 # This shows up when compiling mono_test_marshal_delegate ()
478 libtest_la_CFLAGS=-fno-optimize-sibling-calls
479 # the exported names created by gcc for stdcall functions are missing the leading _, so MS.NET
480 # can't find them. So we use --kill-at to remove the @ suffix as well.
481 libtest_la_LDFLAGS=-no-undefined -rpath `pwd` -Wl,--kill-at
482 else
483 libtest_la_LDFLAGS = -rpath `pwd`
484 endif
485 libtest_la_SOURCES = libtest.c
486 libtest_la_LIBADD = $(GLIB_LIBS)
487
488 CLEANFILES = $(TESTSI_CS) $(TESTSI_IL) $(STRESS_TESTS) *.dll *.stdout *.exe stest.dat