Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: src/trusted/validator_x86/ncval_tests.c

Issue 10116004: Eliminate bundle_size parameter from validator interface. (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client
Patch Set: Created 8 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2012 The Native Client Authors. All rights reserved. 2 * Copyright (c) 2012 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be 3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file. 4 * found in the LICENSE file.
5 */ 5 */
6 6
7 /* 7 /*
8 * ncval_tests.c - simple unit tests for NaCl validator 8 * ncval_tests.c - simple unit tests for NaCl validator
9 */ 9 */
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 "89 e5 \n" /* mov %esp,%ebp */ 67 "89 e5 \n" /* mov %esp,%ebp */
68 "83 ec 08 \n" /* sub $0x8,%esp */ 68 "83 ec 08 \n" /* sub $0x8,%esp */
69 "e8 81 00 00 00 \n" /* call 0x86 */ 69 "e8 81 00 00 00 \n" /* call 0x86 */
70 "e8 d3 00 00 00 \n" /* call 0xd8 */ 70 "e8 d3 00 00 00 \n" /* call 0xd8 */
71 "e8 f3 04 00 00 \n" /* call 0x4f8 */ 71 "e8 f3 04 00 00 \n" /* call 0x4f8 */
72 "c9 \n" /* leave */ 72 "c9 \n" /* leave */
73 "c3 \n" /* ret */ 73 "c3 \n" /* ret */
74 "00 00 f4 \n" 74 "00 00 f4 \n"
75 }, 75 },
76 { 76 {
77 "test 4",
Karl 2012/04/17 22:20:12 I'm a little concerned about "just" deleting this
Nick Bray (chromium) 2012/04/17 22:42:02 That's a good question. My take was that a test n
Karl 2012/04/17 22:48:01 The only thing i see this test doing is verifying
78 "a big chunk of code whose origin is not clear",
79 /* sawfailure= */ 0, /* illegalinst= */ 0,
80 /* instructions= */ 90,
81 /* vaddr= */ 0x8054600,
82 "8d 4c 24 04 \n" /* lea 0x4(%esp),%ecx */
83 "83 e4 f0 \n" /* and $0xfffffff0,%esp */
84 "ff 71 fc \n" /* pushl -0x4(%ecx) */
85 "55 \n" /* push %ebp */
86 "89 e5 \n" /* mov %esp,%ebp */
87 "51 \n" /* push %ecx */
88 "66 90 \n" /* xchg %ax,%ax */
89 "83 ec 24 \n" /* sub $0x24,%esp */
90 "89 4d e8 \n" /* mov %ecx,-0x18(%ebp) */
91 "c7 45 f4 0a 00 00 00 \n" /* movl $0xa,-0xc(%ebp) */
92 "8b 45 e8 \n" /* mov -0x18(%ebp),%eax */
93 "83 38 01 \n" /* cmpl $0x1,(%eax) */
94 "7f 2b \n" /* jg 0x2d */
95 "8b 55 e8 \n" /* mov -0x18(%ebp),%edx */
96 "8b 42 04 \n" /* mov 0x4(%edx),%eax */
97 "8b 00 \n" /* mov (%eax),%eax */
98 "8d 76 00 \n" /* lea 0x0(%esi),%esi */
99 "89 44 24 04 \n" /* mov %eax,0x4(%esp) */
100 "c7 04 24 54 14 00 08 \n" /* movl $0x8001454,(%esp) */
101 "e8 c0 02 00 00 \n" /* call 0x2c5 */
102 "c7 04 24 01 00 00 00 \n" /* movl $0x1,(%esp) */
103 "8d 74 26 00 \n" /* lea 0x0(%esi),%esi */
104 "e8 c0 01 00 00 \n" /* call 0x1c5 */
105 "8b 55 e8 \n" /* mov -0x18(%ebp),%edx */
106 "8b 42 04 \n" /* mov 0x4(%edx),%eax */
107 "83 c0 04 \n" /* add $0x4,%eax */
108 "8b 00 \n" /* mov (%eax),%eax */
109 "89 04 24 \n" /* mov %eax,(%esp) */
110 "66 90 \n" /* xchg %ax,%ax */
111 "8d 74 26 00 \n" /* lea 0x0(%esi),%esi */
112 "8d bc 27 00 00 00 00 \n" /* lea 0x0(%edi),%edi */
113 "e8 90 09 00 00 \n" /* call 0x995 */
114 "89 45 f8 \n" /* mov %eax,-0x8(%ebp) */
115 "8b 45 e8 \n" /* mov -0x18(%ebp),%eax */
116 "83 38 02 \n" /* cmpl $0x2,(%eax) */
117 "7e 25 \n" /* jle 0x27 */
118 "8b 55 e8 \n" /* mov -0x18(%ebp),%edx */
119 "66 90 \n" /* xchg %ax,%ax */
120 "8b 42 04 \n" /* mov 0x4(%edx),%eax */
121 "83 c0 08 \n" /* add $0x8,%eax */
122 "8b 00 \n" /* mov (%eax),%eax */
123 "89 04 24 \n" /* mov %eax,(%esp) */
124 "e8 70 09 00 00 \n" /* call 0x975 */
125 "89 45 f4 \n" /* mov %eax,-0xc(%ebp) */
126 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
127 "8d bc 27 00 00 00 00 \n" /* lea 0x0(%edi),%edi */
128 "8b 45 f4 \n" /* mov -0xc(%ebp),%eax */
129 "a3 28 2f 00 08 \n" /* mov %eax,0x8002f28 */
130 "eb 26 \n" /* jmp 0x28 */
131 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
132 "c7 44 24 08 03 00 00 00 \n" /* movl $0x3,0x8(%esp) */
133 "c7 44 24 04 01 00 00 00 \n" /* movl $0x1,0x4(%esp) */
134 "8b 45 f4 \n" /* mov -0xc(%ebp),%eax */
135 "89 04 24 \n" /* mov %eax,(%esp) */
136 "90 \n" /* nop */
137 "8d 74 26 00 \n" /* lea 0x0(%esi),%esi */
138 "e8 20 00 00 00 \n" /* call 0x25 */
139 "83 7d f8 00 \n" /* cmpl $0x0,-0x8(%ebp) */
140 "0f 9f c0 \n" /* setg %al */
141 "83 6d f8 01 \n" /* subl $0x1,-0x8(%ebp) */
142 "84 c0 \n" /* test %al,%al */
143 "8d 76 00 \n" /* lea 0x0(%esi),%esi */
144 "75 ce \n" /* jne 0xffffffd0 */
145 "c7 04 24 00 00 00 00 \n" /* movl $0x0,(%esp) */
146 "66 90 \n" /* xchg %ax,%ax */
147 "e8 20 01 00 00 \n" /* call 0x125 */
148 "55 \n" /* push %ebp */
149 "89 e5 \n" /* mov %esp,%ebp */
150 "83 ec 1c \n" /* sub $0x1c,%esp */
151 "83 7d 08 01 \n" /* cmpl $0x1,0x8(%ebp) */
152 "75 44 \n" /* jne 0x46 */
153 "8b 55 0c \n" /* mov 0xc(%ebp),%edx */
154 "90 \n" /* nop */
155 "8b 04 95 24 2f 00 08 \n" /* mov 0x8002f24(,%edx,4),%eax */
156 "83 e8 01 \n" /* sub $0x1,%eax */
157 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
158 "89 04 95 24 2f 00 08 \n" /* mov %eax,0x8002f24(,%edx,4) */
159 "8b 55 10 \n" /* mov 0x10(%ebp),%edx */
160 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
161 "8b 04 95 24 2f 00 08 \n" /* mov 0x8002f24(,%edx,4),%eax */
162 "83 c0 01 \n" /* add $0x1,%eax */
163 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
164 "89 04 95 24 2f 00 08 \n" /* mov %eax,0x8002f24(,%edx,4) */
165 "eb 77 \n" /* jmp 0x79 */
166 "8d b4 26 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
167 "8b 45 10 \n" /* mov 0x10(%ebp),%eax */
168 "8b 55 0c \n" /* mov 0xc(%ebp),%edx */
169 "01 c2 \n" /* add %eax,%edx */
170 "b8 06 00 00 00 \n" /* mov $0x6,%eax */
171 "29 d0 \n" /* sub %edx,%eax */
172 "f4 \n" /* hlt */
173 },
174 {
175 "test 5",
176 "a big chunk of code whose origin is not clear",
177 /* sawfailure= */ 0, /* illegalinst= */ 0,
178 /* instructions= */ 90,
179 /* vaddr= */ 0x8054600,
180 "8d 4c 24 04 \n" /* lea 0x4(%esp),%ecx */
181 "83 e4 f0 \n" /* and $0xfffffff0,%esp */
182 "ff 71 fc \n" /* pushl -0x4(%ecx) */
183 "55 \n" /* push %ebp */
184 "89 e5 \n" /* mov %esp,%ebp */
185 "51 \n" /* push %ecx */
186 "66 90 \n" /* xchg %ax,%ax */
187 "83 ec 24 \n" /* sub $0x24,%esp */
188 "89 4d e8 \n" /* mov %ecx,-0x18(%ebp) */
189 "c7 45 f4 0a 00 00 00 \n" /* movl $0xa,-0xc(%ebp) */
190 "8b 45 e8 \n" /* mov -0x18(%ebp),%eax */
191 "83 38 01 \n" /* cmpl $0x1,(%eax) */
192 "7f 2b \n" /* jg 0x2d */
193 "8b 55 e8 \n" /* mov -0x18(%ebp),%edx */
194 "8b 42 04 \n" /* mov 0x4(%edx),%eax */
195 "8b 00 \n" /* mov (%eax),%eax */
196 "8d 76 00 \n" /* lea 0x0(%esi),%esi */
197 "89 44 24 04 \n" /* mov %eax,0x4(%esp) */
198 "c7 04 24 54 14 00 08 \n" /* movl $0x8001454,(%esp) */
199 "e8 c0 02 00 00 \n" /* call 0x2c5 */
200 "c7 04 24 01 00 00 00 \n" /* movl $0x1,(%esp) */
201 "8d 74 26 00 \n" /* lea 0x0(%esi),%esi */
202 "e8 c0 01 00 00 \n" /* call 0x1c5 */
203 "8b 55 e8 \n" /* mov -0x18(%ebp),%edx */
204 "8b 42 04 \n" /* mov 0x4(%edx),%eax */
205 "83 c0 04 \n" /* add $0x4,%eax */
206 "8b 00 \n" /* mov (%eax),%eax */
207 "89 04 24 \n" /* mov %eax,(%esp) */
208 "66 90 \n" /* xchg %ax,%ax */
209 "8d 74 26 00 \n" /* lea 0x0(%esi),%esi */
210 "8d bc 27 00 00 00 00 \n" /* lea 0x0(%edi),%edi */
211 "e8 90 09 00 00 \n" /* call 0x995 */
212 "89 45 f8 \n" /* mov %eax,-0x8(%ebp) */
213 "8b 45 e8 \n" /* mov -0x18(%ebp),%eax */
214 "83 38 02 \n" /* cmpl $0x2,(%eax) */
215 "7e 25 \n" /* jle 0x27 */
216 "8b 55 e8 \n" /* mov -0x18(%ebp),%edx */
217 "66 90 \n" /* xchg %ax,%ax */
218 "8b 42 04 \n" /* mov 0x4(%edx),%eax */
219 "83 c0 08 \n" /* add $0x8,%eax */
220 "8b 00 \n" /* mov (%eax),%eax */
221 "89 04 24 \n" /* mov %eax,(%esp) */
222 "e8 70 09 00 00 \n" /* call 0x975 */
223 "89 45 f4 \n" /* mov %eax,-0xc(%ebp) */
224 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
225 "8d bc 27 00 00 00 00 \n" /* lea 0x0(%edi),%edi */
226 "8b 45 f4 \n" /* mov -0xc(%ebp),%eax */
227 "a3 28 2f 00 08 \n" /* mov %eax,0x8002f28 */
228 "eb 26 \n" /* jmp 0x28 */
229 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
230 "c7 44 24 08 03 00 00 00 \n" /* movl $0x3,0x8(%esp) */
231 "c7 44 24 04 01 00 00 00 \n" /* movl $0x1,0x4(%esp) */
232 "8b 45 f4 \n" /* mov -0xc(%ebp),%eax */
233 "89 04 24 \n" /* mov %eax,(%esp) */
234 "90 \n" /* nop */
235 "8d 74 26 00 \n" /* lea 0x0(%esi),%esi */
236 "e8 20 00 00 00 \n" /* call 0x25 */
237 "83 7d f8 00 \n" /* cmpl $0x0,-0x8(%ebp) */
238 "0f 9f c0 \n" /* setg %al */
239 "83 6d f8 01 \n" /* subl $0x1,-0x8(%ebp) */
240 "84 c0 \n" /* test %al,%al */
241 "8d 76 00 \n" /* lea 0x0(%esi),%esi */
242 "75 ce \n" /* jne 0xffffffd0 */
243 "c7 04 24 00 00 00 00 \n" /* movl $0x0,(%esp) */
244 "66 90 \n" /* xchg %ax,%ax */
245 "e8 20 01 00 00 \n" /* call 0x125 */
246 "55 \n" /* push %ebp */
247 "89 e5 \n" /* mov %esp,%ebp */
248 "83 ec 1c \n" /* sub $0x1c,%esp */
249 "83 7d 08 01 \n" /* cmpl $0x1,0x8(%ebp) */
250 "75 44 \n" /* jne 0x46 */
251 "8b 55 0c \n" /* mov 0xc(%ebp),%edx */
252 "90 \n" /* nop */
253 "8b 04 95 24 2f 00 08 \n" /* mov 0x8002f24(,%edx,4),%eax */
254 "83 e8 01 \n" /* sub $0x1,%eax */
255 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
256 "89 04 95 24 2f 00 08 \n" /* mov %eax,0x8002f24(,%edx,4) */
257 "8b 55 10 \n" /* mov 0x10(%ebp),%edx */
258 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
259 "8b 04 95 24 2f 00 08 \n" /* mov 0x8002f24(,%edx,4),%eax */
260 "83 c0 01 \n" /* add $0x1,%eax */
261 "8d b6 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
262 "89 04 95 24 2f 00 08 \n" /* mov %eax,0x8002f24(,%edx,4) */
263 "00 00 \n" /* add %al,(%eax) */
264 "8d b4 26 00 00 00 00 \n" /* lea 0x0(%esi),%esi */
265 "8b 45 10 \n" /* mov 0x10(%ebp),%eax */
266 "8b 55 0c \n" /* mov 0xc(%ebp),%edx */
267 "01 c2 \n" /* add %eax,%edx */
268 "b8 06 00 00 00 \n" /* mov $0x6,%eax */
269 "29 d0 \n" /* sub %edx,%eax */
270 "f4 \n" /* hlt */
271 },
272 {
273 "test 6", 77 "test 6",
274 "test 6: 3c 25 cmp %al, $I", 78 "test 6: 3c 25 cmp %al, $I",
275 /* sawfailure= */ 0, /* illegalinst= */ 0, 79 /* sawfailure= */ 0, /* illegalinst= */ 0,
276 /* instructions= */ 7, 80 /* instructions= */ 7,
277 /* vaddr= */ 0x80000000, 81 /* vaddr= */ 0x80000000,
278 "3c 25 \n" /* cmp $0x25,%al */ 82 "3c 25 \n" /* cmp $0x25,%al */
279 "90 90 90 90 90 90 f4 \n" 83 "90 90 90 90 90 90 f4 \n"
280 }, 84 },
281 { 85 {
282 "test 7", 86 "test 7",
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 /* instructions= */ 3, 226 /* instructions= */ 3,
423 /* vaddr= */ 0x80000000, 227 /* vaddr= */ 0x80000000,
424 "81 e0 ff ff ff ff 81 c8 00 00 00 00 ff d0 f4 \n" 228 "81 e0 ff ff ff ff 81 c8 00 00 00 00 ff d0 f4 \n"
425 }, 229 },
426 { 230 {
427 "test 24", 231 "test 24",
428 "test 24: 5-byte nacljmp", 232 "test 24: 5-byte nacljmp",
429 /* sawfailure= */ 0, /* illegalinst= */ 0, 233 /* sawfailure= */ 0, /* illegalinst= */ 0,
430 /* instructions= */ 2, 234 /* instructions= */ 2,
431 /* vaddr= */ 0x80000000, 235 /* vaddr= */ 0x80000000,
432 "83 e0 f0 ff e0 f4 \n" 236 "83 e0 e0 ff e0 f4 \n"
433 }, 237 },
434 { 238 {
435 "test 25", 239 "test 25",
436 "test 25: 0xe3 jmp", 240 "test 25: 0xe3 jmp",
437 /* sawfailure= */ 1, /* illegalinst= */ 1, 241 /* sawfailure= */ 1, /* illegalinst= */ 1,
438 /* instructions= */ 1, 242 /* instructions= */ 1,
439 /* vaddr= */ 0x80000000, 243 /* vaddr= */ 0x80000000,
440 "e3 00 f4 \n" 244 "e3 00 f4 \n"
441 }, 245 },
442 { 246 {
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 }, 711 },
908 /* code.google.com issue 23 reported by defend.the.world on 11 Dec 2008 */ 712 /* code.google.com issue 23 reported by defend.the.world on 11 Dec 2008 */
909 { 713 {
910 "test 78", 714 "test 78",
911 "test 78: call (*edx)", 715 "test 78: call (*edx)",
912 /* sawfailure= */ 1, /* illegalinst= */ 0, 716 /* sawfailure= */ 1, /* illegalinst= */ 0,
913 /* instructions= */ 30, 717 /* instructions= */ 30,
914 /* vaddr= */ 0x80000000, 718 /* vaddr= */ 0x80000000,
915 "90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 \n" 719 "90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 \n"
916 "90 90 90 90 90 90 90 90 90 90 90 \n" 720 "90 90 90 90 90 90 90 90 90 90 90 \n"
917 "83 e2 f0 \n" /* and */ 721 "83 e2 e0 \n" /* and */
918 "ff 12 \n" /* call (*edx) */ 722 "ff 12 \n" /* call (*edx) */
919 "90 f4 \n" /* nop halt */ 723 "90 f4 \n" /* nop halt */
920 }, 724 },
921 { 725 {
922 "test 79", 726 "test 79",
923 "test 79: call *edx", 727 "test 79: call *edx",
924 /* sawfailure= */ 0, /* illegalinst= */ 0, 728 /* sawfailure= */ 0, /* illegalinst= */ 0,
925 /* instructions= */ 30, 729 /* instructions= */ 30,
926 /* vaddr= */ 0x80000000, 730 /* vaddr= */ 0x80000000,
927 "90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 \n" 731 "90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 90 \n"
928 "90 90 90 90 90 90 90 90 90 90 90 \n" 732 "90 90 90 90 90 90 90 90 90 90 90 \n"
929 "83 e2 f0 \n" /* and */ 733 "83 e2 e0 \n" /* and */
930 "ff d2 \n" /* call *edx */ 734 "ff d2 \n" /* call *edx */
931 "90 f4 \n" /* nop halt */ 735 "90 f4 \n" /* nop halt */
932 }, 736 },
933 { 737 {
934 "test 80", 738 "test 80",
935 "test 80: roundss", 739 "test 80: roundss",
936 /* sawfailure= */ 0, /* illegalinst= */ 0, 740 /* sawfailure= */ 0, /* illegalinst= */ 0,
937 /* instructions= */ 3, 741 /* instructions= */ 3,
938 /* vaddr= */ 0x80000000, 742 /* vaddr= */ 0x80000000,
939 "66 0f 3a 0a c0 00 \n" /* roundss $0x0,%xmm0,%xmm0 */ 743 "66 0f 3a 0a c0 00 \n" /* roundss $0x0,%xmm0,%xmm0 */
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
1146 int rc; 950 int rc;
1147 951
1148 DecodeHexString(vtest->data_as_hex, &byte0, &data_size); 952 DecodeHexString(vtest->data_as_hex, &byte0, &data_size);
1149 /* 953 /*
1150 * The validator used to require that code chunks end in HLT. We 954 * The validator used to require that code chunks end in HLT. We
1151 * have left the HLTs in, but don't pass them to the validator. 955 * have left the HLTs in, but don't pass them to the validator.
1152 * TODO(mseaborn): Remove the HLTs. 956 * TODO(mseaborn): Remove the HLTs.
1153 */ 957 */
1154 assert(byte0[data_size - 1] == 0xf4 /* HLT */); 958 assert(byte0[data_size - 1] == 0xf4 /* HLT */);
1155 959
1156 vstate = NCValidateInit(vtest->vaddr, data_size - 1, 16, 960 vstate = NCValidateInit(vtest->vaddr, data_size - 1,
1157 FALSE, &g_ncval_cpu_features); 961 FALSE, &g_ncval_cpu_features);
1158 assert (vstate != NULL); 962 assert (vstate != NULL);
1159 NCValidateSetErrorReporter(vstate, &kNCVerboseErrorReporter); 963 NCValidateSetErrorReporter(vstate, &kNCVerboseErrorReporter);
1160 NCValidateSegment(byte0, (uint32_t)vtest->vaddr, data_size - 1, vstate); 964 NCValidateSegment(byte0, (uint32_t)vtest->vaddr, data_size - 1, vstate);
1161 free(byte0); 965 free(byte0);
1162 rc = NCValidateFinish(vstate); 966 rc = NCValidateFinish(vstate);
1163 967
1164 do { 968 do {
1165 printf("vtest->sawfailure = %d, vstate->stats.sawfailure = %d\n", 969 printf("vtest->sawfailure = %d, vstate->stats.sawfailure = %d\n",
1166 vtest->sawfailure, vstate->stats.sawfailure); 970 vtest->sawfailure, vstate->stats.sawfailure);
1167 NCStatsPrint(vstate); 971 NCStatsPrint(vstate);
1168 if (vtest->sawfailure != rc) break; 972 if (vtest->sawfailure != rc) break;
1169 if (vtest->sawfailure ^ vstate->stats.sawfailure) break; 973 if (vtest->sawfailure ^ vstate->stats.sawfailure) break;
1170 if (didstubout != vstate->stats.didstubout) break; 974 if (didstubout != vstate->stats.didstubout) break;
1171 if (vtest->instructions != vstate->stats.instructions) break; 975 if (vtest->instructions != vstate->stats.instructions) break;
1172 if (vtest->illegalinst != vstate->stats.illegalinst) break; 976 if (vtest->illegalinst != vstate->stats.illegalinst) break;
1173 Info("*** %s passed (%s)\n", vtest->name, vtest->description); 977 Info("*** %s passed (%s)\n", vtest->name, vtest->description);
978 printf("\n");
1174 NCValidateFreeState(&vstate); 979 NCValidateFreeState(&vstate);
1175 return; 980 return;
1176 } while (0); 981 } while (0);
1177 NCStatsPrint(vstate); 982 NCStatsPrint(vstate);
1178 NCValidateFreeState(&vstate); 983 NCValidateFreeState(&vstate);
1179 Info("*** %s failed (%s)\n", vtest->name, vtest->description); 984 Info("*** %s failed (%s)\n", vtest->name, vtest->description);
1180 exit(-1); 985 exit(-1);
1181 } 986 }
1182 987
1183 void test_fail_on_bad_alignment() { 988 void test_fail_on_bad_alignment() {
1184 struct NCValidatorState *vstate; 989 struct NCValidatorState *vstate;
1185 990
1186 vstate = NCValidateInit(0x80000000, 0x1000, 16, FALSE, 991 printf("Running test_fail_on_bad_alignment...\n");
992
993 vstate = NCValidateInit(0x80000000, 0x1000, FALSE,
1187 &g_ncval_cpu_features); 994 &g_ncval_cpu_features);
1188 assert (vstate != NULL); 995 if (vstate == NULL)
996 exit(-1);
1189 NCValidateFreeState(&vstate); 997 NCValidateFreeState(&vstate);
1190 998
1191 /* Unaligned start addresses are not allowed. */ 999 /* Unaligned start addresses are not allowed. */
1192 vstate = NCValidateInit(0x80000001, 0x1000, 16, FALSE, 1000 vstate = NCValidateInit(0x80000001, 0x1000, FALSE,
1193 &g_ncval_cpu_features); 1001 &g_ncval_cpu_features);
1194 assert (vstate == NULL); 1002 if (vstate != NULL)
1195 1003 exit(-1);
1196 /* Only alignments of 32 and 64 bytes are supported. */
1197 vstate = NCValidateInit(0x80000000, 0x1000, 64, FALSE,
1198 &g_ncval_cpu_features);
1199 assert (vstate == NULL);
1200 } 1004 }
1201 1005
1202 void test_stubout() { 1006 void test_stubout() {
1203 /* Similar to test 68 */ 1007 /* Similar to test 68 */
1204 struct NCValTestCase test = { 1008 struct NCValTestCase test = {
1205 "test stubout", 1009 "test stubout",
1206 "test stubout: NACLi_MMX", 1010 "test stubout: NACLi_MMX",
1207 /* sawfailure= */ 0, /* illegalinst= */ 0, 1011 /* sawfailure= */ 0, /* illegalinst= */ 0,
1208 /* instructions= */ 1, 1012 /* instructions= */ 1,
1209 /* vaddr= */ 0x80000000, 1013 /* vaddr= */ 0x80000000,
1210 "0f 60 00 f4 \n" /* punpcklbw (%eax),%mm0 */ 1014 "0f 60 00 f4 \n" /* punpcklbw (%eax),%mm0 */
1211 }; 1015 };
1212 1016
1017 printf("Running test_stubout...\n");
1018
1213 /* If MMX instructions are not allowed, stubout will occur. */ 1019 /* If MMX instructions are not allowed, stubout will occur. */
1214 NaClSetCPUFeature(&g_ncval_cpu_features, NaClCPUFeature_MMX, FALSE); 1020 NaClSetCPUFeature(&g_ncval_cpu_features, NaClCPUFeature_MMX, FALSE);
1215 TestValidator(&test, TRUE); 1021 TestValidator(&test, TRUE);
1216 NaClSetCPUFeature(&g_ncval_cpu_features, NaClCPUFeature_MMX, TRUE); 1022 NaClSetCPUFeature(&g_ncval_cpu_features, NaClCPUFeature_MMX, TRUE);
1217 } 1023 }
1218 1024
1219 void ncvalidate_unittests() { 1025 void ncvalidate_unittests() {
1220 size_t i; 1026 size_t i;
1221 1027
1222 /* Default to stubbing out nothing. */ 1028 /* Default to stubbing out nothing. */
(...skipping 16 matching lines...) Expand all
1239 if (!GioFileRefCtor(&gio_out_stream, stdout)) { 1045 if (!GioFileRefCtor(&gio_out_stream, stdout)) {
1240 fprintf(stderr, "Unable to create gio file for stdout!\n"); 1046 fprintf(stderr, "Unable to create gio file for stdout!\n");
1241 return 1; 1047 return 1;
1242 } 1048 }
1243 1049
1244 NaClLogModuleInitExtended(LOG_INFO, gout); 1050 NaClLogModuleInitExtended(LOG_INFO, gout);
1245 ncvalidate_unittests(); 1051 ncvalidate_unittests();
1246 GioFileDtor(gout); 1052 GioFileDtor(gout);
1247 return 0; 1053 return 0;
1248 } 1054 }
OLDNEW
« src/trusted/validator_x86/build.scons ('K') | « src/trusted/validator_x86/ncval.c ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698