Author: kumpera
Date: 2008-01-17 11:51:24 -0500 (Thu, 17 Jan 2008)
New Revision: 93173

Added:
   trunk/mono/mono/tests/verifier/make_localloc_test.sh
Modified:
   trunk/mono/mono/tests/verifier/ChangeLog
   trunk/mono/mono/tests/verifier/make_tests.sh
Log:
2008-01-17 Rodrigo Kumpera <[EMAIL PROTECTED]>

        * make_localloc_test.sh: test generator for localloc.

        * make_tests.sh: added tests for localloc.





Modified: trunk/mono/mono/tests/verifier/ChangeLog
===================================================================
--- trunk/mono/mono/tests/verifier/ChangeLog    2008-01-17 16:49:43 UTC (rev 
93172)
+++ trunk/mono/mono/tests/verifier/ChangeLog    2008-01-17 16:51:24 UTC (rev 
93173)
@@ -1,5 +1,11 @@
 2008-01-17 Rodrigo Kumpera <[EMAIL PROTECTED]>
 
+       * make_localloc_test.sh: test generator for localloc.
+
+       * make_tests.sh: added tests for localloc.
+
+2008-01-17 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
        * make_sizeof_test.sh: test generator for sizeof.
 
        * make_tests.sh: added tests for sizeof.

Added: trunk/mono/mono/tests/verifier/make_localloc_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_localloc_test.sh        2008-01-17 
16:49:43 UTC (rev 93172)
+++ trunk/mono/mono/tests/verifier/make_localloc_test.sh        2008-01-17 
16:51:24 UTC (rev 93173)
@@ -0,0 +1,105 @@
+#! /bin/sh
+
+TEST_NAME=$1
+TEST_VALIDITY=$2
+TEST_INIT=$3
+TEST_BLOCK=$4
+
+TRY_END="
+               leave END
+       } catch [mscorlib]System.NullReferenceException {
+               leave END
+       }"
+
+if [ "$TEST_BLOCK" == "catch" ]; then
+       TRY_MIDDLE="
+               leave END
+       } catch [mscorlib]System.NullReferenceException {"
+       TRY_END="
+               leave END
+       }"
+elif [ "$TEST_BLOCK" == "filter" ]; then
+       TRY_MIDDLE="
+               leave END
+       } filter {"
+       TRY_END="
+               pop
+               ldc.i4.0
+               endfilter
+       } {
+               leave END
+       }"
+elif [ "$TEST_BLOCK" == "handler" ]; then
+       TRY_MIDDLE="
+               leave END
+       } filter {
+               pop
+               ldc.i4.0
+               endfilter
+       } {"
+       TRY_END="
+               leave END
+       }"
+elif [ "$TEST_BLOCK" == "finally" ]; then
+       TRY_MIDDLE="
+               leave END
+       } finally {"
+       TRY_END="
+               endfinally
+       }"
+elif [ "$TEST_BLOCK" == "fault" ]; then
+       TRY_MIDDLE="
+               leave END
+       } fault {"
+       TRY_END="
+               endfault
+       }"
+fi
+
+
+TEST_FILE=`echo ${TEST_VALIDITY}_${TEST_NAME} | sed -e 's/ /_/g' -e 's/\./_/g' 
-e 's/&/mp/g' -e 's/\[/_/g' -e 's/\]/_/g'`_generated.il
+echo $TEST_FILE
+TEST_TYPE1=`echo $TEST_TYPE1 | sed -s 's/&/\\\&/'`
+
+sed -e "s/OPCODE/${TEST_OP}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e 
"s/INIT/${TEST_INIT}/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 public Template\`1<T>
+       extends [mscorlib]System.Object
+{
+}
+
+.class public auto ansi sealed MyStruct
+       extends [mscorlib]System.ValueType
+{
+    .field public int32 valid
+}
+
+.method public static int32 Main() cil managed
+{
+       .entrypoint
+       .maxstack 5
+       .locals init (native int V_0, int32 V_1)
+
+       .try {
+               nop
+${TRY_MIDDLE}
+               INIT
+               localloc
+               stloc.0
+
+${TRY_END}
+
+END:
+       ldc.i4.0
+       ret
+}
+//EOF


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

Modified: trunk/mono/mono/tests/verifier/make_tests.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_tests.sh        2008-01-17 16:49:43 UTC 
(rev 93172)
+++ trunk/mono/mono/tests/verifier/make_tests.sh        2008-01-17 16:51:24 UTC 
(rev 93173)
@@ -3876,4 +3876,32 @@
 done
 
 
+#localloc
 
+#valid types
+I=1
+for INIT in "ldc.i4.1" "ldc.i4.1\n\tconv.i" 
+do
+       ./make_localloc_test.sh localloc_stack_type_$I unverifiable "$INIT"
+       I=`expr $I + 1`
+done
+
+#these types should be invalid
+for INIT in "ldc.i8 2" "ldc.r4 2.2" "ldc.r8 2.2" "ldloca 1"
+do
+       ./make_localloc_test.sh localloc_stack_type_$I unverifiable "$INIT"
+       I=`expr $I + 1`
+done
+
+#stack underflow
+./make_localloc_test.sh localloc_empty_stack invalid 
+./make_localloc_test.sh localloc_stack_with_more_than_2_items invalid 
"ldc.i4.1\n\tldc.i4.1"
+
+#inside exception blocks
+./make_localloc_test.sh localloc_inside_catch_handler invalid "ldc.i4.1" 
"catch"
+./make_localloc_test.sh localloc_inside_filter invalid "ldc.i4.1" "filter"
+./make_localloc_test.sh localloc_inside_handler invalid "ldc.i4.1" "handler"
+./make_localloc_test.sh localloc_inside_finally invalid "ldc.i4.1" "finally"
+./make_localloc_test.sh localloc_inside_fault invalid "ldc.i4.1" "fault"
+
+

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

Reply via email to