Bug 1165061 - Fix Intermittent test_0102_background_restartNotification_staging.xul by not copying app files when staging for tests and enable the tests for Linux and Mac. r=spohl

This commit is contained in:
Robert Strong 2015-06-03 11:29:51 -07:00
Родитель 97786c5695
Коммит e20b2bd833
13 изменённых файлов: 180 добавлений и 53 удалений

Просмотреть файл

@ -18,8 +18,8 @@ support-files =
[test_0015_check_incompat_basic_addons.xul]
[test_0016_check_incompat_basic_license_addons.xul]
[test_0017_check_staging_basic.xul]
skip-if = os != 'win'
reason = Bug 918029 and bug 1164560 - timeout caused by copying too many files.
skip-if = asan
reason = Bug 1168003
[test_0021_check_billboard.xul]
[test_0022_check_billboard_license.xul]
[test_0023_check_incompat_billboard.xul]
@ -60,11 +60,15 @@ reason = Bug 918029 and bug 1164560 - timeout caused by copying too many files.
[test_0094_restartNotification_remote.xul]
[test_0095_restartNotification_remoteInvalidNumber.xul]
[test_0096_restartNotification_stagedBackground.xul]
skip-if = asan
reason = Bug 1168003
[test_0097_restartNotification_stagedServiceBackground.xul]
skip-if = os != 'win'
reason = only Windows has the maintenance service.
[test_0101_background_restartNotification.xul]
[test_0102_background_restartNotification_staging.xul]
skip-if = os == 'linux'
reason = Bug 918029 - timeout caused by copying too many files.
skip-if = asan
reason = Bug 1168003
[test_0103_background_restartNotification_stagingService.xul]
skip-if = os != 'win'
reason = only Windows has the maintenance service.

Просмотреть файл

