Author: kumpera
Date: 2007-12-24 12:09:21 -0500 (Mon, 24 Dec 2007)
New Revision: 91865

Added:
   trunk/mono/mono/tests/verifier/make_switch_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-24 Rodrigo Kumpera <[EMAIL PROTECTED]>

        * make_switch_test.sh: new test generator.

        * make_exception_branch_test.sh: the filter
        handler did not pop the exception argument.

        * make_tests.sh: add tests for switch.



Modified: trunk/mono/mono/tests/verifier/ChangeLog
===================================================================
--- trunk/mono/mono/tests/verifier/ChangeLog    2007-12-24 15:40:41 UTC (rev 
91864)
+++ trunk/mono/mono/tests/verifier/ChangeLog    2007-12-24 17:09:21 UTC (rev 
91865)
@@ -1,3 +1,12 @@
+2007-12-24 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
+       * make_switch_test.sh: new test generator.
+
+       * make_exception_branch_test.sh: the filter
+       handler did not pop the exception argument.
+
+       * make_tests.sh: add tests for switch.
+
 2007-12-21 Rodrigo Kumpera <[EMAIL PROTECTED]>
 
        * make_branch_test.sh: new test generator.

Modified: trunk/mono/mono/tests/verifier/make_exception_branch_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_exception_branch_test.sh        
2007-12-24 15:40:41 UTC (rev 91864)
+++ trunk/mono/mono/tests/verifier/make_exception_branch_test.sh        
2007-12-24 17:09:21 UTC (rev 91865)
@@ -69,6 +69,7 @@
        }
 
        {
+               pop
                nop
 branch_target4:
                OPCODE5

Added: trunk/mono/mono/tests/verifier/make_switch_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_switch_test.sh  2007-12-24 15:40:41 UTC 
(rev 91864)
+++ trunk/mono/mono/tests/verifier/make_switch_test.sh  2007-12-24 17:09:21 UTC 
(rev 91865)
@@ -0,0 +1,158 @@
+#! /bin/sh
+
+TEST_NAME=$1
+TEST_VALIDITY=$2
+TEST_POS=$3
+TEST_EXTRA=$4
+TEST_OP=$5
+TEST_FIN=$6
+
+if [ "$TEST_FIN" == "" ]; then
+       TEST_FIN="finally";
+fi
+
+declare BRANCH_${TEST_POS}="$TEST_OP"
+declare BRANCH_EXTRA_${TEST_POS}="$TEST_EXTRA"
+
+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 V0, native int V1)
+ 
+       ${BRANCH_EXTRA_1}
+       ${BRANCH_1}
+        ldc.i4 0x7FFFFFFF
+       pop
+
+       ldloca 0
+       unaligned. 1
+AFTER_FIRST_PREFIX:
+       volatile.
+AFTER_SECOND_PREFIX:
+       ldind.i4
+       pop
+
+       nop
+       ldc.i4.0
+INVALID_MERGE_POINT:
+       nop
+       pop
+
+
+BLOCK_1:
+       nop
+BLOCK_1_B:
+       nop
+       .try {
+               nop
+               ${BRANCH_EXTRA_2}
+               ${BRANCH_2}
+               nop
+IN_TRY:
+
+BLOCK_2:
+               nop
+BLOCK_2_B:
+               nop
+               leave END
+       } catch [mscorlib]System.Exception {
+               pop
+               ${BRANCH_EXTRA_3}
+               ${BRANCH_3}
+               nop
+IN_CATCH:
+BLOCK_3:
+               nop
+BLOCK_3_B:
+               nop
+               leave END
+       }
+
+       .try {
+               leave END
+       } FINALLY {
+               nop
+               ${BRANCH_EXTRA_4}
+               ${BRANCH_4}
+               nop
+IN_FINALLY:
+BLOCK_4:
+               nop
+BLOCK_4_B:
+               nop
+               endfinally
+       }
+
+       .try {
+               leave END
+       } filter {
+               pop
+               nop
+               ${BRANCH_EXTRA_5}
+               ${BRANCH_5}
+               nop
+IN_FILTER:
+BLOCK_5:
+               nop
+BLOCK_5_B:
+               nop
+               ldc.i4.0
+               endfilter
+       }
+       {
+               pop
+               nop
+               ${BRANCH_EXTRA_6}
+               ${BRANCH_6}
+               nop
+IN_HANDLER:
+BLOCK_6:
+               nop
+BLOCK_6_B:
+               nop
+               leave END
+       }
+
+END:
+        ldc.i4.0
+        ret
+}
+//EOF


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

