OLD | NEW |
| (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 2008 Google Inc. All rights reserved. --> | |
5 <head> | |
6 <title> SRPC Descriptor Passing 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 server = 0; | |
17 var client = 0; | |
18 var num_passing = 0; | |
19 var num_failing = 0; | |
20 | |
21 var GeneralLog = function(str) { | |
22 var output = document.getElementById('GeneralOutput'); | |
23 output.innerHTML += str + '<br>'; | |
24 } | |
25 | |
26 var SocketAddressLog = function(str) { | |
27 var output = document.getElementById('SocketAddressOutput'); | |
28 output.innerHTML += str + '<br>'; | |
29 } | |
30 | |
31 var SetTestResult = function(element_id, result) { | |
32 var element = document.getElementById(element_id); | |
33 if ('pass' == result) { | |
34 element.className = 'pass'; | |
35 ++num_passing; | |
36 } else { | |
37 element.className = 'fail'; | |
38 ++num_failing; | |
39 } | |
40 } | |
41 var SocketAddressNaClToNacl = function() { | |
42 SocketAddressLog('<b> NaCl to NaCl Test'); | |
43 SocketAddressLog('Invoking server.start_server'); | |
44 var socket_address = server.start_server(); | |
45 SocketAddressLog('Invoking NaCl client.sock_addr_client'); | |
46 client_errors = client.sock_addr_client(socket_address); | |
47 var server_errors = server.report(); | |
48 if (client_errors == 0 && server_errors == 0) { | |
49 SocketAddressLog('TEST PASSED'); | |
50 SetTestResult('addr_nacl_nacl', 'pass'); | |
51 } else if (client_errors == 0) { | |
52 SocketAddressLog('Server errors -- NaClToNaCl TEST FAILED'); | |
53 SetTestResult('addr_nacl_nacl', 'fail'); | |
54 } else { | |
55 SocketAddressLog('Client errors -- NaClToNaCl TEST FAILED'); | |
56 SetTestResult('addr_nacl_nacl', 'fail'); | |
57 } | |
58 } | |
59 | |
60 var SocketAddressNaClToBrowser = function() { | |
61 SocketAddressLog('<b> NaCl to Browser Test'); | |
62 SocketAddressLog('Invoking server.start_server'); | |
63 var socket_address2 = server.start_server(); | |
64 SocketAddressLog('Invoking connect'); | |
65 var con_sock = socket_address2.connect(); | |
66 SocketAddressLog('Invoking getmsg'); | |
67 var retval = con_sock.getmsg(100); | |
68 var str = ''; | |
69 for (var i = 0; i < retval.length && retval[i] != 0; i++) { | |
70 str += String.fromCharCode(retval[i]); | |
71 } | |
72 SocketAddressLog(str); | |
73 var server_errors = server.report(); | |
74 if (server_errors == 0) { | |
75 SocketAddressLog('TEST PASSED'); | |
76 SetTestResult('addr_nacl_browser', 'pass'); | |
77 } else { | |
78 SocketAddressLog('Server errors -- NaClToBrowser TEST FAILED'); | |
79 SetTestResult('addr_nacl_browser', 'fail'); | |
80 } | |
81 } | |
82 | |
83 var SharedMemoryLog = function(str) { | |
84 var output = document.getElementById('SharedMemoryOutput'); | |
85 output.innerHTML += str + '<br>'; | |
86 } | |
87 | |
88 var SharedMemoryBrowserToBrowser = function() { | |
89 // This tests the basic creation of shared memory objects and manipulation | |
90 // within the JavaScript bridge. It creates a shared memory region, writes a | |
91 // string into it, and tests that reading a substring suffix is correct. | |
92 var in_str = 'hello, world'; | |
93 var test_offset = 7; | |
94 SharedMemoryLog('<b> Browser to Browser Test'); | |
95 var shared_memory = server.__shmFactory(65536); | |
96 SharedMemoryLog('created shared memory region'); | |
97 shared_memory.write(0, in_str.length, in_str); | |
98 SharedMemoryLog('wrote to shared memory region'); | |
99 var rval = shared_memory.read(test_offset, in_str.length - test_offset); | |
100 if (rval == in_str.substring(test_offset)) { | |
101 SharedMemoryLog('TEST PASSED'); | |
102 SetTestResult('mem_browser_browser', 'pass'); | |
103 } else { | |
104 SharedMemoryLog('Strings miscompare: BrowserToBrowser TEST FAILED'); | |
105 SetTestResult('mem_browser_browser', 'fail'); | |
106 } | |
107 } | |
108 | |
109 var SharedMemoryBrowserToNaCl = function() { | |
110 // This tests passing of shared memory objects from the browser to NaCl | |
111 // modules. It creates a shared memory region, writes a string to the region, | |
112 // invokes a method in the server that checks for the expected string and | |
113 // writes another string immediately after. It then checks the written | |
114 // return string and error count. | |
115 var in_str = 'hello, world'; | |
116 var compare_string = 'Quod erat demonstrandum'; | |
117 var region_size = 65536; | |
118 SharedMemoryLog('<b> Browser to NaCl Test'); | |
119 var shared_memory = server.__shmFactory(region_size); | |
120 SharedMemoryLog('created shared memory region'); | |
121 shared_memory.write(0, in_str.length, in_str); | |
122 SharedMemoryLog('wrote to shared memory region'); | |
123 var server_errors = server.test_shared_memory(shared_memory, in_str); | |
124 var rval = shared_memory.read(in_str.length, compare_string.length); | |
125 if (server_errors == 0 && rval == compare_string) { | |
126 SharedMemoryLog('TEST PASSED'); | |
127 SetTestResult('mem_browser_nacl', 'pass'); | |
128 } else { | |
129 SharedMemoryLog('Strings miscompare: BrowserToNaCl TEST FAILED'); | |
130 SetTestResult('mem_browser_nacl', 'fail'); | |
131 } | |
132 } | |
133 | |
134 var SharedMemoryNaClToBrowser = function() { | |
135 // This tests passing of shared memory objects from NaCl to the browser. | |
136 // It invokes a method in client to create a shared memory region and write a | |
137 // string to the region. | |
138 var region_size = 65536; | |
139 SharedMemoryLog('<b> NaCl to Browser Test'); | |
140 var retval = client.shared_memory_client(region_size); | |
141 var handle = retval[0]; | |
142 var in_str = retval[1]; | |
143 var client_errors = retval[2]; | |
144 SharedMemoryLog('Compare to: ' + in_str); | |
145 var shared_memory = handle.map(); | |
146 var read_string = shared_memory.read(0, in_str.length); | |
147 if (client_errors == 0 && in_str == read_string) { | |
148 SharedMemoryLog('TEST PASSED'); | |
149 SetTestResult('mem_nacl_browser', 'pass'); | |
150 } else { | |
151 SharedMemoryLog('Strings miscompare: NaClToBrowser TEST FAILED'); | |
152 SetTestResult('mem_nacl_browser', 'fail'); | |
153 } | |
154 } | |
155 | |
156 var SharedMemoryNaClToNaCl = function() { | |
157 // This tests passing of shared memory objects from NaCl to NaCl. | |
158 // It invokes a method in client to create a shared memory region and write a | |
159 // string to the region. This region is then passed to the server, which | |
160 // checks the region and writes its own string and an error count. | |
161 var compare_string = 'Quod erat demonstrandum'; | |
162 var region_size = 65536; | |
163 SharedMemoryLog('<b> NaCl to NaCl Test'); | |
164 var retval = client.shared_memory_client(region_size); | |
165 var handle = retval[0]; | |
166 var in_str = retval[1]; | |
167 var client_errors = retval[2]; | |
168 SharedMemoryLog('Compare to: ' + in_str); | |
169 var shared_memory = handle.map(); | |
170 var server_errors = server.test_shared_memory(shared_memory, in_str); | |
171 var rval = shared_memory.read(in_str.length, compare_string.length); | |
172 if (client_errors == 0 && server_errors == 0 && rval == compare_string) { | |
173 SharedMemoryLog('TEST PASSED'); | |
174 SetTestResult('mem_nacl_nacl', 'pass'); | |
175 } else { | |
176 SharedMemoryLog('Strings miscompare: NaClToNaCl TEST FAILED'); | |
177 SetTestResult('mem_nacl_nacl', 'fail'); | |
178 } | |
179 } | |
180 | |
181 var RunAllTests = function() { | |
182 // socket address passing tests. | |
183 SocketAddressNaClToBrowser(); | |
184 SocketAddressNaClToNacl(); | |
185 // shared memory passing tests. | |
186 SharedMemoryBrowserToBrowser(); | |
187 SharedMemoryBrowserToNaCl(); | |
188 SharedMemoryNaClToBrowser(); | |
189 SharedMemoryNaClToNaCl(); | |
190 } | |
191 //]]> | |
192 </script> | |
193 </head> | |
194 <body onload="nacllib.waitForModulesAndRunTests();" | |
195 onunload="nacllib.cleanUp();" > | |
196 <h1> SRPC Descriptor Passing Test </h1> | |
197 <table border=5 cellpadding=5% | |
198 summary="A three-column table of test results"> | |
199 <tr> | |
200 <td align=center> | |
201 <button type="button" onclick="RunAllTests()"> Run All Tests </button> | |
202 </td> | |
203 <td align=center> <b> Socket Address Passing </b> </td> | |
204 <td align=center> <b> Shared Memory Passing </b> </td> | |
205 </tr> | |
206 <tr> | |
207 <td align=center> <b> Browser to Browser </b> </td> | |
208 <td align=center> <em> Not applicable </em> </td> | |
209 <td align=center id="mem_browser_browser" class="notrun"> | |
210 <button type="button" onclick="SharedMemoryBrowserToBrowser()"> | |
211 Run Test | |
212 </button> | |
213 </td> | |
214 </tr> | |
215 <tr> | |
216 <td> <b> Browser to NaCl </b> </td> | |
217 <td align=center> <em> Not applicable </em> </td> | |
218 <td align=center id="mem_browser_nacl" class="notrun"> | |
219 <button type="button" onclick="SharedMemoryBrowserToNaCl()"> | |
220 Run Test | |
221 </button> | |
222 </td> | |
223 </tr> | |
224 <tr> | |
225 <td> <b> NaCl to Browser </b> </td> | |
226 <td align=center id="addr_nacl_browser" class="notrun"> | |
227 <button type="button" onclick="SocketAddressNaClToBrowser()"> | |
228 Run Test | |
229 </button> | |
230 </td> | |
231 <td align=center id="mem_nacl_browser" class="notrun"> | |
232 <button type="button" onclick="SharedMemoryNaClToBrowser()"> | |
233 Run Test | |
234 </button> | |
235 </td> | |
236 </tr> | |
237 <tr> | |
238 <td> <b> NaCl to NaCl </b> </td> | |
239 <td align=center id="addr_nacl_nacl" class="notrun"> | |
240 <button type="button" onclick="SocketAddressNaClToNacl()"> | |
241 Run Test | |
242 </button> | |
243 </td> | |
244 <td align=center id="mem_nacl_nacl" class="notrun"> | |
245 <button type="button" onclick="SharedMemoryNaClToNaCl()"> | |
246 Run Test | |
247 </button> | |
248 </td> | |
249 </tr> | |
250 </table> | |
251 <table summary="The color codes used for identifying test outcomes"> | |
252 <tr> <td align="center"> <em> Legend </em> </td> </tr> | |
253 <tr> <td align="center" class="notrun"> Test not run </td> </tr> | |
254 <tr> <td align="center" class="pass"> Test passed </td> </tr> | |
255 <tr> <td align="center" class="fail"> Test failed </td> </tr> | |
256 </table> | |
257 <br/> | |
258 <h2> Output logs </h2> | |
259 <br/> | |
260 <table border=5 cellpadding=5% summary="A three-column test output log"> | |
261 <tr> | |
262 <td> <b> General test output </b> </td> | |
263 <td> <b> Socket address test output </b> </td> | |
264 <td> <b> Shared memory test output </b> </td> | |
265 </tr> | |
266 <tr> | |
267 <td valign=top id="GeneralOutput"> </td> | |
268 <td valign=top id="SocketAddressOutput"> </td> | |
269 <td valign=top id="SharedMemoryOutput"> </td> | |
270 </tr> | |
271 </table> | |
272 | |
273 <div id=status>NO-STATUS</div> | |
274 | |
275 <embed type="application/x-nacl" id="nacl_client" | |
276 name="nacl_module" width="0" height="0" | |
277 src="srpc_nrd_client.nexe" /> | |
278 <embed type="application/x-nacl" id="nacl_server" | |
279 name="nacl_module" width="0" height="0" | |
280 src="srpc_nrd_server.nexe" /> | |
281 | |
282 <script type="text/javascript" src="nacl_js_lib.js"></script> | |
283 <script type="text/javascript"> | |
284 //<![CDATA[ | |
285 var nacllib = new NaclLib("nacl_module", "status", 500); | |
286 | |
287 nacllib.test = function() { | |
288 server = document.getElementById("nacl_server"); | |
289 client = document.getElementById("nacl_client"); | |
290 RunAllTests(); | |
291 if (0 == num_passing && 0 == num_failing) { | |
292 return "No tests run."; | |
293 } else if (0 != num_failing) { | |
294 return "Tests failed."; | |
295 } else { | |
296 // Set the magic Selenium variable to signal success. | |
297 document.cookie = 'status=OK'; | |
298 return ""; | |
299 } | |
300 } | |
301 //]]> | |
302 </script> | |
303 </body> | |
304 </html> | |
OLD | NEW |