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