Modified: trunk/mono/mono/tests/verifier/make_tests.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_tests.sh        2007-12-24 15:40:41 UTC 
(rev 91864)
+++ trunk/mono/mono/tests/verifier/make_tests.sh        2007-12-24 17:09:21 UTC 
(rev 91865)
@@ -3297,3 +3297,51 @@
 ./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";
 
+#TODO test the encoding of the switch table
+# switch
+#valid tests
+for I in {1..6}; do
+       ./make_switch_test.sh switch_inside_same_block_${I} valid ${I} 
"ldloc.0" "switch (BLOCK_${I}, BLOCK_${I}_B)";
+done
+
+./make_switch_test.sh switch_with_native_int_on_stack valid 1 "ldloc.1" 
"switch (BLOCK_1, BLOCK_1_B)";
+
+#branching outside of the protected block
+for I in {2..6}; do
+       ./make_switch_test.sh switch_outside_protected_block_${I} unverifiable 
${I} "ldloc.0" "switch (END, BLOCK_1, BLOCK_1_B)";
+done
+
+#branching to a protected block from the outside
+for I in {2..6}; do
+       if [ "$I" == "4" ]; then
+               ./make_switch_test.sh 
switch_inside_protected_block_from_outside_${I}_finally invalid 1 "ldloc.0" 
"switch (BLOCK_${I}, BLOCK_${I}_B)" "finally";
+               ./make_switch_test.sh 
switch_inside_protected_block_from_outside_${I}_fault invalid 1 "ldloc.0" 
"switch (BLOCK_${I}, BLOCK_${I}_B)" "fault";
+       else
+               ./make_switch_test.sh 
switch_inside_protected_block_from_outside_${I} unverifiable 1 "ldloc.0" 
"switch (BLOCK_${I}, BLOCK_${I}_B)";
+       fi
+done
+
+#TODO branching out of range (FIX ilasm first)
+#./make_switch_test.sh switch_out_of_bounds_before_start invalid 1 "ldloc.0" 
"switch (-1000, -2000)"
+#./make_switch_test.sh switch_out_of_bounds_after_end invalid 1 "ldloc.0" 
"switch (BLOCK_1, 1000, 1500)"
+
+#empty stack
+./make_switch_test.sh switch_empty_stack invalid 1 "nop" "switch (BLOCK_1, 
BLOCK_1_B)"
+
+#wrong type on stack
+I=1
+for TYPE in "ldnull" "ldc.i8 0" "ldc.r4 0" "ldc.r8 0"
+do
+       ./make_switch_test.sh switch_bad_type_on_stack_${I} unverifiable 1 
"$TYPE" "switch (BLOCK_1, BLOCK_1_B)"
+       I=`expr $I + 1`
+done
+
+#switch landing in the middle of instructions
+#FIXME (ilasm don't work with offsets on switch statements)
+#./make_switch_test.sh switch_target_middle_of_instruction invalid 1 "ldloc.1" 
"switch (BLOCK_1, BLOCK_1)";
+
+./make_switch_test.sh switch_target_between_prefix_1 invalid 1 "ldloc.1" 
"switch (AFTER_FIRST_PREFIX, BLOCK_1)";
+./make_switch_test.sh switch_target_between_prefix_2 invalid 1 "ldloc.1" 
"switch (AFTER_SECOND_PREFIX, BLOCK_1)";
+./make_switch_test.sh switch_target_bad_merge_point invalid 1 "ldloc.1" 
"switch (INVALID_MERGE_POINT, BLOCK_1)";
+
+

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

Reply via email to