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