Author: kumpera
Date: 2008-01-23 13:06:50 -0500 (Wed, 23 Jan 2008)
New Revision: 93682

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

        * make_call_test.sh: test generator for call and callvirt.

        * make_tests.sh: added tests for call and callvirt.



Modified: trunk/mono/mono/tests/verifier/ChangeLog
===================================================================
--- trunk/mono/mono/tests/verifier/ChangeLog    2008-01-23 18:03:46 UTC (rev 
93681)
+++ trunk/mono/mono/tests/verifier/ChangeLog    2008-01-23 18:06:50 UTC (rev 
93682)
@@ -1,3 +1,9 @@
+2008-01-23 Rodrigo Kumpera <[EMAIL PROTECTED]>
+
+       * make_call_test.sh: test generator for call and callvirt.
+
+       * make_tests.sh: added tests for call and callvirt.
+
 2008-01-21 Rodrigo Kumpera <[EMAIL PROTECTED]>
 
        * invalid_ldstr_bad_token.il: added. check the index

Added: trunk/mono/mono/tests/verifier/make_call_test.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_call_test.sh    2008-01-23 18:03:46 UTC 
(rev 93681)
+++ trunk/mono/mono/tests/verifier/make_call_test.sh    2008-01-23 18:06:50 UTC 
(rev 93682)
@@ -0,0 +1,212 @@
+#! /bin/sh
+
+TEST_NAME=$1
+TEST_VALIDITY=$2
+TEST_OP=$3
+TEST_LOAD_ARGS=$4
+TEST_INSTANCE_METHOD=$5
+TEST_EXTRA_STUFF=$6
+
+if [ "$TEST_INSTANCE_METHOD" == "instance" ]; then
+       MEMBER_TEST_OP=$TEST_OP
+       MEMBER_TEST_LOAD_ARGS=$TEST_LOAD_ARGS
+       MEMBER_TEST_EXTRA_STUFF=$6
+
+       TEST_LOAD_ARGS="newobj instance void Driver::.ctor()"
+       TEST_OP="call instance void Driver::MemberMain()"
+       TEST_EXTRA_STUFF=""
+fi
+
+
+
+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/LOAD_ARGS/${TEST_LOAD_ARGS}/g" -e "s/MEMBER_OP/${MEMBER_TEST_OP}/g" -e 
"s/MEMBER_LD_ARGS/${MEMBER_TEST_LOAD_ARGS}/g" -e 
"s/EXTRA_STUFF/${TEST_EXTRA_STUFF}/g" -e "s/EXTRA/${MEMBER_TEST_EXTRA_STUFF}/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
+}
+
+.assembly extern mscorlib
+{
+  .ver 1:0:5000:0
+  .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
+}
+
+.method public static void GlobalMethod1() cil managed
+{
+       ret
+}
+
+.method public static void GlobalMethod2(int32 a) cil managed
+{
+       ret
+}
+
+.class ClassA extends [mscorlib]System.Object
+{
+       .method public hidebysig  specialname rtspecialname instance default 
void .ctor () cil managed 
+       {
+               .maxstack 8
+               ldarg.0 
+               call instance void object::.ctor()
+               ret 
+       }
+
+       .method public  void Method1() cil managed
+       {
+               ret
+       }
+
+       .method public  void Method2(int32 a) cil managed
+       {
+               ret
+       }
+
+       .method public virtual void VirtMethod() cil managed
+       {
+               ret
+       }
+}
+
+.class ClassB extends [mscorlib]System.Object
+{
+       .method public hidebysig  specialname rtspecialname instance default 
void .ctor () cil managed 
+       {
+               .maxstack 8
+               ldarg.0 
+               call instance void object::.ctor()
+               ret 
+       }
+
+}
+
+.class ClassC extends ClassA
+{
+       .method public hidebysig  specialname rtspecialname instance default 
void .ctor () cil managed 
+       {
+               .maxstack 8
+               ldarg.0 
+               call instance void ClassA::.ctor()
+               ret 
+       }
+
+       .method public virtual final void VirtMethod() cil managed
+       {
+               ret
+       }
+}
+
+.class interface abstract InterfaceA
+{
+       .method public abstract virtual instance void AbsMethod () cil managed 
+       {
+       }
+}
+
+.class ImplIfaceA extends [mscorlib]System.Object implements InterfaceA
+{
+       .method public hidebysig  specialname rtspecialname instance default 
void .ctor () cil managed 
+       {
+               .maxstack 8
+               ldarg.0 
+               call instance void object::.ctor()
+               ret 
+       }
+
+       .method public virtual instance void AbsMethod () cil managed 
+       {
+               ret
+       }
+}
+
+.class sealed MyValueType extends [mscorlib]System.ValueType
+{
+       .field private int32 v
+
+       .method public instance void Method ()
+       {
+               ret
+       }
+
+       .method public virtual instance int32 GetHashCode()
+       {
+               ldc.i4.0
+               ret
+       }
+}
+
+
+.class BaseClass extends [mscorlib]System.Object
+{
+       .method public hidebysig  specialname rtspecialname instance default 
void .ctor () cil managed 
+       {
+               .maxstack 8
+               ldarg.0 
+               call instance void object::.ctor()
+               ret 
+       }
+
+
+       .method public virtual void VirtMethod ()
+       {
+               ret
+       }
+}
+
+
+.class Driver extends BaseClass
+{
+
+       .method public virtual void VirtMethod ()
+       {
+               ret
+       }
+
+       .method public hidebysig  specialname rtspecialname instance default 
void .ctor () cil managed 
+       {
+               .maxstack 8
+               ldarg.0 
+               call instance void BaseClass::.ctor()
+               ret 
+       }
+
+       .method public void MemberMain() cil managed
+       {
+               .maxstack 8
+               .locals init (MyValueType V_0)
+
+               MEMBER_LD_ARGS
+               MEMBER_OP
+               EXTRA
+
+               ret
+       }
+
+       .method public static void Main() cil managed
+       {
+               .entrypoint
+               .maxstack 8
+               .locals init (MyValueType V_0)
+
+               .try {
+                       LOAD_ARGS
+                       OPCODE
+                       EXTRA_STUFF
+                       leave END
+               } catch [mscorlib]System.NullReferenceException {
+                       leave END
+               }
+
+END:
+               ret
+       }
+
+}
+//EOF


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

