| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2014 The Chromium Authors. All rights reserved. | 2 * Copyright 2014 The Chromium 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 // Post-message based test for simple rpc based access to name services. | 8 // Post-message based test for simple rpc based access to name services. |
| 9 // | 9 // |
| 10 | 10 |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 NaClSrpcDtor(&manifest_channel); | 421 NaClSrpcDtor(&manifest_channel); |
| 422 return; | 422 return; |
| 423 } | 423 } |
| 424 | 424 |
| 425 sb->DiscardOutput(); | 425 sb->DiscardOutput(); |
| 426 sb->Printf("File Contents:\n"); | 426 sb->Printf("File Contents:\n"); |
| 427 | 427 |
| 428 char buffer[4096]; | 428 char buffer[4096]; |
| 429 int len; | 429 int len; |
| 430 while ((len = read(desc, buffer, sizeof buffer - 1)) > 0) { | 430 while ((len = read(desc, buffer, sizeof buffer - 1)) > 0) { |
| 431 // NB: fgets does not discard the newline nor any carriage return | |
| 432 // character before that. | |
| 433 // | |
| 434 // Note that CR LF is the default end-of-line style for Windows. | |
| 435 // Furthermore, when the test_file (input data, which happens to | |
| 436 // be the nmf file) is initially created in a change list, the | |
| 437 // patch is sent to our try bots as text. This means that when | |
| 438 // the file arrives, it has CR LF endings instead of the original | |
| 439 // LF line endings. Since the expected or golden data is | |
| 440 // (manually) encoded in the HTML file's JavaScript, there will be | |
| 441 // a mismatch. After submission, the svn property svn:eol-style | |
| 442 // will be set to LF, so a clean check out should have LF and not | |
| 443 // CR LF endings, and the tests will pass without CR removal. | |
| 444 // However -- and there's always a however in long discourses -- | |
| 445 // if the nmf file is edited, say, because the test is being | |
| 446 // modified, and the modification is being done on a Windows | |
| 447 // machine, then it is likely that the editor used by the | |
| 448 // programmer will convert the file to CR LF endings. Which, | |
| 449 // unfortunatly, implies that the test will mysteriously fail | |
| 450 // again. | |
| 451 // | |
| 452 // To defend against such nonsense, we weaken the test slighty, | |
| 453 // and just strip the CR if it is present. | |
| 454 if (len >= 2 && buffer[len-1] == '\n' && buffer[len-2] == '\r') { | |
| 455 buffer[len-2] = '\n'; | |
| 456 buffer[len-1] = '\0'; | |
| 457 } | |
| 458 // Null terminate. | 431 // Null terminate. |
| 459 buffer[len] = 0; | 432 buffer[len] = '\0'; |
| 460 sb->Printf("%s", buffer); | 433 sb->Printf("%s", buffer); |
| 461 } | 434 } |
| 462 NaClSrpcDtor(&manifest_channel); | 435 NaClSrpcDtor(&manifest_channel); |
| 463 return; | 436 return; |
| 464 } | 437 } |
| 465 | 438 |
| 466 // HandleMessage gets invoked when postMessage is called on the DOM | 439 // HandleMessage gets invoked when postMessage is called on the DOM |
| 467 // element associated with this plugin instance. In this case, if we | 440 // element associated with this plugin instance. In this case, if we |
| 468 // are given a string, we'll post a message back to JavaScript with a | 441 // are given a string, we'll post a message back to JavaScript with a |
| 469 // reply -- essentially treating this as a string-based RPC. | 442 // reply -- essentially treating this as a string-based RPC. |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 | 508 |
| 536 namespace pp { | 509 namespace pp { |
| 537 | 510 |
| 538 // Factory function for your specialization of the Module object. | 511 // Factory function for your specialization of the Module object. |
| 539 Module* CreateModule() { | 512 Module* CreateModule() { |
| 540 fprintf(stderr, "CreateModule invoked\n"); fflush(NULL); | 513 fprintf(stderr, "CreateModule invoked\n"); fflush(NULL); |
| 541 return new MyModule(); | 514 return new MyModule(); |
| 542 } | 515 } |
| 543 | 516 |
| 544 } // namespace pp | 517 } // namespace pp |
| OLD | NEW |