Merge pull request #2863 from alexrp/windows-critsect-debug-info
[mono.git] / mono / tests / verifier / make_switch_test.sh
1 #! /bin/sh
2
3 SED="sed"
4 if [ `which gsed 2> /dev/null` ] ; then 
5         SED="gsed"
6 fi
7
8 TEST_NAME=$1
9 TEST_VALIDITY=$2
10 TEST_POS=$3
11 TEST_EXTRA=$4
12 TEST_OP=$5
13 TEST_FIN=$6
14
15 if [ "x$TEST_FIN" = "x" ]; then
16         TEST_FIN="finally";
17 fi
18
19 declare BRANCH_${TEST_POS}="$TEST_OP"
20 declare BRANCH_EXTRA_${TEST_POS}="$TEST_EXTRA"
21
22 TEST_NAME=${TEST_VALIDITY}_${TEST_NAME}
23 TEST_FILE=${TEST_NAME}_generated.il
24 echo $TEST_FILE
25
26 $SED -e "s/VALIDITY/${TEST_VALIDITY}/g" -e "s/OPCODE/${TEST_OP}/g" -e "s/FINALLY/${TEST_FIN}/g" > $TEST_FILE <<//EOF
27
28 // VALIDITY CIL which breaks the ECMA-335 rules. 
29 // this CIL should fail verification by a conforming CLI verifier.
30
31 .assembly '${TEST_NAME}_generated'
32 {
33   .hash algorithm 0x00008004
34   .ver  0:0:0:0
35 }
36
37 .class ClassA
38         extends [mscorlib]System.Object
39 {
40 }
41
42 .class sealed MyValueType
43         extends [mscorlib]System.ValueType
44 {
45         .field private int32 v
46 }
47
48 .class public Template\`1<T>
49         extends [mscorlib]System.Object
50 {
51 }
52
53 .class sealed public ValueTypeTemplate\`1<T>
54         extends [mscorlib]System.ValueType
55 {
56         .field private int32 v
57 }
58
59 .method public static int32 Main() cil managed
60 {
61         .entrypoint
62         .maxstack 8
63         .locals init ( int32 V0, native int V1)
64  
65         ${BRANCH_EXTRA_1}
66         ${BRANCH_1}
67         ldc.i4 0x7FFFFFFF
68         pop
69
70         ldloca 0
71         unaligned. 1
72 AFTER_FIRST_PREFIX:
73         volatile.
74 AFTER_SECOND_PREFIX:
75         ldind.i4
76         pop
77
78         nop
79         ldc.i4.0
80 INVALID_MERGE_POINT:
81         nop
82         pop
83
84
85 BLOCK_1:
86         nop
87 BLOCK_1_B:
88         nop
89         .try {
90                 nop
91                 ${BRANCH_EXTRA_2}
92                 ${BRANCH_2}
93                 nop
94 IN_TRY:
95
96 BLOCK_2:
97                 nop
98 BLOCK_2_B:
99                 nop
100                 leave END
101         } catch [mscorlib]System.Exception {
102                 pop
103                 ${BRANCH_EXTRA_3}
104                 ${BRANCH_3}
105                 nop
106 IN_CATCH:
107 BLOCK_3:
108                 nop
109 BLOCK_3_B:
110                 nop
111                 leave END
112         }
113
114         .try {
115                 leave END
116         } FINALLY {
117                 nop
118                 ${BRANCH_EXTRA_4}
119                 ${BRANCH_4}
120                 nop
121 IN_FINALLY:
122 BLOCK_4:
123                 nop
124 BLOCK_4_B:
125                 nop
126                 endfinally
127         }
128
129         .try {
130                 leave END
131         } filter {
132                 pop
133                 nop
134                 ${BRANCH_EXTRA_5}
135                 ${BRANCH_5}
136                 nop
137 IN_FILTER:
138 BLOCK_5:
139                 nop
140 BLOCK_5_B:
141                 nop
142                 ldc.i4.0
143                 endfilter
144         }
145         {
146                 pop
147                 nop
148                 ${BRANCH_EXTRA_6}
149                 ${BRANCH_6}
150                 nop
151 IN_HANDLER:
152 BLOCK_6:
153                 nop
154 BLOCK_6_B:
155                 nop
156                 leave END
157         }
158
159 END:
160         ldc.i4.0
161         ret
162 }
163 //EOF