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

Side by Side Diff: tests/srpc/srpc_shm_ppapi.html

Issue 6452010: Remove the x-ppapi-nacl-srpc and x-nacl-srpc mime types in favor of the singl... (Closed) Base URL: svn://svn.chromium.org/native_client/trunk/src/native_client/
Patch Set: '' Created 9 years, 10 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
« no previous file with comments | « tests/srpc/srpc_shm.html ('k') | tests/srpc/srpc_sockaddr.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html>
4 <!-- Copyright 2009 Google Inc. All rights reserved. -->
5 <head>
6 <title> SRPC Shared Memory API Test </title>
7 <META HTTP-EQUIV="Pragma" CONTENT="no-cache" />
8 <META HTTP-EQUIV="Expires" CONTENT="-1" />
9 <style type="text/css">
10 td.notrun { background-color: skyblue }
11 td.pass { background-color: lime }
12 td.fail { background-color: red }
13 </style>
14 <script type="application/x-javascript">
15 //<![CDATA[
16 var SetTestResult = function(element_id, result) {
17 var element = document.getElementById(element_id);
18 element.className = result;
19 }
20
21 // The NaCl module. Used to produce handles and for __shmFactory invocations.
22 var server;
23 // All shared memory regions will have this size.
24 var shm_size = 65536;
25 // Handle to a shared memory object returned by a NaCl module
26 var nacl_shm_handle;
27 // Shared memory object resulting from mapping a handle from a NaCl module.
28 var nacl_shm;
29 // A mapped shared memory object created by the __shmFactory method.
30 var factory_shm;
31 // The epitome of a test string.
32 var test_str = 'Hello, world.';
33 // The test string's length.
34 var str_len = test_str.length;
35 // The count of failing tests. Set from the queue length, and decremented
36 // whenever a test passes.
37 var failing_count;
38
39 // The queue of small tests.
40 var testQueue = [ ];
41 var appendTest = function(test_descr) {
42 testQueue[testQueue.length] = test_descr;
43 }
44
45 var expectPass = function(element, has_return, fp) {
46 appendTest(new Array('pass', element, has_return, fp));
47 }
48
49 var expectFail = function(element, fp) {
50 appendTest(new Array('fail', element, fp));
51 }
52
53 var SharedMemoryFactory = function() {
54 // Test the creation of shared memory objects.
55 // Attempt to create with the wrong number of parameters.
56 expectFail('factory_too_few',
57 function() {
58 return server.__shmFactory();
59 });
60 expectFail('factory_too_many',
61 function() {
62 return server.__shmFactory(shm_size, 'extra');
63 });
64 // Attempt to create a shared memory region with size of invalid type.
65 expectFail('factory_size_null',
66 function() {
67 return server.__shmFactory(undefined);
68 });
69 expectFail('factory_size_string',
70 function() {
71 return server.__shmFactory('string');
72 });
73 expectFail('factory_size_object',
74 function() {
75 return server.__shmFactory(new Array(10));
76 });
77 // Attempt to create a shared memory region with an invalid size.
78 expectFail('factory_size_invalid',
79 function() {
80 return server.__shmFactory(-1);
81 });
82 // Attempt to create a shared memory region with a valid size.
83 expectPass('factory_conforming',
84 true,
85 function() {
86 return server.__shmFactory(shm_size);
87 });
88 }
89
90 var SharedMemoryMaps = function() {
91 // Test the map method of a handle object.
92 // Get a handle to an invalid shared memory object from a NaCl module.
93 expectPass('map_invalid',
94 true,
95 function() {
96 return server.get_invalid_handle();
97 });
98 // Attempt to map with the wrong number of parameters.
99 expectFail('map_too_many',
100 function() {
101 nacl_shm_handle.map(1);
102 });
103 // Attempt to map with the correct number of parameters.
104 expectPass('map_valid',
105 true,
106 function() {
107 return nacl_shm_handle.map();
108 });
109 // Attempt to write to a negative offset.
110 expectFail('map_offset_neg',
111 function() {
112 nacl_shm.write(-1, str_len, test_str);
113 });
114 // Attempt to write to an offset larger than the region size.
115 expectFail('map_offset_big',
116 function() {
117 nacl_shm.write(shm_size, str_len, test_str);
118 });
119 // Attempt to write with a negative length.
120 expectFail('map_length_neg',
121 function() {
122 nacl_shm.write(0, -1, test_str);
123 });
124 // Attempt to write with a length larger than the region size.
125 expectFail('map_length_big',
126 function() {
127 nacl_shm.write(0, str_len + 1, test_str);
128 });
129 // Attempt to write to a valid offset.
130 expectPass('map_conforming', false,
131 function() {
132 nacl_shm.write(0, str_len, test_str);
133 });
134 }
135
136 var SharedMemoryWrites = function() {
137 // Test the write method.
138 // Attempt to write with the wrong number of parameters.
139 expectFail('write_too_few',
140 function() {
141 factory_shm.write(0, str_len);
142 });
143 expectFail('write_too_many',
144 function() {
145 factory_shm.write(0, str_len, test_str, 'extra');
146 });
147 // Attempt to write with a badly typed offset parameter.
148 expectFail('write_offset_null',
149 function() {
150 factory_shm.write(undefined, str_len, test_str);
151 });
152 expectFail('write_offset_string',
153 function() {
154 factory_shm.write('string', str_len, test_str);
155 });
156 expectFail('write_offset_object',
157 function() {
158 factory_shm.write(new Array(10), str_len, test_str);
159 });
160 // Attempt to write to a negative offset.
161 expectFail('write_offset_neg',
162 function() {
163 factory_shm.write(-1, str_len, test_str);
164 });
165 // Attempt to write to an offset larger than the region size.
166 expectFail('write_offset_big',
167 function() {
168 factory_shm.write(shm_size + 1, str_len, test_str);
169 });
170 // Attempt to write with a badly typed length parameter.
171 expectFail('write_length_null',
172 function() {
173 factory_shm.write(0, undefined, test_str);
174 });
175 expectFail('write_length_string',
176 function() {
177 factory_shm.write(0, 'string', test_str);
178 });
179 expectFail('write_length_object',
180 function() {
181 factory_shm.write(0, new Array(10), test_str);
182 });
183 // Attempt to write with a negative length.
184 expectFail('write_length_neg',
185 function() {
186 factory_shm.write(0, -1, test_str);
187 });
188 // Attempt to write with a length larger than the region size.
189 expectFail('write_length_big',
190 function() {
191 factory_shm.write(0, shm_size + 1, test_str);
192 });
193 // Attempt to write with a badly typed string parameter.
194 expectFail('write_string_null',
195 function() {
196 factory_shm.write(0, str_len, undefined);
197 });
198 expectFail('write_string_integer',
199 function() {
200 factory_shm.write(0, str_len, 10);
201 });
202 expectFail('write_string_object',
203 function() {
204 factory_shm.write(0, str_len, new Array(10));
205 });
206 // Attempt to write overlapping the end of the region.
207 expectFail('write_overlap',
208 function() {
209 factory_shm.write(shm_size - str_len + 1, str_len, test_str);
210 });
211 // Attempt to write with string.length != length.
212 expectFail('write_length_mismatch',
213 function() {
214 factory_shm.write(0, str_len + 1, test_str);
215 });
216 // Attempt a valid write. This should pass.
217 expectPass('write_conforming',
218 false,
219 function() {
220 factory_shm.write(0, str_len, test_str);
221 });
222 }
223
224 var SharedMemoryReads = function() {
225 // Test the read method.
226 // Attempt to read with the wrong number of parameters.
227 expectFail('read_too_few',
228 function() {
229 return factory_shm.read(0);
230 });
231 expectFail('read_too_many',
232 function() {
233 return factory_shm.read(0, str_len, 'extra');
234 });
235 // Attempt to read with a badly typed offset parameter.
236 expectFail('read_offset_null',
237 function() {
238 return factory_shm.read(undefined, str_len);
239 });
240 expectFail('read_offset_string',
241 function() {
242 return factory_shm.read('string', str_len);
243 });
244 expectFail('read_offset_object',
245 function() {
246 return factory_shm.read(new Array(10), str_len);
247 });
248 // Attempt to read from a negative offset.
249 expectFail('read_offset_neg',
250 function() {
251 return factory_shm.read(-1, str_len);
252 });
253 // Attempt to read from an offset larger than the region size.
254 expectFail('read_offset_big',
255 function() {
256 return factory_shm.read(shm_size + 1, str_len);
257 });
258 // Attempt to read with a badly typed length parameter.
259 expectFail('read_length_null',
260 function() {
261 return factory_shm.read(0, undefined);
262 });
263 expectFail('read_length_string',
264 function() {
265 return factory_shm.read(0, 'string');
266 });
267 expectFail('read_length_object',
268 function() {
269 return factory_shm.read(0, new Array(10));
270 });
271 // Attempt to read with a negative length.
272 expectFail('read_length_neg',
273 function() {
274 return factory_shm.read(0, -1);
275 });
276 // Attempt to read with a length larger than the region size.
277 expectFail('read_length_big',
278 function() {
279 return factory_shm.read(0, shm_size + 1);
280 });
281 // Attempt to read overlapping the end of the region.
282 expectFail('read_overlap',
283 function() {
284 return factory_shm.read(shm_size - str_len + 1, str_len);
285 });
286 // Attempt a valid read, and ensure return is correct. This should pass.
287 expectPass('read_conforming',
288 true,
289 function() {
290 return factory_shm.read(0, str_len);
291 });
292 }
293
294 // The test run functions.
295 var testExpectedPass = function(element, has_return, fp) {
296 var result = undefined;
297 try {
298 result = fp();
299 if (has_return && (undefined == result)) {
300 SetTestResult(element, 'fail');
301 } else {
302 SetTestResult(element, 'pass');
303 --failing_count;
304 }
305 } catch (string) {
306 SetTestResult(element, 'fail');
307 }
308 }
309
310 var testExpectedFail = function(element, fp) {
311 var result = undefined;
312 try {
313 result = fp();
314 SetTestResult(element, 'fail');
315 } catch (string) {
316 if (undefined == result) {
317 SetTestResult(element, 'pass');
318 --failing_count;
319 } else {
320 SetTestResult(element, 'fail');
321 }
322 }
323 }
324
325 var RunAllTests = function() {
326 var i;
327 var len = testQueue.length;
328 // All tests are considered failure until they have run successfully.
329 // This catches runs that end prematurely.
330 failing_count = len;
331 for (i = 0; i < len; ++i) {
332 var test_descr = testQueue[i];
333 if ('pass' == test_descr[0]) {
334 testExpectedPass(test_descr[1], test_descr[2], test_descr[3]);
335 } else {
336 testExpectedFail(test_descr[1], test_descr[2]);
337 }
338 }
339 }
340
341 var EnqueueAndRunTests = function() {
342 // Setup -- abort entire test if this fails.
343 try {
344 nacl_shm_handle = server.get_shm_handle(shm_size);
345 nacl_shm = server.get_shm_handle(shm_size).map();
346 factory_shm = server.__shmFactory(shm_size);
347 } catch (string) {
348 window.alert('Memory Maps test setup failed.');
349 return;
350 }
351 // Enqueue the tests.
352 SharedMemoryFactory();
353 SharedMemoryMaps();
354 SharedMemoryWrites();
355 SharedMemoryReads();
356 // Run them all.
357 RunAllTests();
358 }
359 //]]>
360 </script>
361 </head>
362 <body onload="nacllib.waitForModulesAndRunTests();"
363 onunload="nacllib.cleanUp();" >
364 <h1> SRPC Shared Memory API Test </h1>
365 <table cellspacing=5 cellpadding=5 border=5 summary="Test status table">
366 <tr>
367 <td>
368 </td>
369 <td>
370 <b> __shmFactory tests </b>
371 </td>
372 <td>
373 <b> handle mapping tests </b>
374 </td>
375 <td>
376 <b> write method tests </b>
377 </td>
378 <td>
379 <b> read method tests </b>
380 </td>
381 </tr>
382 <tr>
383 <td>
384 <b> Argument count tests </b>
385 </td>
386 <td valign=top>
387 <table summary="Factory arugments tests">
388 <tr>
389 <td id="factory_too_few" class="notrun">
390 argc: too few
391 </td>
392 </tr>
393 <tr>
394 <td id="factory_too_many" class="notrun">
395 argc: too many
396 </td>
397 </tr>
398 </table>
399 </td>
400 <td>
401 <table summary="Map arguments test">
402 <tr>
403 <td id="map_too_many" class="notrun">
404 argc: too many
405 </td>
406 </tr>
407 </table>
408 </td>
409 <td>
410 <table summary="Write argument tests">
411 <tr>
412 <td id="write_too_few" class="notrun">
413 argc: too few
414 </td>
415 </tr>
416 <tr>
417 <td id="write_too_many" class="notrun">
418 argc: too many
419 </td>
420 </tr>
421 </table>
422 </td>
423 <td>
424 <table summary="Read arguments tests">
425 <tr>
426 <td id="read_too_few" class="notrun">
427 argc: too few
428 </td>
429 </tr>
430 <tr>
431 <td id="read_too_many" class="notrun">
432 argc: too many
433 </td>
434 </tr>
435 </table>
436 </td>
437 </tr>
438 <tr>
439 <td>
440 <b> Argument type tests </b>
441 </td>
442 <td valign=top>
443 <table summary="Factory size tests">
444 <tr>
445 <td id="factory_size_null" class="notrun">
446 arg[0]: (size) undefined
447 </td>
448 </tr>
449 <tr>
450 <td id="factory_size_string" class="notrun">
451 arg[0]: (size) string
452 </td>
453 </tr>
454 <tr>
455 <td id="factory_size_object" class="notrun">
456 arg[0]: (size) object
457 </td>
458 </tr>
459 </table>
460 </td>
461 <td valign=top>
462 </td>
463 <td valign=top>
464 <table summary="Write offset tests">
465 <tr>
466 <td id="write_offset_null" class="notrun">
467 arg[0]: (offset) undefined
468 </td>
469 </tr>
470 <tr>
471 <td id="write_offset_string" class="notrun">
472 arg[0]: (offset) string
473 </td>
474 </tr>
475 <tr>
476 <td id="write_offset_object" class="notrun">
477 arg[0]: (offset) object
478 </td>
479 </tr>
480 <tr>
481 <td id="write_length_null" class="notrun">
482 arg[1]: (length) undefined
483 </td>
484 </tr>
485 <tr>
486 <td id="write_length_string" class="notrun">
487 arg[1]: (length) string
488 </td>
489 </tr>
490 <tr>
491 <td id="write_length_object" class="notrun">
492 arg[1]: (length) object
493 </td>
494 </tr>
495 <tr>
496 <td id="write_string_null" class="notrun">
497 arg[2]: (string) undefined
498 </td>
499 </tr>
500 <tr>
501 <td id="write_string_integer" class="notrun">
502 arg[2]: (string) integer
503 </td>
504 </tr>
505 <tr>
506 <td id="write_string_object" class="notrun">
507 arg[2]: (string) object
508 </td>
509 </tr>
510 </table>
511 </td>
512 <td valign=top>
513 <table summary="Read offset tests">
514 <tr>
515 <td id="read_offset_null" class="notrun">
516 arg[0]: (offset) undefined
517 </td>
518 </tr>
519 <tr>
520 <td id="read_offset_string" class="notrun">
521 arg[0]: (offset) string
522 </td>
523 </tr>
524 <tr>
525 <td id="read_offset_object" class="notrun">
526 arg[0]: (offset) object
527 </td>
528 </tr>
529 <tr>
530 <td id="read_length_null" class="notrun">
531 arg[1]: (length) undefined
532 </td>
533 </tr>
534 <tr>
535 <td id="read_length_string" class="notrun">
536 arg[1]: (length) string
537 </td>
538 </tr>
539 <tr>
540 <td id="read_length_object" class="notrun">
541 arg[1]: (length) object
542 </td>
543 </tr>
544 </table>
545 </td>
546 </tr>
547
548 <tr>
549 <td>
550 <b> Argument range tests </b>
551 </td>
552 <td valign=top>
553 <table summary="Factory invalid size test">
554 <tr>
555 <td id="factory_size_invalid" class="notrun">
556 arg[0]: (size) invalid/negative
557 </td>
558 </tr>
559 </table>
560 </td>
561 <td valign=top>
562 <table summary="Map invalid offset tests">
563 <tr>
564 <td id="map_offset_neg" class="notrun">
565 arg[0]: (offset) negative
566 </td>
567 </tr>
568 <tr>
569 <td id="map_offset_big" class="notrun">
570 arg[0]: (offset) too big
571 </td>
572 </tr>
573 <tr>
574 <td id="map_length_neg" class="notrun">
575 arg[1]: (length) negative
576 </td>
577 </tr>
578 <tr>
579 <td id="map_length_big" class="notrun">
580 arg[1]: (length) too big
581 </td>
582 </tr>
583 </table>
584 </td>
585 <td valign=top>
586 <table summary="Write invalid offset tests">
587 <tr>
588 <td id="write_offset_neg" class="notrun">
589 arg[0]: (offset) negative
590 </td>
591 </tr>
592 <tr>
593 <td id="write_offset_big" class="notrun">
594 arg[0]: (offset) too big
595 </td>
596 </tr>
597 <tr>
598 <td id="write_length_neg" class="notrun">
599 arg[1]: (length) negative
600 </td>
601 </tr>
602 <tr>
603 <td id="write_length_big" class="notrun">
604 arg[1]: (length) too big
605 </td>
606 </tr>
607 </table>
608 </td>
609 <td valign=top>
610 <table summary="Read invalid offset tests">
611 <tr>
612 <td id="read_offset_neg" class="notrun">
613 arg[0]: (offset) negative
614 </td>
615 </tr>
616 <tr>
617 <td id="read_offset_big" class="notrun">
618 arg[0]: (offset) too big
619 </td>
620 </tr>
621 <tr>
622 <td id="read_length_neg" class="notrun">
623 arg[1]: (length) negative
624 </td>
625 </tr>
626 <tr>
627 <td id="read_length_big" class="notrun">
628 arg[1]: (length) too big
629 </td>
630 </tr>
631 </table>
632 </td>
633 </tr>
634
635 <tr>
636 <td>
637 <b> Semantic error tests </b>
638 </td>
639 <td>
640 </td>
641 <td valign=top>
642 <table summary="Invalid map test">
643 <tr>
644 <td id="map_invalid" class="notrun">
645 NaCl module returns invalid handle
646 </td>
647 </tr>
648 </table>
649 </td>
650 <td valign=top>
651 <table summary="Write error tests">
652 <tr>
653 <td id="write_overlap" class="notrun">
654 Write overlaps end of region
655 </td>
656 </tr>
657 <tr>
658 <td id="write_length_mismatch" class="notrun">
659 Length disagrees with str.length
660 </td>
661 </tr>
662 </table>
663 </td>
664 <td valign=top>
665 <table summary="Read error tests">
666 <tr>
667 <td id="read_overlap" class="notrun">
668 Read overlaps end of region
669 </td>
670 </tr>
671 </table>
672 </td>
673 </tr>
674
675 <tr>
676 <td>
677 <b> Expected behavior </b>
678 </td>
679 <td valign=top>
680 <table summary="Factory conforming test">
681 <tr>
682 <td id="factory_conforming" class="notrun">
683 Conforming usage
684 </td>
685 </tr>
686 </table>
687 </td>
688 <td valign=top>
689 <table summary="Map conforming tests">
690 <tr>
691 <td id="map_valid" class="notrun">
692 Conforming invocation of map
693 </td>
694 </tr>
695 <tr>
696 <td id="map_conforming" class="notrun">
697 Conforming write to shared memory
698 </td>
699 </tr>
700 </table>
701 </td>
702 <td valign=top>
703 <table summary="Write conforming test">
704 <tr>
705 <td id="write_conforming" class="notrun">
706 Conforming usage
707 </td>
708 </tr>
709 </table>
710 </td>
711 <td valign=top>
712 <table summary="Read conforming test">
713 <tr>
714 <td id="read_conforming" class="notrun">
715 Conforming usage
716 </td>
717 </tr>
718 </table>
719 </td>
720 </tr>
721 </table>
722
723 <table summary="The color codes used for identifying test outcomes">
724 <tr> <td align="center"> <em> Legend </em> </td> </tr>
725 <tr> <td align="center" class="notrun"> Test not run </td> </tr>
726 <tr> <td align="center" class="pass"> Test passed </td> </tr>
727 <tr> <td align="center" class="fail"> Test failed </td> </tr>
728 </table>
729 <p>
730 <b>
731 NOTE: Some versions of some WebKit-based browsers do not correctly report
732 JavaScript exceptions raised by NPAPI plugins. This can cause some of
733 the above tests to spuriously report failure.
734 </b>
735 </p>
736
737 <div id=status>NO-STATUS</div>
738
739 <embed type="application/x-ppapi-nacl-srpc" id="nacl_server"
740 name="nacl_module" width="0" height="0" src="srpc_shm.nexe" />
741
742 <script type="text/javascript" src="nacl_js_lib.js"></script>
743 <script type="text/javascript">
744 //<![CDATA[
745 var nacllib = new NaclLib("nacl_module", "status", 500);
746
747 nacllib.test = function() {
748 server = document.getElementById("nacl_server");
749 EnqueueAndRunTests();
750 if (0 == testQueue.length) {
751 return "No tests run.";
752 } else if (0 != failing_count) {
753 return "Tests failed.";
754 } else {
755 return "";
756 }
757 }
758 //]]>
759 </script>
760 </body>
761 </html>
OLDNEW
« no previous file with comments | « tests/srpc/srpc_shm.html ('k') | tests/srpc/srpc_sockaddr.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698