Bug 757794 - Constant "command timed out: 1200 seconds without output" in test_0200_app_launch_apply_update.js and others. Ensure that timeout loops will always abort eventually. r=ehsan

--HG--
extra : rebase_source : d29af708ec3c8d26bb5bcc95c51e25b13f798072
This commit is contained in:
Mark Banner 2012-06-19 15:48:00 +01:00
parent 15986fc154
commit b8289dc31e
7 changed files with 115 additions and 21 deletions

View File

@ -18,12 +18,16 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
let gAppTimer;
let gProcess;
let gTimeoutRuns = 0;
function run_test() {
do_test_pending();
@ -236,19 +240,26 @@ function getUpdateTestDir() {
* the test.
*/
function checkUpdateFinished() {
gTimeoutRuns++;
// Don't proceed until the update.log has been created.
let log = getUpdatesDir();
log.append("0");
log.append(FILE_UPDATE_LOG);
if (!log.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for updates log to be created");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}
// Don't proceed until the update status is no longer pending or applying.
let status = readStatusFile();
if (status == STATE_PENDING || status == STATE_APPLYING) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for updates status to not be pending or applying");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}

View File

@ -21,6 +21,9 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
@ -28,6 +31,7 @@ const APP_TIMER_TIMEOUT = 15000;
let gAppTimer;
let gProcess;
let gActiveUpdate;
let gTimeoutRuns = 0;
// Override getUpdatesRootDir on Mac because we need to apply the update
// inside the bundle directory.
@ -327,9 +331,13 @@ function getUpdateTestDir() {
* Checks if the update has finished being applied in the background.
*/
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the update has been applied.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED_PLATFORM) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for update to be applied");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}
@ -459,11 +467,15 @@ function checkUpdateApplied() {
* the test.
*/
function checkUpdateFinished() {
gTimeoutRuns++;
// Don't proceed until the update status is no longer applied.
try {
let status = readStatusFile();
if (status != STATE_SUCCEEDED) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for succeeded state");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}
} catch (e) {
@ -477,7 +489,10 @@ function checkUpdateFinished() {
if (e.result == Components.results.NS_ERROR_FILE_IS_LOCKED) {
// This might happen on Windows in case the callback application has not
// finished its job yet. So, we'll wait some more.
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for file to be unlocked");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);
@ -493,7 +508,10 @@ function checkUpdateFinished() {
updatedDir.append(UPDATED_DIR_SUFFIX.replace("/", ""));
logTestInfo("testing " + updatedDir.path + " shouldn't exist");
if (updatedDir.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for update dir to not exist");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}

View File

@ -27,6 +27,8 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
@ -36,6 +38,7 @@ Components.utils.import("resource://gre/modules/ctypes.jsm");
let gAppTimer;
let gProcess;
let gActiveUpdate;
let gTimeoutRuns = 0;
// Override getUpdatesRootDir on Mac because we need to apply the update
// inside the bundle directory.
@ -356,9 +359,13 @@ function getUpdateTestDir() {
* Checks if the update has finished being applied in the background.
*/
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the update has been applied.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED_PLATFORM) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for update to be applied");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}
@ -489,10 +496,14 @@ function checkUpdateApplied() {
*/
function checkUpdateFinished() {
// Don't proceed until the update status is no longer applied.
gTimeoutRuns++;
try {
let status = readStatusFile();
if (status != STATE_SUCCEEDED) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for succeeded state");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}
} catch (e) {
@ -506,7 +517,10 @@ function checkUpdateFinished() {
if (e.result == Components.results.NS_ERROR_FILE_IS_LOCKED) {
// This might happen on Windows in case the callback application has not
// finished its job yet. So, we'll wait some more.
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for file to be unlocked");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);

View File

@ -18,10 +18,15 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
let gTimeoutRuns = 0;
function run_test() {
if (!shouldRunServiceTest()) {
return;
@ -198,7 +203,10 @@ function checkUpdateFinished() {
log.append("0");
log.append(FILE_UPDATE_LOG);
if (!log.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for updates log to be created");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}

View File

@ -21,6 +21,9 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
@ -28,6 +31,7 @@ const APP_TIMER_TIMEOUT = 15000;
let gAppTimer;
let gProcess;
let gActiveUpdate;
let gTimeoutRuns = 0;
// Override getUpdatesRootDir on Mac because we need to apply the update
// inside the bundle directory.
@ -335,9 +339,13 @@ function getUpdateTestDir() {
* Checks if the update has finished being applied in the background.
*/
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the update has been applied.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED_PLATFORM) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for state to be applied to platform");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}
@ -352,7 +360,10 @@ function checkUpdateApplied() {
let log = getUpdatesDir();
log.append(FILE_LAST_LOG);
if (!log.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whilst waiting for update log to be created");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}
@ -439,11 +450,15 @@ function checkUpdateApplied() {
* the test.
*/
function checkUpdateFinished() {
gTimeoutRuns++;
// Don't proceed until the update status is no longer applied.
try {
let status = readStatusFile();
if (status != STATE_SUCCEEDED) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for succeeded state");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}
} catch (e) {
@ -457,7 +472,10 @@ function checkUpdateFinished() {
if (e.result == Components.results.NS_ERROR_FILE_IS_LOCKED) {
// This might happen on Windows in case the callback application has not
// finished its job yet. So, we'll wait some more.
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded whilst waiting for file to be unlocked");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);

View File

@ -27,11 +27,15 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
let gActiveUpdate;
let gTimeoutRuns = 0;
// Override getUpdatesRootDir on Mac because we need to apply the update
// inside the bundle directory.
@ -300,7 +304,10 @@ function getUpdateTestDir() {
function checkUpdateApplied() {
// Don't proceed until the update has failed, and reset to pending.
if (gUpdateManager.activeUpdate.state != STATE_PENDING) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (++gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for pending state to finish");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}

View File

@ -27,6 +27,9 @@ const FILE_UPDATER_INI_BAK = "updater.ini.bak";
// Number of milliseconds for each do_timeout call.
const CHECK_TIMEOUT_MILLI = 1000;
// How many of CHECK_TIMEOUT_MILLI to wait before we abort the test.
const MAX_TIMEOUT_RUNS = 300;
// Maximum number of milliseconds the process that is launched can run before
// the test will try to kill it.
const APP_TIMER_TIMEOUT = 15000;
@ -36,6 +39,7 @@ Components.utils.import("resource://gre/modules/ctypes.jsm");
let gAppTimer;
let gProcess;
let gActiveUpdate;
let gTimeoutRuns = 0;
// Override getUpdatesRootDir on Mac because we need to apply the update
// inside the bundle directory.
@ -364,9 +368,13 @@ function getUpdateTestDir() {
* Checks if the update has finished being applied in the background.
*/
function checkUpdateApplied() {
gTimeoutRuns++;
// Don't proceed until the update has been applied.
if (gUpdateManager.activeUpdate.state != STATE_APPLIED_PLATFORM) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for update to be applied to the platform");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}
@ -381,7 +389,10 @@ function checkUpdateApplied() {
let log = getUpdatesDir();
log.append(FILE_LAST_LOG);
if (!log.exists()) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for update log to be created");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateApplied);
return;
}
@ -468,11 +479,15 @@ function checkUpdateApplied() {
* the test.
*/
function checkUpdateFinished() {
gTimeoutRuns++;
// Don't proceed until the update status is no longer applied.
try {
let status = readStatusFile();
if (status != STATE_SUCCEEDED) {
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for success status");
else
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
}
} catch (e) {
@ -484,9 +499,12 @@ function checkUpdateFinished() {
getAppConsoleLogPath();
} catch (e) {
if (e.result == Components.results.NS_ERROR_FILE_IS_LOCKED) {
// This might happen on Windows in case the callback application has not
// finished its job yet. So, we'll wait some more.
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
if (gTimeoutRuns > MAX_TIMEOUT_RUNS)
do_throw("Exceeded MAX_TIMEOUT_RUNS whist waiting for file to be unlocked");
else
// This might happen on Windows in case the callback application has not
// finished its job yet. So, we'll wait some more.
do_timeout(CHECK_TIMEOUT_MILLI, checkUpdateFinished);
return;
} else {
do_throw("getAppConsoleLogPath threw: " + e);