Part 1. use custom XREExeF and UpdRootD - Bug 889183 - mozapps/update xpcshell tests cannot be run concurrently. r=bbondy

This commit is contained in:
Robert Strong 2013-07-16 19:19:03 -07:00
parent 45938dc1bd
commit 3fd3de316f
55 changed files with 212 additions and 5 deletions

View File

@ -393,7 +393,7 @@ function pathHandler(metadata, response) {
* @return The relative path to the directory where the update will be applied.
*/
function getApplyDirPath() {
return TEST_ID + APPLY_TO_DIR_SUFFIX;
return TEST_ID + APPLY_TO_DIR_SUFFIX + "appdir/";
}
/**
@ -1238,7 +1238,7 @@ function cleanupUpdaterTest() {
}
// Try to remove the updates and the apply to directories.
let applyToDir = getApplyDirFile(null, true);
let applyToDir = getApplyDirFile(null, true).parent;
try {
removeDirRecursive(applyToDir);
}
@ -2160,6 +2160,59 @@ function adjustPathsOnWindows() {
let gWindowsBinDir = null;
/**
* This function makes XREExeF and UpdRootD point to unique locations so
* xpcshell tests can run in parallel.
*/
function adjustGeneralPaths() {
let dirProvider = {
getFile: function DP_getFile(prop, persistent) {
persistent.value = true;
if (prop == XRE_EXECUTABLE_FILE)
return do_get_file(getApplyDirPath() + "test" + APP_BIN_SUFFIX, true);
if (prop == XRE_UPDATE_ROOT_DIR)
return do_get_file(getApplyDirPath(), true);
return null;
},
QueryInterface: function(iid) {
if (iid.equals(AUS_Ci.nsIDirectoryServiceProvider) ||
iid.equals(AUS_Ci.nsISupports))
return this;
throw AUS_Cr.NS_ERROR_NO_INTERFACE;
}
};
let ds = Services.dirsvc.QueryInterface(AUS_Ci.nsIDirectoryService);
ds.registerProvider(dirProvider);
do_register_cleanup(function() {
ds.unregisterProvider(dirProvider);
let testBin = do_get_file(getApplyDirPath() + "test" + APP_BIN_SUFFIX, true);
// Try to remove the test.bin file if it exists (it shouldn't).
if (testBin.exists()) {
try {
testBin.remove(false);
}
catch (e) {
dump("Unable to remove file\n" +
"path: " + updatesDir.path + "\n" +
"Exception: " + e + "\n");
}
}
let testDir = do_get_file(getApplyDirPath(), true).parent;
// Try to remove the directory used to apply updates (this is non-fatal
// for the test).
if (testDir.exists()) {
try {
removeDirRecursive(testDir);
}
catch (e) {
dump("Unable to remove directory\n" +
"path: " + updatesDir.path + "\n" +
"Exception: " + e + "\n");
}
}
});
}
/**
* This function returns the current process directory on Windows and Linux, and
* the application bundle directory on Mac.

View File

@ -5,10 +5,14 @@
/* General Update Service Tests */
const TEST_ID = "0010";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
// Verify write access to the custom app dir
logTestInfo("testing write access to the application directory");
removeUpdateDirsAndFiles();

View File

@ -5,12 +5,17 @@
/* General Update Check Update XML Tests */
const TEST_ID = "0020";
var gNextRunFunc;
var gExpectedCount;
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
setUpdateURLOverride();
setUpdateChannel("test_channel");

View File

@ -5,6 +5,8 @@
/* General MAR File Download Tests */
const TEST_ID = "0030";
const INC_CONTRACT_ID = "@mozilla.org/network/incremental-download;1";
AUS_Cu.import("resource://gre/modules/FileUtils.jsm");
AUS_Cu.import("resource://gre/modules/Services.jsm");
@ -22,6 +24,9 @@ var gIncrementalDownloadErrorType = 0;
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
Services.prefs.setBoolPref(PREF_APP_UPDATE_STAGING_ENABLED, false);
removeUpdateDirsAndFiles();
setUpdateURLOverride();

View File

@ -3,9 +3,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* General URL Construction Tests */
Components.utils.import("resource://gre/modules/ctypes.jsm")
/* General URL Construction Tests */
const TEST_ID = "0040";
const URL_PREFIX = URL_HOST + URL_PATH + "/";
@ -14,6 +16,9 @@ var gAppInfo;
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
// The mock XMLHttpRequest is MUCH faster
overrideXHR(callHandleEvent);

View File

@ -11,6 +11,8 @@
// 2152398868, 2152398878, 2152398890, 2152398919, 2152398920, 2153390069,
// 2152398918, 2152398861
const TEST_ID = "0050";
var gNextRunFunc;
var gExpectedStatusCode;
var gExpectedStatusText;
@ -18,6 +20,9 @@ var gExpectedStatusText;
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
setUpdateURLOverride();
standardInit();

View File

@ -5,10 +5,14 @@
/* General Update Manager Tests */
const TEST_ID = "0060";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing addition of a successful update to " + FILE_UPDATES_DB +
" and verification of update properties with the format prior " +
"to bug 530872");

