Merge branch 'master' of github.com:mono/mono
[mono.git] / mono / tests / verifier / Makefile
1
2 %.exe: %.cil
3         ilasm2 -out:$@ $<
4
5 BatchCompiler.exe: BatchCompiler.cs
6         gmcs -r:../../../mcs/class/lib/net_2_0/ilasm.exe BatchCompiler.cs
7
8 test_lib.dll: test_lib.cs
9         gmcs test_lib.cs -target:library
10
11 compile-stamp: generate-stamp BatchCompiler.exe test_lib.dll
12         for i in *.cs; do \
13                 EXE="`echo $$i | cut -d. -f1`.exe"; \
14                 DLL="`echo $$i | cut -d. -f1`.dll"; \
15                 if ! [ -f $$EXE ] && ! [ -f $$DLL ]; then \
16                         gmcs /unsafe $$i; \
17                 fi \
18         done 
19         MONO_PATH=../../../mcs/class/lib/net_2_0/ mono BatchCompiler.exe
20         #for $$I in *.il; do ilasm2 $$I; done
21         touch compile-stamp
22
23 clean:
24         for i in *generated*; do rm $$i; done
25         for i in *.exe; do rm $$i; done
26         rm generate-stamp compile-stamp
27
28 generate-stamp: make_tests.sh make_bin_test.sh make_exception_branch_test.sh make_obj_store_test.sh \
29                 make_stack_0_pop_test.sh make_stack_0_test.sh make_stack_1_pop_test.sh \
30                 make_stack_merge_test.sh make_store_test.sh make_unary_test.sh 
31         ./make_tests.sh
32         touch generate-stamp
33
34 test: compile-stamp run-test
35
36 run-test: compile-stamp
37         @for i in *.exe; do \
38                 TEST=`echo $$i | cut -d '.' -f 1`; \
39                 RES=99; \
40                 FIRST=`echo $$i | cut -d '_' -f 1`; \
41                 if [ "$$FIRST" == "invalid" ]; \
42                 then \
43                         RES=3; \
44                 fi; \
45                 if [ "$$FIRST" == "unverifiable" ] || [ "$FIRST" == "typeunverifiable" ]; \
46                 then \
47                         RES=2; \
48                 fi; \
49                 if [ "$$FIRST" == "badmd" ]; \
50                 then \
51                         RES=1; \
52                 fi; \
53                 if [ "$$FIRST" == "valid" ]; \
54                 then \
55                         RES=0; \
56                 fi; \
57                 if [ "$$FIRST" == "strict" ]; \
58                 then \
59                         #in strict more it must fail under strict check and pass under non-strict check \
60                         ../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
61                         R1=$$?; \
62                         ../../metadata/pedump --verify partial-md,error,warn,cls,code,non-strict $$TEST.exe >/dev/null 2>/dev/null; \
63                         R2=$$?; \
64                         if [ $$R1 != 2 ] && [ $$R1 != 3 ]; then \
65                                 echo "$$TEST is strict but did not fail under strict check, got $${R1} but expected 2 or 3"; \
66                         fi \
67                         #non-strict result \
68                         if [ $$R2 != 0 ]; then \
69                                 echo "$$TEST is strict but did not pass under non-strict check, got $${R2} but expected 0"; \
70                         fi \
71                 elif [ "$$FIRST" == "typeunverifiable" ]; then \
72                         #in type unverifiable more it must fail under verifiable mode but it's ok under valid mode \
73                         ../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe  >/dev/null 2>/dev/null; \
74                         R1=$$?; \
75                         ../../metadata/pedump --verify partial-md,error,warn,cls,code,valid-only $$TEST.exe  >/dev/null 2>/dev/null; \
76                         R2=$$?; \
77                         if [ $$R1 != 3 ]; then \
78                                 echo "$$TEST is type unverifiable but did not fail under verifiable check, got $${R1} but expected 3"; \
79                         fi \
80                         #type unverifiable result \
81                         if [ $$R2 != 0 ]; then \
82                                 echo "$$TEST is type unverifiable but did not pass under non-strict check, got $${R2} but expected 0"; \
83                         fi \
84                 elif [ $$RES != 99 ]; then \
85                         ../../metadata/pedump --verify partial-md,error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
86                         R=$$?; \
87                         if [ $$R != $$RES ]; then \
88                                 echo "$$TEST failed expected $$RES but got $$R"; \
89                         fi \
90                 fi; \
91         done
92