@ -31,6 +31,8 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
gUseTestUpdater = true;
function runTest() {
debugDump("entering");

Просмотреть файл

@ -24,6 +24,8 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
gUseTestUpdater = true;
function runTest() {
debugDump("entering");

Просмотреть файл

@ -24,6 +24,8 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
gUseTestUpdater = true;
function runTest() {
debugDump("entering");

Просмотреть файл

@ -24,6 +24,8 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
gUseTestUpdater = true;
function runTest() {
debugDump("entering");

Просмотреть файл

@ -24,6 +24,8 @@ const TESTS = [ {
buttonClick: "extra1"
} ];
gUseTestUpdater = true;
function runTest() {
debugDump("entering");

Просмотреть файл

@ -81,7 +81,29 @@ function runTest() {
", Exception: " + e);
}
resetAddons(finishTest);
resetAddons(cleanupRestoreUpdaterBackup);
}
/**
* After all tests finish this will repeatedly attempt to restore the real
* updater if it exists and then call finishTest after the restore is
* successful.
*/
function cleanupRestoreUpdaterBackup() {
debugDump("entering");
try {
// Windows debug builds keep the updater file in use for a short period of
// time after the updater process exits.
restoreUpdaterBackup();
} catch (e) {
logTestInfo("Attempt to restore the backed up updater failed... " +
"will try again, Exception: " + e);
SimpleTest.executeSoon(cleanupRestoreUpdaterBackup);
return;
}
SimpleTest.executeSoon(finishTest);
}
function finishTest() {

Просмотреть файл

@ -216,6 +216,7 @@ var gPrefToCheck;
var gDisableNoUpdateAddon = false;
var gDisableUpdateCompatibilityAddon = false;
var gDisableUpdateVersionAddon = false;
var gUseTestUpdater = false;
// Set to true to log additional information for debugging. To log additional
// information for an individual test set DEBUG_AUS_TEST to true in the test's
@ -330,9 +331,10 @@ function runTestDefaultWaitForWindowClosed() {
setupFiles();
setupPrefs();
gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "1");
removeUpdateDirsAndFiles();
reloadUpdateManagerData();
setupAddons(runTest);
setupAddons(setupTestUpdater);
}
}
@ -358,6 +360,7 @@ function finishTestDefault() {
verifyTestsRan();
resetPrefs();
gEnv.set("MOZ_TEST_SKIP_UPDATE_STAGE", "");
resetFiles();
removeUpdateDirsAndFiles();
reloadUpdateManagerData();
@ -367,7 +370,7 @@ function finishTestDefault() {
gDocElem.removeEventListener("pageshow", onPageShowDefault, false);
}
finishTestDefaultWaitForWindowClosed();
finishTestRestoreUpdaterBackup();
}
/**
@ -390,6 +393,28 @@ function finishTestTimeout(aTimer) {
}
}
/**
* When a test finishes this will repeatedly attempt to restore the real updater
* for tests that use the test updater and then call
* finishTestDefaultWaitForWindowClosed after the restore is successful.
*/
function finishTestRestoreUpdaterBackup() {
if (gUseTestUpdater) {
try {
// Windows debug builds keep the updater file in use for a short period of
// time after the updater process exits.
restoreUpdaterBackup();
} catch (e) {
logTestInfo("Attempt to restore the backed up updater failed... " +
"will try again, Exception: " + e);
SimpleTest.executeSoon(finishTestRestoreUpdaterBackup);
return;
}
}
finishTestDefaultWaitForWindowClosed();
}
/**
* If an update window is found SimpleTest.executeSoon can callback before the
* update window is fully closed especially with debug builds. If an update
@ -400,6 +425,7 @@ function finishTestTimeout(aTimer) {
function finishTestDefaultWaitForWindowClosed() {
gCloseWindowTimeoutCounter++;
if (gCloseWindowTimeoutCounter > CLOSE_WINDOW_TIMEOUT_MAXCOUNT) {
SimpleTest.requestCompleteLog();
SimpleTest.finish();
return;
}
@ -752,7 +778,7 @@ function checkIncompatbleList() {
for (let i = 0; i < gIncompatibleListbox.itemCount; i++) {
let label = gIncompatibleListbox.getItemAtIndex(i).label;
// Use indexOf since locales can change the text displayed
ok(label.indexOf("noupdate") != -1, "Checking that only incompatible " +
ok(label.indexOf("noupdate") != -1, "Checking that only incompatible " +
"add-ons that don't have an update are listed in the incompatible list");
}
}
@ -875,26 +901,6 @@ function verifyTestsRan() {
}
}
/**
* Restore the updater that was backed up. This is called both in setupFiles
* and resetFiles. It is called in setupFiles before the backup is done in
* case the previous test failed. It is called in resetFiles to put things
* back to its original state.
*/
function resetUpdaterBackup() {
let baseAppDir = getAppBaseDir();
let updater = baseAppDir.clone();
let updaterBackup = baseAppDir.clone();
updater.append(FILE_UPDATER_BIN);
updaterBackup.append(FILE_UPDATER_BIN_BAK);
if (updaterBackup.exists()) {
if (updater.exists()) {
updater.remove(true);
}
updaterBackup.moveTo(baseAppDir, FILE_UPDATER_BIN);
}
}
/**
* Creates a backup of files the tests need to modify so they can be restored to
* the original file when the test has finished and then modifies the files.
@ -910,30 +916,101 @@ function setupFiles() {
updateSettingsIni = baseAppDir.clone();
updateSettingsIni.append(FILE_UPDATE_SETTINGS_INI);
writeFile(updateSettingsIni, UPDATE_SETTINGS_CONTENTS);
}
// Just in case the last test failed, try to reset.
resetUpdaterBackup();
// Move away the real updater
let updater = baseAppDir.clone();
updater.append(FILE_UPDATER_BIN);
updater.moveTo(baseAppDir, FILE_UPDATER_BIN_BAK);
// Move in the test only updater
let testUpdaterDir = Cc["@mozilla.org/file/directory_service;1"].
getService(Ci.nsIProperties).
get("CurWorkD", Ci.nsILocalFile);
let relPath = REL_PATH_DATA;
let pathParts = relPath.split("/");
for (let i = 0; i < pathParts.length; ++i) {
testUpdaterDir.append(pathParts[i]);
/**
* For tests that use the test updater restores the backed up real updater if
* it exists and tries again on failure since Windows debug builds at times
* leave the file in use. After success moveRealUpdater is called to continue
* the setup of the test updater. For tests that don't use the test updater
* runTest will be called.
*/
function setupTestUpdater() {
if (!gUseTestUpdater) {
runTest();
return;
}
let testUpdater = testUpdaterDir.clone();
testUpdater.append(FILE_UPDATER_BIN);
if (testUpdater.exists()) {
try {
restoreUpdaterBackup();
} catch (e) {
logTestInfo("Attempt to restore the backed up updater failed... " +
"will try again, Exception: " + e);
SimpleTest.executeSoon(setupTestUpdater);
return;
}
moveRealUpdater();
}
/**
* Backs up the real updater and tries again on failure since Windows debug
* builds at times leave the file in use. After success it will call
* copyTestUpdater to continue the setup of the test updater.
*/
function moveRealUpdater() {
try {
// Move away the real updater
let baseAppDir = getAppBaseDir();
let updater = baseAppDir.clone();
updater.append(FILE_UPDATER_BIN);
updater.moveTo(baseAppDir, FILE_UPDATER_BIN_BAK);
} catch (e) {
logTestInfo("Attempt to move the real updater out of the way failed... " +
"will try again, Exception: " + e);
SimpleTest.executeSoon(moveRealUpdater);
return;
}
copyTestUpdater();
}
/**
* Copies the test updater so it can be used by tests and tries again on failure
* since Windows debug builds at times leave the file in use. After success it
* will call runTest to continue the test.
*/
function copyTestUpdater() {
try {
// Copy the test updater
let baseAppDir = getAppBaseDir();
let testUpdaterDir = Services.dirsvc.get("CurWorkD", Ci.nsILocalFile);
let relPath = REL_PATH_DATA;
let pathParts = relPath.split("/");
for (let i = 0; i < pathParts.length; ++i) {
testUpdaterDir.append(pathParts[i]);
}
let testUpdater = testUpdaterDir.clone();
testUpdater.append(FILE_UPDATER_BIN);
testUpdater.copyToFollowingLinks(baseAppDir, FILE_UPDATER_BIN);
} catch (e) {
logTestInfo("Attempt to copy the test updater failed... " +
"will try again, Exception: " + e);
SimpleTest.executeSoon(copyTestUpdater);
return;
}
runTest();
}
/**
* Restores the updater that was backed up. This is called in setupTestUpdater
* before the backup of the real updater is done in case the previous test
* failed to restore the updater, in finishTestDefaultWaitForWindowClosed when
* the test has finished, and in test_9999_cleanup.xul after all tests have
* finished.
*/
function restoreUpdaterBackup() {
let baseAppDir = getAppBaseDir();
let updater = baseAppDir.clone();
let updaterBackup = baseAppDir.clone();
updater.append(FILE_UPDATER_BIN);
updaterBackup.append(FILE_UPDATER_BIN_BAK);
if (updaterBackup.exists()) {
if (updater.exists()) {
updater.remove(true);
}
updaterBackup.moveTo(baseAppDir, FILE_UPDATER_BIN);
}
}
@ -1022,7 +1099,6 @@ function resetFiles() {
", Exception: " + e);
}
}
resetUpdaterBackup();
}
/**

Просмотреть файл

@ -130,6 +130,10 @@ XPCOMUtils.defineLazyGetter(this, "gPrefRoot", function test_gPR() {
return Services.prefs.getBranch(null);
});
XPCOMUtils.defineLazyServiceGetter(this, "gEnv",
"@mozilla.org/process/environment;1",
"nsIEnvironment");
XPCOMUtils.defineLazyGetter(this, "gZipW", function test_gZipW() {
return Cc["@mozilla.org/zipwriter;1"].
createInstance(Ci.nsIZipWriter);

Просмотреть файл

@ -18,7 +18,7 @@
// These are generated at compile time based on the DER file for the channel
// being used
#ifdef MOZ_VERIFY_MAR_SIGNATURE
#ifdef UPDATER_XPCSHELL_CERT
#ifdef TEST_UPDATER
#include "../xpcshellCert.h"
#else
#include "primaryCert.h"
@ -85,7 +85,7 @@ ArchiveReader::VerifySignature()
#ifndef MOZ_VERIFY_MAR_SIGNATURE
return OK;
#else
#ifdef UPDATER_XPCSHELL_CERT
#ifdef TEST_UPDATER
int rv = VerifyLoadedCert(mArchive, xpcshellCertData);
#else
int rv = VerifyLoadedCert(mArchive, primaryCertData);

Просмотреть файл

@ -8,6 +8,6 @@ Program('updater-xpcshell')
updater_rel_path = '../'
DIST_INSTALL = False
DEFINES['UPDATER_XPCSHELL_CERT'] = True
DEFINES['TEST_UPDATER'] = True
include('../updater-common.build')
FAIL_ON_WARNINGS = True

Просмотреть файл

@ -2262,7 +2262,18 @@ UpdateThreadFunc(void *param)
#endif
if (rv == OK && sStagedUpdate && !sIsOSUpdate) {
#ifdef TEST_UPDATER
// The MOZ_TEST_SKIP_UPDATE_STAGE environment variable prevents copying
// the files in dist/bin in the test updater when staging an update since
// this can cause tests to timeout.
if (getenv("MOZ_TEST_SKIP_UPDATE_STAGE")) {
rv = OK;
} else {
rv = CopyInstallDirToDestDir();
}
#else
rv = CopyInstallDirToDestDir();
#endif
}
if (rv == OK) {

Просмотреть файл

@ -4,7 +4,7 @@
// Microsoft Visual C++ generated resource script.
//
#ifdef UPDATER_XPCSHELL_CERT
#ifdef TEST_UPDATER
#include "../resource.h"
#define MANIFEST_PATH "../updater.exe.manifest"
#define COMCTL32_MANIFEST_PATH "../updater.exe.comctl32.manifest"