View File

@ -5,10 +5,14 @@
/* General Update Manager Tests */
const TEST_ID = "0061";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing removal of an update download in progress for an " +
"older version of the application on startup (bug 485624)");
removeUpdateDirsAndFiles();

View File

@ -5,10 +5,14 @@
/* General Update Manager Tests */
const TEST_ID = "0062";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing resuming an update download in progress for the same " +
"version of the application on startup (bug 485624)");
removeUpdateDirsAndFiles();

View File

@ -5,10 +5,14 @@
/* General Update Manager Tests */
const TEST_ID = "0063";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing removing an active update for a channel that is not" +
"valid due to switching channels (bug 486275)");
removeUpdateDirsAndFiles();

View File

@ -5,10 +5,14 @@
/* General Update Manager Tests */
const TEST_ID = "0064";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing removal of an update download in progress for the " +
"same version of the application with the same application " +
"build id on startup (bug 536547)");

View File

@ -5,10 +5,14 @@
/* General Update Directory Cleanup Tests */
const TEST_ID = "0070";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);

View File

@ -5,10 +5,14 @@
/* General Update Directory Cleanup Tests */
const TEST_ID = "0071";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);

View File

@ -4,10 +4,14 @@
/* General Update Directory Cleanup Tests - Bug 539717 */
const TEST_ID = "0072";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);

View File

@ -4,10 +4,14 @@
/* General Update Directory Cleanup Tests - Bug 601701 */
const TEST_ID = "0073";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
writeUpdatesToXMLFile(getLocalUpdatesXMLString(""), false);

View File

@ -8,10 +8,14 @@
* preference is true.
*/
const TEST_ID = "0080";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing nsIUpdatePrompt notifications should not be seen " +
"when the " + PREF_APP_UPDATE_SILENT + " preference is true");

View File

@ -7,10 +7,14 @@
* showUpdateAvailable when there is already an application update window open.
*/
const TEST_ID = "0081";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing nsIUpdatePrompt notifications should not be seen when " +
"there is already an application update window open");

View File

@ -7,9 +7,14 @@
* unsupported system update when it has already been shown (bug 843497).
*/
const TEST_ID = "0082";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
removeUpdateDirsAndFiles();
setUpdateURLOverride();
// The mock XMLHttpRequest is MUCH faster

View File

@ -238,6 +238,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_COMPLETE_FILE);
let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);

View File

@ -240,6 +240,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_PARTIAL_FILE);
let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);

View File

@ -233,6 +233,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_PARTIAL_FILE);
let updatesDir = do_get_file(TEST_ID + UPDATES_DIR_SUFFIX);

View File

@ -271,6 +271,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -5,7 +5,7 @@
/* Test version downgrade MAR security check */
const TEST_ID = "0113";
const TEST_ID = "0113-VDC";
// We don't actually care if the MAR has any data, we only care about the
// application return code and update.status result.
@ -20,6 +20,9 @@ function run_test() {
// Setup an old version MAR file
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_OLD_VERSION_FILE);
// Apply the MAR

View File

@ -240,6 +240,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_PARTIAL_FILE);

View File

