Author: kumpera
Date: 2007-12-21 14:04:20 -0500 (Fri, 21 Dec 2007)
New Revision: 91782

Added:
   trunk/mono/mono/tests/verifier/make_branch_test.sh
Modified:
   trunk/mono/mono/tests/verifier/ChangeLog
   trunk/mono/mono/tests/verifier/make_exception_branch_test.sh
   trunk/mono/mono/tests/verifier/make_tests.sh
Log:
2007-12-21 Rodrigo Kumpera <[EMAIL PROTECTED]>

        * make_branch_test.sh: new test generator.

        * make_exception_branch_test.sh: added
        support to test generator to specify
        the expected result.

        * make_tests.sh: some results for
        make_exception_branch_test.sh were
        wrong, fixed that.

        * make_tests.sh: added some tests
        to beq and bge.

        * make_tests.sh added tests for br.

        * valid_exception_sequence.il: new test


Modified: trunk/mono/mono/tests/verifier/ChangeLog
===================================================================
--- trunk/mono/mono/tests/verifier/ChangeLog    2007-12-21 18:57:34 UTC (rev 
91781)
+++ trunk/mono/mono/tests/verifier/ChangeLog    2007-12-21 19:04:20 UTC (rev 
91782)
@@ -1,6 +1,23 @@
+2007-12-21 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
+       * make_branch_test.sh: new test generator.
+
+       * make_exception_branch_test.sh: added
+       support to test generator to specify
+       the expected result.
+
+       * make_tests.sh: some results for
+       make_exception_branch_test.sh were
+       wrong, fixed that.
+
+       * make_tests.sh: added some tests
+       to beq and bge.
+
+       * make_tests.sh added tests for br.
+
 2007-12-20 Rodrigo Kumpera <[EMAIL PROTECTED]>
 
-       *valid_exception_sequence.il: new test
+       * valid_exception_sequence.il: new test
        for what blocks take an exception on
        stack at the begin.
 

