2008-01-17 Rodrigo Kumpera <rkumpera@novell.com>
[mono.git] / mono / tests / verifier / make_access_test.sh
1 #! /bin/sh
2
3 TEST_NAME=$1
4 TEST_VALIDITY=$2
5 TEST_OP=$3
6 TEST_CLASS_ACCESS=$4
7 TEST_MEMBER_ACCESS=$5
8 TEST_EXTENDS=$6
9 TEST_USE_SUB_CLASS=$7
10
11 if [ "$TEST_EXTENDS" == "yes" ]; then
12         TEST_EXTENDS="extends Class"
13         TEST_SUPER_TYPE="Class"
14 else
15         TEST_EXTENDS="extends [mscorlib]System.Object"
16         TEST_SUPER_TYPE="object"
17 fi
18
19 if [ "$TEST_USE_SUB_CLASS" == "yes" ]; then
20         TEST_VAR_TYPE="ExampleClass"
21 else
22         TEST_VAR_TYPE="Class"
23 fi
24
25 TEST_NAME=${TEST_VALIDITY}_${TEST_NAME}
26 TEST_FILE=${TEST_NAME}_generated.il
27 echo $TEST_FILE
28 sed -e "s/SUPER_TYPE/${TEST_SUPER_TYPE}/g" -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/CLASS_ACCESS/${TEST_CLASS_ACCESS}/g" -e "s/VAR_TYPE/${TEST_VAR_TYPE}/g" -e "s/MEMBER_ACCESS/${TEST_MEMBER_ACCESS}/g" -e "s/EXTENDS/${TEST_EXTENDS}/g" > $TEST_FILE <<//EOF
29
30 .assembly '${TEST_NAME}_generated'
31 {
32   .hash algorithm 0x00008004
33   .ver  0:0:0:0
34 }
35
36 // VALIDITY CIL which breaks the ECMA-335 rules. 
37 // this CIL should fail verification by a conforming CLI verifier.
38
39 .assembly extern mscorlib
40 {
41   .ver 1:0:5000:0
42   .publickeytoken = (B7 7A 5C 56 19 34 E0 89 ) // .z\V.4..
43 }
44
45 .class CLASS_ACCESS Class extends [mscorlib]System.Object
46 {
47     .field MEMBER_ACCESS static int32 sfld
48     .field MEMBER_ACCESS int32 fld
49
50         .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed
51         {
52                 .maxstack 8
53                 ldarg.0 
54                 call instance void object::.ctor()
55                 ret
56         }
57
58     .method MEMBER_ACCESS int32 Method() {
59         ldc.i4.0
60         ret
61     }
62 }
63
64 .class ExampleClass EXTENDS
65 {
66         .method public hidebysig specialname rtspecialname instance default void .ctor () cil managed
67         {
68                 .maxstack 8
69                 ldarg.0 
70                 call instance void SUPER_TYPE::.ctor()
71                 ret
72         }
73
74         .method public static int32 Main() cil managed
75         {
76                 .entrypoint
77                 .maxstack 4
78                 newobj instance void class VAR_TYPE::.ctor()
79                 OPCODE // VALIDITY.
80                 pop
81                 ldc.i4.0
82                 ret
83         }
84 }
85 //EOF