2008-05-01 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / tests / verifier / Makefile
index 7105be578a8dc9c5709a5f1390034ad49a5dbd6c..fcfa0a82441368335bbc2d24c9a2758e6d34296c 100644 (file)
@@ -1,38 +1,83 @@
 
 %.exe: %.cil
-       ilasm -out:$@ $<
+       ilasm2 -out:$@ $<
 
-compile-stamp: generate-stamp
-       for i in *.il; do ilasm $$i; done
+BatchCompiler.exe: BatchCompiler.cs
+       gmcs -r:../../../../mcs/class/lib/net_2_0/ilasm.exe BatchCompiler.cs
+
+compile-stamp: generate-stamp BatchCompiler.exe
+       for i in *.cs; do \
+               EXE="`echo $$i | cut -d. -f1`.exe"; \
+               if ! [ -f $$EXE ]; then \
+                       gmcs /unsafe $$i; \
+               fi \
+       done 
+       MONO_PATH=../../../../mcs/class/lib/net_2_0/ mono BatchCompiler.exe
        touch compile-stamp
 
 clean:
-       rm -f *_generated.il *.exe *.dll generate-stamp compile-stamp
+       for i in *generated*; do rm $$i; done
+       for i in *.exe; do rm $$i; done
+       rm generate-stamp compile-stamp
 
 generate-stamp: make_tests.sh make_bin_test.sh make_exception_branch_test.sh make_obj_store_test.sh \
                make_stack_0_pop_test.sh make_stack_0_test.sh make_stack_1_pop_test.sh \
-               make_stack_merge_test.sh make_store_test.sh make_unary_test.sh
+               make_stack_merge_test.sh make_store_test.sh make_unary_test.sh 
        ./make_tests.sh
        touch generate-stamp
 
 test: compile-stamp run-test
 
-run-test:
+run-test: compile-stamp
        @for i in *.exe; do \
-               echo -n $$i; \
-               mono $$i >/dev/null 2>/dev/null; \
-               RES=$$?; \
-               if [ $$RES = 1 ]; \
+               TEST=`echo $$i | cut -d '.' -f 1`; \
+               RES=99; \
+               FIRST=`echo $$i | cut -d '_' -f 1`; \
+               if [ "$$FIRST" == "invalid" ]; \
+               then \
+                       RES=3; \
+               fi; \
+               if [ "$$FIRST" == "unverifiable" ] || [ "$FIRST" == "typeunverifiable" ]; \
                then \
-                       echo " OK"; \
+                       RES=2; \
                fi; \
-               if [ $$RES = 0 ]; \
+               if [ "$$FIRST" == "valid" ]; \
                then \
-                       echo " NOT OK (silent success)"; \
+                       RES=0; \
                fi; \
-               if [ $$RES '>' 1 ]; \
+               if [ "$$FIRST" == "strict" ]; \
                then \
-                       echo " NOT OK (other failure)"; \
+                       #in strict more it must fail under strict check and pass under non-strict check \
+                       ../../metadata/pedump --verify error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
+                       R1=$$?; \
+                       ../../metadata/pedump --verify error,warn,cls,code,non-strict $$TEST.exe >/dev/null 2>/dev/null; \
+                       R2=$$?; \
+                       if [ $$R1 != 2 ] && [ $$R1 != 3 ]; then \
+                               echo "$$TEST is strict but did not fail under strict check, got $${R1} but expected 2 or 3"; \
+                       fi \
+                       #non-strict result \
+                       if [ $$R2 != 0 ]; then \
+                               echo "$$TEST is strict but did not pass under non-strict check, got $${R2} but expected 0"; \
+                       fi \
+               elif [ "$$FIRST" == "typeunverifiable" ]; then \
+                       #in type unverifiable more it must fail under verifiable mode but it's ok under valid mode \
+                       ../../metadata/pedump --verify error,warn,cls,code $$TEST.exe  >/dev/null 2>/dev/null; \
+                       R1=$$?; \
+                       ../../metadata/pedump --verify error,warn,cls,code,valid-only $$TEST.exe  >/dev/null 2>/dev/null; \
+                       R2=$$?; \
+                       if [ $$R1 != 3 ]; then \
+                               echo "$$TEST is type unverifiable but did not fail under verifiable check, got $${R1} but expected 3"; \
+                       fi \
+                       #type unverifiable result \
+                       if [ $$R2 != 0 ]; then \
+                               echo "$$TEST is type unverifiable but did not pass under non-strict check, got $${R2} but expected 0"; \
+                       fi \
+               elif [ $RES != 99 ]; then \
+                       ../../metadata/pedump --verify error,warn,cls,code $$TEST.exe >/dev/null 2>/dev/null; \
+                       R=$$?; \
+                       if [ $$R != $$RES ]; then \
+                               echo "$$TEST failed expected $$RES but got $$R"; \
+                       fi \
                fi; \
        done