Added: trunk/mono/mono/tests/verifier/make_branch_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_branch_test.sh  2007-12-21 18:57:34 UTC 
(rev 91781)
+++ trunk/mono/mono/tests/verifier/make_branch_test.sh  2007-12-21 19:04:20 UTC 
(rev 91782)
@@ -0,0 +1,130 @@
+#! /bin/sh
+
+TEST_NAME=$1
+TEST_VALIDITY=$2
+TEST_POS=$3
+TEST_OP=$4
+TEST_FIN=$5
+
+if [ "$TEST_FIN" == "" ]; then
+       TEST_FIN="finally";
+fi
+
+declare BRANCH_${TEST_POS}="$TEST_OP"
+
+TEST_NAME=${TEST_VALIDITY}_${TEST_NAME}
+TEST_FILE=${TEST_NAME}_generated.il
+echo $TEST_FILE
+
+sed -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e 
"s/FINALLY/${TEST_FIN}/g" > $TEST_FILE <<//EOF
+
+// VALIDITY CIL which breaks the ECMA-335 rules. 
+// this CIL should fail verification by a conforming CLI verifier.
+
+.assembly '${TEST_NAME}_generated'
+{
+  .hash algorithm 0x00008004
+  .ver  0:0:0:0
+}
+
+.class ClassA
+       extends [mscorlib]System.Object
+{
+}
+
+.class sealed MyValueType
+       extends [mscorlib]System.ValueType
+{
+       .field private int32 v
+}
+
+.class public Template\`1<T>
+       extends [mscorlib]System.Object
+{
+}
+
+.class sealed public ValueTypeTemplate\`1<T>
+       extends [mscorlib]System.ValueType
+{
+       .field private int32 v
+}
+
+.method public static int32 Main() cil managed
+{
+        .entrypoint
+        .maxstack 8
+       .locals init ( int32 BLA)
+ 
+       ${BRANCH_1}
+        ldc.i4 0x7FFFFFFF
+       pop
+
+       ldloca 0
+       unaligned. 1
+AFTER_FIRST_PREFIX:
+       volatile.
+AFTER_SECOND_PREFIX:
+       ldind.i4
+       pop
+
+
+BLOCK_1:
+       nop
+       .try {
+               nop
+               ${BRANCH_2}
+               nop
+IN_TRY:
+BLOCK_2:
+               leave END
+       } catch [mscorlib]System.Exception {
+               pop
+               ${BRANCH_3}
+               nop
+IN_CATCH:
+BLOCK_3:
+               nop
+               leave END
+       }
+
+       .try {
+               leave END
+       } FINALLY {
+               nop
+               ${BRANCH_4}
+               nop
+IN_FINALLY:
+BLOCK_4:
+               nop
+               endfinally
+       }
+
+       .try {
+               leave END
+       } filter {
+               pop
+               nop
+               ${BRANCH_5}
+               nop
+IN_FILTER:
+BLOCK_5:
+               nop
+               ldc.i4.0
+               endfilter
+       }
+       {
+               pop
+               nop
+               ${BRANCH_6}
+               nop
+IN_HANDLER:
+BLOCK_6:
+               nop
+               leave END
+       }
+
+END:
+        ldc.i4.0
+        ret
+}
+//EOF


Property changes on: trunk/mono/mono/tests/verifier/make_branch_test.sh
___________________________________________________________________
Name: svn:executable
   + *

Modified: trunk/mono/mono/tests/verifier/make_exception_branch_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_exception_branch_test.sh        
2007-12-21 18:57:34 UTC (rev 91781)
+++ trunk/mono/mono/tests/verifier/make_exception_branch_test.sh        
2007-12-21 19:04:20 UTC (rev 91782)
@@ -1,19 +1,19 @@
 #! /bin/sh
 
 TEST_NAME=$1
+TEST_VALIDITY=$2
 
 # Only 1 TEST_OP variable should be set.
+TEST_OP1=$3
+TEST_OP2=$4
+TEST_OP3=$5
+TEST_OP4=$6
+TEST_OP5=$7
 
-TEST_OP1=$2
-TEST_OP2=$3
-TEST_OP3=$4
-TEST_OP4=$5
-TEST_OP5=$6
-
-TEST_FILE=invalid_exception_branch_${TEST_NAME}_generated.il
+TEST_FILE=${TEST_VALIDITY}_exception_branch_${TEST_NAME}_generated.il
 echo $TEST_FILE
 sed -e "s/OPCODE1/${TEST_OP1}/g" -e "s/OPCODE2/${TEST_OP2}/g" -e 
"s/OPCODE3/${TEST_OP3}/g" -e "s/OPCODE4/${TEST_OP4}/g" -e 
"s/OPCODE5/${TEST_OP5}/g" > $TEST_FILE <<//EOF
-// invalid CIL which breaks the ECMA-335 rules. 
+// ${TEST_VALIDITY} CIL which breaks the ECMA-335 rules. 
 // This CIL should fail verification by a conforming CLI verifier.
 
 .assembly '${TEST_NAME}_generated'
@@ -25,7 +25,10 @@
 .method public static int32 Main() cil managed
 {
        .entrypoint
-       .maxstack 2
+       .maxstack 8
+       .locals init (int32 V0,
+               int32 V1)
+
        OPCODE1
        .try
        {

Modified: trunk/mono/mono/tests/verifier/make_tests.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_tests.sh        2007-12-21 18:57:34 UTC 
(rev 91781)
+++ trunk/mono/mono/tests/verifier/make_tests.sh        2007-12-21 19:04:20 UTC 
(rev 91782)
@@ -807,22 +807,36 @@
 I=1
 for OP in br "ldc.i4.0\n\tbrfalse"
 do
-  ./make_exception_branch_test.sh in_try_${I} "$OP branch_target1"
-  ./make_exception_branch_test.sh in_catch_${I} "$OP branch_target2"
-  ./make_exception_branch_test.sh in_finally_${I} "$OP branch_target3"
-  ./make_exception_branch_test.sh in_filter_${I} "$OP branch_target4"
-  ./make_exception_branch_test.sh out_try_${I} "" "$OP branch_target5"
-  ./make_exception_branch_test.sh out_catch_${I} "" "" "$OP branch_target5"
-  ./make_exception_branch_test.sh out_finally_${I} "" "" "" "$OP 
branch_target5"
-  ./make_exception_branch_test.sh out_filter_${I} "" "" "" "" "$OP 
branch_target5"
+  ./make_exception_branch_test.sh in_try_${I} unverifiable "$OP branch_target1"
+  ./make_exception_branch_test.sh in_catch_${I} unverifiable "$OP 
branch_target2"
+  ./make_exception_branch_test.sh in_finally_${I} invalid "$OP branch_target3"
+  ./make_exception_branch_test.sh in_filter_${I} unverifiable "$OP 
branch_target4"
+  ./make_exception_branch_test.sh out_try_${I} unverifiable "" "$OP 
branch_target5"
+  ./make_exception_branch_test.sh out_catch_${I} unverifiable "" "" "$OP 
branch_target5"
+  ./make_exception_branch_test.sh out_finally_${I} unverifiable "" "" "" "$OP 
branch_target5"
+  ./make_exception_branch_test.sh out_filter_${I} unverifiable "" "" "" "" 
"$OP branch_target5"
   I=`expr $I + 1`
 done
 
-./make_exception_branch_test.sh ret_out_try "" "ldc.i4.0\n\tret"
-./make_exception_branch_test.sh ret_out_catch "" "" "ldc.i4.0\n\tret"
-./make_exception_branch_test.sh ret_out_finally "" "" "" "ldc.i4.0\n\tret"
-./make_exception_branch_test.sh ret_out_filter "" "" "" "" "ldc.i4.0\n\tret"
+for OP in "ldloc.0\n\tldloc.1\n\tbeq" "ldloc.0\n\tldloc.1\n\tbge"
+do
+  ./make_exception_branch_test.sh in_try_${I} invalid "$OP branch_target1"
+  ./make_exception_branch_test.sh in_catch_${I} invalid "$OP branch_target2"
+  ./make_exception_branch_test.sh in_finally_${I} invalid "$OP branch_target3"
+  ./make_exception_branch_test.sh in_filter_${I} invalid "$OP branch_target4"
+  ./make_exception_branch_test.sh out_try_${I} invalid "" "$OP branch_target5"
+  ./make_exception_branch_test.sh out_catch_${I} invalid "" "" "$OP 
branch_target5"
+  ./make_exception_branch_test.sh out_finally_${I} unverifiable "" "" "" "$OP 
branch_target5"
+  ./make_exception_branch_test.sh out_filter_${I} unverifiable "" "" "" "" 
"$OP branch_target5"
+  I=`expr $I + 1`
+done
 
+./make_exception_branch_test.sh ret_out_try unverifiable "" "ldc.i4.0\n\tret"
+./make_exception_branch_test.sh ret_out_catch unverifiable "" "" 
"ldc.i4.0\n\tret"
+./make_exception_branch_test.sh ret_out_finally unverifiable "" "" "" 
"ldc.i4.0\n\tret"
+./make_exception_branch_test.sh ret_out_filter unverifiable "" "" "" "" 
"ldc.i4.0\n\tret"
+
+
 # Unary branch op type tests (see 3.17)
 
 for OP in brfalse
@@ -3248,3 +3262,38 @@
 ./make_leave_test.sh "filter_branch_before_start" invalid "1" "leave -400" 
"$EXTRA"
 ./make_leave_test.sh "filter_branch_after_end" invalid "1" "leave 400" "$EXTRA"
 
+
+# br.X
+#valid tests
+for I in {1..6}; do
+       ./make_branch_test.sh branch_inside_same_block_${I} valid ${I} "br 
BLOCK_${I}";
+       ./make_branch_test.sh branch_inside_same_block_${I}_s valid ${I} "br.s 
BLOCK_${I}";
+done
+
+#branching outside of the protected block
+for I in {2..6}; do
+       ./make_branch_test.sh branch_outside_protected_block_${I} unverifiable 
${I} "br END";
+done
+
+#branching to a protected block from the outside
+for I in {2..6}; do
+       if [ "$I" == "4" ]; then
+               ./make_branch_test.sh 
branch_inside_protected_block_from_outside_${I}_finally invalid 1 "br 
BLOCK_${I}" "finally";
+               ./make_branch_test.sh 
branch_inside_protected_block_from_outside_${I}_fault invalid 1 "br BLOCK_${I}" 
"fault";
+       else
+               ./make_branch_test.sh 
branch_inside_protected_block_from_outside_${I} unverifiable 1 "br BLOCK_${I}";
+       fi
+done
+
+
+#branching out of range
+./make_branch_test.sh branch_out_of_bounds_before_start invalid 1 "br -1000";
+./make_branch_test.sh branch_out_of_bounds_after_end invalid 1 "br 1000";
+
+#branching in the middle of an instruction
+./make_branch_test.sh branch_middle_of_instruction invalid 1 "br 2";
+
+#branching in between prefix and instruction 
+./make_branch_test.sh branch_middle_of_instruction_prefix_1 invalid 1 "br 
AFTER_FIRST_PREFIX";
+./make_branch_test.sh branch_middle_of_instruction_prefix_2 invalid 1 "br 
AFTER_SECOND_PREFIX";
+

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to