@ -5,7 +5,7 @@
/* Test product/channel MAR security check */
const TEST_ID = "0114";
const TEST_ID = "0114-PCC";
// We don't actually care if the MAR has any data, we only care about the
// application return code and update.status result.
@ -18,6 +18,8 @@ function run_test() {
return;
}
adjustGeneralPaths();
// Setup a wrong channel MAR file
do_register_cleanup(cleanupUpdaterTest);
setupUpdaterTest(MAR_WRONG_CHANNEL_FILE);

View File

@ -232,6 +232,8 @@ ADDITIONAL_TEST_DIRS = [
function run_test() {
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_PARTIAL_FILE);

View File

@ -194,6 +194,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_COMPLETE_WIN_FILE);
gCallbackBinFile = "exe0.exe";

View File

@ -196,6 +196,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_IN_USE_WIN_FILE);
gCallbackBinFile = "exe0.exe";

View File

@ -194,6 +194,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_WIN_FILE);

View File

@ -196,6 +196,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_IN_USE_WIN_FILE);

View File

@ -237,6 +237,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_COMPLETE_FILE);
// Launch the callback helper application so it is in use during the update

View File

@ -237,6 +237,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -187,6 +187,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -187,6 +187,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -187,6 +187,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_COMPLETE_FILE);
// Exclusively lock an existing file so it is in use during the update

View File

@ -188,6 +188,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_PARTIAL_FILE);
// Exclusively lock an existing file so it is in use during the update

View File

@ -187,6 +187,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -188,6 +188,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_PARTIAL_FILE);

View File

@ -187,6 +187,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -188,6 +188,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_PARTIAL_FILE);

View File

@ -193,6 +193,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_COMPLETE_FILE);
// Launch an existing file so it is in use during the update

View File

@ -196,6 +196,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_IN_USE_WIN_FILE);
// Launch an existing file so it is in use during the update

View File

@ -193,6 +193,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_COMPLETE_FILE);
let fileInUseBin = getApplyDirFile(TEST_DIRS[4].relPathDir +

View File

@ -236,6 +236,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
setupUpdaterTest(MAR_IN_USE_WIN_FILE);
let fileInUseBin = getApplyDirFile(TEST_DIRS[2].relPathDir +

View File

@ -193,6 +193,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -196,6 +196,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_IN_USE_WIN_FILE);

View File

@ -193,6 +193,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -236,6 +236,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_IN_USE_WIN_FILE);

View File

@ -193,6 +193,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -196,6 +196,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_IN_USE_WIN_FILE);

View File

@ -193,6 +193,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_COMPLETE_FILE);

View File

@ -236,6 +236,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(cleanupUpdaterTest);
adjustGeneralPaths();
gBackgroundUpdate = true;
setupUpdaterTest(MAR_IN_USE_WIN_FILE);

View File

@ -7,10 +7,14 @@
* partial update.
*/
const TEST_ID = "bug595059";
function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("testing Bug 595059 - calling nsIUpdatePrompt::showUpdateError " +
"should call getNewPrompter and alert on the object returned " +
"by getNewPrompter when the update.state = " + STATE_FAILED +

View File

@ -5,6 +5,8 @@
/* Offline retry test (Bug 794211) */
const TEST_ID = "bug794211";
// Needs to be in sync w/ nsUpdateService.js
const NETWORK_ERROR_OFFLINE = 111;
@ -12,6 +14,8 @@ function run_test() {
do_test_pending();
do_register_cleanup(end_test);
adjustGeneralPaths();
logTestInfo("test when an update check fails because the network is " +
"offline that we check again when the network comes online. " +
"(Bug 794211)");

View File

@ -4,6 +4,8 @@
*/
AUS_Cu.import("resource://gre/modules/FileUtils.jsm");
const TEST_ID = "bug794211";
const KEY_UPDATE_ARCHIVE_DIR = "UpdArchD"
let gActiveUpdate = null;
@ -28,6 +30,8 @@ function run_test() {
do_register_cleanup(end_test);
DEBUG_AUS_TEST = true;
adjustGeneralPaths();
removeUpdateDirsAndFiles();
setUpdateURLOverride();
overrideXHR(xhr_pt1);