Modified: trunk/mono/mono/tests/verifier/make_tests.sh
===================================================================
--- trunk/mono/mono/tests/verifier/make_tests.sh        2008-01-23 18:03:46 UTC 
(rev 93681)
+++ trunk/mono/mono/tests/verifier/make_tests.sh        2008-01-23 18:06:50 UTC 
(rev 93682)
@@ -3915,3 +3915,95 @@
 ./make_localloc_test.sh localloc_inside_fault invalid "ldc.i4.1" "fault"
 
 
+
+
+
+
+#tests for call and callvirt
+
+#call test
+#invalid method token
+#valid
+#validate the this pointer for signatures with HASTHIS. 
+#this ptr: reference types must be a value, value type can be a MP or a BT.
+#number of args
+#args are compatible
+#method is abstract
+#calling base class constructor
+#calling a value type constructor
+#visibility
+#calling non-final virtual calls on something not a boxed valuetype, this arg 
must have THIS_POINTER_MASK and no starg.0 or ldarga.0 happens
+
+
+I=1
+for CTYPE in "call" "callvirt"
+do
+       ./make_call_test.sh call_${I}_non_virtual_1 valid "${CTYPE} instance 
void ClassA::Method1()" "newobj instance void ClassA::.ctor()"
+       ./make_call_test.sh call_${I}_non_virtual_2 valid "${CTYPE} instance 
void ClassA::Method1()" "ldnull"
+       ./make_call_test.sh call_${I}_non_virtual_3 valid "${CTYPE} instance 
void ClassA::Method2(int32)" "newobj instance void 
ClassA::.ctor()\n\t\tldc.i4.0"
+       ./make_call_test.sh call_${I}_non_virtual_underflow invalid "${CTYPE} 
instance void ClassA::Method12(int32)" "newobj instance void ClassA::.ctor()"
+       ./make_call_test.sh call_${I}_non_virtual_bad_this invalid "${CTYPE} 
instance void ClassA::Method12(int32)" "newobj instance void ClassB::.ctor()"
+
+       ./make_call_test.sh call_${I}_non_virtual_compat_this_1 valid "${CTYPE} 
instance void ClassA::Method1()" "newobj instance void ClassC::.ctor()"
+       ./make_call_test.sh call_${I}_non_virtual_compat_this_2 valid "${CTYPE} 
instance void ClassC::Method1()" "newobj instance void ClassC::.ctor()"
+       ./make_call_test.sh call_${I}_non_virtual_compat_this_3 unverifiable 
"${CTYPE} instance void ClassC::Method1()" "newobj instance void 
ClassA::.ctor()"
+
+       ./make_call_test.sh call_${I}_final_virtual_method_1 valid "${CTYPE} 
instance void ClassC::VirtMethod()" "newobj instance void ClassC::.ctor()"
+
+       ./make_call_test.sh call_${I}_virtual_method_1 valid "${CTYPE} instance 
void Driver::VirtMethod()" "ldarg.0" "instance"
+       ./make_call_test.sh call_${I}_virtual_method_2 valid "${CTYPE} instance 
void BaseClass::VirtMethod()" "ldarg.0" "instance"
+
+       I=`expr $I + 1`
+done
+
+
+#tests for call only
+./make_call_test.sh call_global_1 valid "call void GlobalMethod1()"
+./make_call_test.sh call_global_2 valid "call void GlobalMethod2(int32)" 
"ldc.i4.0"
+./make_call_test.sh call_global_underflow invalid "call void 
GlobalMethod2(int32)" ""
+./make_call_test.sh call_abstract_method unverifiable "call instance void 
InterfaceA::AbsMethod()" "newobj instance void ImplIfaceA::.ctor()"
+./make_call_test.sh call_final_virtual_method_2 unverifiable "call instance 
void ClassC::VirtMethod()" "newobj instance void ClassA::.ctor()"
+./make_call_test.sh call_final_virtual_method_3 unverifiable "call instance 
void ClassA::VirtMethod()" "newobj instance void ClassA::.ctor()"
+
+./make_call_test.sh call_virtual_method_3 unverifiable "call instance void 
BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarg.0\n\t\tstarg 0" 
+./make_call_test.sh call_virtual_method_4 unverifiable "call instance void 
BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarga 0\n\t\tpop"
+
+#value type (we can call non final virtual on boxed VT)
+./make_call_test.sh call_valuetype_1 valid "call instance void 
MyValueType::Method()" "ldloca 0"
+./make_call_test.sh call_valuetype_2 unverifiable "call instance void 
MyValueType::Method()" "ldloc.0\n\t\tbox MyValueType"
+./make_call_test.sh call_valuetype_3 unverifiable "call instance void 
MyValueType::Method()" "ldloc.0"
+
+./make_call_test.sh call_valuetype_4 unverifiable "call instance int32 
[mscorlib]System.ValueType::GetHashCode()" "ldloca 0" "static" "pop"
+./make_call_test.sh call_valuetype_5 valid "call instance int32 
MyValueType::GetHashCode()" "ldloca 0" "static" "pop"
+
+./make_call_test.sh call_valuetype_6 valid "call instance int32 
[mscorlib]System.ValueType::GetHashCode()"  "ldloc.0\n\t\tbox MyValueType" 
"static" "pop"
+./make_call_test.sh call_valuetype_7 valid "call instance bool 
object::Equals(object)" "ldloc.0\n\t\tbox MyValueType\n\t\tldnull" "static" 
"pop"
+
+./make_call_test.sh call_valuetype_8 valid "call instance int32 
[mscorlib]System.Object::GetHashCode()"  "ldloc.0\n\t\tbox MyValueType" 
"static" "pop"
+
+#tests for callvirt only
+#FIXME ilasm encode the signature with instance even if it doesn't state so.
+#./make_call_test.sh call_virt_global_1 invalid "callvirt void GlobalMethod1()"
+
+./make_call_test.sh callvirt_abstract_method valid "callvirt instance void 
InterfaceA::AbsMethod()" "newobj instance void ImplIfaceA::.ctor()"
+./make_call_test.sh callvirt_final_virtual_method_2 unverifiable "callvirt 
instance void ClassC::VirtMethod()" "newobj instance void ClassA::.ctor()"
+./make_call_test.sh callvirt_final_virtual_method_3 valid "callvirt instance 
void ClassA::VirtMethod()" "newobj instance void ClassA::.ctor()"
+
+./make_call_test.sh callvirt_virtual_method_3 valid "callvirt instance void 
BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarg.0\n\t\tstarg 0" 
+./make_call_test.sh callvirt_virtual_method_4 valid "callvirt instance void 
BaseClass::VirtMethod()" "ldarg.0" "instance" "ldarga 0\n\t\tpop"
+
+#value type (we can call non final virtual on boxed VT)
+./make_call_test.sh callvirt_valuetype_1 unverifiable "callvirt instance void 
MyValueType::Method()" "ldloca 0"
+./make_call_test.sh callvirt_valuetype_2 unverifiable "callvirt instance void 
MyValueType::Method()" "ldloc.0\n\t\tbox MyValueType"
+./make_call_test.sh callvirt_valuetype_3 unverifiable "callvirt instance void 
MyValueType::Method()" "ldloc.0"
+
+./make_call_test.sh callvirt_valuetype_4 unverifiable "callvirt instance int32 
[mscorlib]System.ValueType::GetHashCode()" "ldloca 0" "static" "pop"
+./make_call_test.sh callvirt_valuetype_5 unverifiable "callvirt instance int32 
MyValueType::GetHashCode()" "ldloca 0" "static" "pop"
+
+./make_call_test.sh callvirt_valuetype_6 valid "callvirt instance int32 
[mscorlib]System.ValueType::GetHashCode()"  "ldloc.0\n\t\tbox MyValueType" 
"static" "pop"
+./make_call_test.sh callvirt_valuetype_7 valid "callvirt instance bool 
object::Equals(object)" "ldloc.0\n\t\tbox MyValueType\n\t\tldnull" "static" 
"pop"
+./make_call_test.sh callvirt_valuetype_8 valid "callvirt instance int32 
[mscorlib]System.Object::GetHashCode()"  "ldloc.0\n\t\tbox MyValueType" 
"static" "pop"
+
+
+
+

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

Reply via email to