Commit ea37c98a authored by binji@chromium.org's avatar binji@chromium.org

[NaCl SDK] Don't exit from nacl_io_test before posting message to JS.

In the nacl_io_test there's a race condition between the NaCl module exiting
and a posted message from the module being handled by JavaScript.

To fix it, when running in the browser, we wait indefinitely and assume the
JavaScript will kill the module when it is ready.

(This fixes a flake that can be seen in
http://build.chromium.org/p/client.nacl.sdk/builders/mac-sdk-multi/builds/5838/steps/Run%20Tests/logs/stdio

BUG=none
R=sbc@chromium.org

Review URL: https://codereview.chromium.org/23531034

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@222065 0039d316-1c4b-4281-b951-d872f2087c98
parent ad8e142e
...@@ -237,6 +237,14 @@ var common = (function() { ...@@ -237,6 +237,14 @@ var common = (function() {
common.naclModule.style.height = '0'; common.naclModule.style.height = '0';
} }
/**
* Remove the NaCl module from the page.
*/
function removeModule() {
common.naclModule.parentNode.removeChild(common.naclModule);
common.naclModule = null;
}
/** /**
* Return true when |s| starts with the string |prefix|. * Return true when |s| starts with the string |prefix|.
* *
...@@ -376,6 +384,7 @@ var common = (function() { ...@@ -376,6 +384,7 @@ var common = (function() {
domContentLoaded: domContentLoaded, domContentLoaded: domContentLoaded,
createNaClModule: createNaClModule, createNaClModule: createNaClModule,
hideModule: hideModule, hideModule: hideModule,
removeModule: removeModule,
logMessage: logMessage, logMessage: logMessage,
updateStatus: updateStatus updateStatus: updateStatus
}; };
......
...@@ -46,6 +46,15 @@ function endCommand(testName, testResult) { ...@@ -46,6 +46,15 @@ function endCommand(testName, testResult) {
function testendCommand() { function testendCommand() {
testsFinished = true; testsFinished = true;
common.removeModule();
if (failedTests) {
common.updateStatus('FAILED');
document.getElementById('statusField').classList.add('failed');
} else {
common.updateStatus('OK');
document.getElementById('statusField').classList.add('ok');
}
} }
function handleMessage(event) { function handleMessage(event) {
......
...@@ -60,7 +60,15 @@ int example_main(int argc, char* argv[]) { ...@@ -60,7 +60,15 @@ int example_main(int argc, char* argv[]) {
::testing::InitGoogleTest(&argc, argv); ::testing::InitGoogleTest(&argc, argv);
::testing::UnitTest::GetInstance()->listeners() ::testing::UnitTest::GetInstance()->listeners()
.Append(new GTestEventListener()); .Append(new GTestEventListener());
return RUN_ALL_TESTS(); int result = RUN_ALL_TESTS();
// When running as an automated test, we don't want the final message
// ("testend") to be dropped, so don't exit. The web page will kill the
// plugin if it needs to.
while(1);
// Silence the warning.
return result;
} }
// Register the function to call once the Instance Object is initialized. // Register the function to call once the Instance Object is initialized.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment