Bug 964550 - Make marStageSuccessComplete.js, marStageSuccessPartial.js, and marAppInUseStageSuccessComplete_unix.js xpcshell tests pass on Mac. r=bbondy
authorRobert Strong <robert.bugzilla@gmail.com>
Tue, 28 Jan 2014 19:14:15 -0800
changeset 181664 79bc68a348d5422e18917e0fcfcae048b6e58c4f
parent 181663 73ed67830408f08a84aae2c815771f8229085abb
child 181665 24ddba64280c9e330fd9bbbffa9599002bec6797
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs964550
milestone29.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 964550 - Make marStageSuccessComplete.js, marStageSuccessPartial.js, and marAppInUseStageSuccessComplete_unix.js xpcshell tests pass on Mac. r=bbondy
toolkit/mozapps/update/tests/shared.js
toolkit/mozapps/update/tests/unit_aus_update/head_update.js
toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
toolkit/mozapps/update/tests/unit_base_updater/xpcshell.ini
--- a/toolkit/mozapps/update/tests/shared.js
+++ b/toolkit/mozapps/update/tests/shared.js
@@ -53,26 +53,24 @@ const NS_APP_USER_PROFILE_50_DIR   = "Pr
 const NS_GRE_DIR                   = "GreD";
 const NS_XPCOM_CURRENT_PROCESS_DIR = "XCurProcD";
 const XRE_EXECUTABLE_FILE          = "XREExeF";
 const XRE_UPDATE_ROOT_DIR          = "UpdRootD";
 
 const CRC_ERROR   = 4;
 const WRITE_ERROR = 7;
 
-const DIR_PATCH                      = "0";
-const DIR_UPDATES                    = "updates";
+const DIR_PATCH        = "0";
+const DIR_UPDATES      = "updates";
 #ifdef XP_MACOSX
-const DIR_APP_REL_PATH = "/Contents/MacOS/";
-const DIR_APP_SUFFIX = ".app";
-const DIR_UPDATED = "Updated.app";
+const DIR_BIN_REL_PATH = "Contents/MacOS/";
+const DIR_UPDATED      = "Updated.app";
 #else
-const DIR_APP_REL_PATH = "/appdir/";
-const DIR_APP_SUFFIX = "";
-const DIR_UPDATED = "updated";
+const DIR_BIN_REL_PATH = "";
+const DIR_UPDATED      = "updated";
 #endif
 
 const FILE_BACKUP_LOG                = "backup-update.log";
 const FILE_LAST_LOG                  = "last-update.log";
 const FILE_UPDATER_INI               = "updater.ini";
 const FILE_UPDATES_DB                = "updates.xml";
 const FILE_UPDATE_ACTIVE             = "active-update.xml";
 const FILE_UPDATE_ARCHIVE            = "update.mar";
--- a/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
@@ -410,19 +410,16 @@ function setupTestCommon() {
 
   // Don't attempt to show a prompt when an update finishes.
   Services.prefs.setBoolPref(PREF_APP_UPDATE_SILENT, true);
 
   gGREDirOrig = getGREDir();
   gAppDirOrig = getAppBaseDir();
 
   let applyDir = getApplyDirFile(null, true).parent;
-  if (IS_MACOSX) {
-    applyDir = applyDir.parent;
-  }
 
   // Try to remove the directory used to apply updates and the updates directory
   // on platforms other than Windows. Since the test hasn't ran yet and the
   // directory shouldn't exist finished this is non-fatal for the test.
   if (applyDir.exists()) {
     logTestInfo("attempting to remove directory. Path: " + applyDir.path);
     try {
       removeDirRecursive(applyDir);
@@ -535,19 +532,16 @@ function cleanupTestCommon() {
       } catch (e) {
         logTestInfo("non-fatal error removing directory. Path: " +
                     updatesDir.path + ", Exception: " + e);
       }
     }
   }
 
   let applyDir = getApplyDirFile(null, true).parent;
-  if (IS_MACOSX) {
-    applyDir = applyDir.parent;
-  }
 
   // Try to remove the directory used to apply updates. Since the test has
   // already finished this is non-fatal for the test.
   if (applyDir.exists()) {
     logTestInfo("attempting to remove directory. Path: " + applyDir.path);
     try {
       removeDirRecursive(applyDir);
     } catch (e) {
@@ -669,35 +663,28 @@ function getAppVersion() {
   let iniParser = AUS_Cc["@mozilla.org/xpcom/ini-parser-factory;1"].
                   getService(AUS_Ci.nsIINIParserFactory).
                   createINIParser(iniFile);
   return iniParser.getString("App", "Version");
 }
 
 /**
  * Helper function for getting the relative path to the directory where the
- * application binary is located.
- * For Mac OS X the path will be:
- *   <test_file_leafname>.app/Contents/MacOS/
- * For other platforms the path will be:
- *   <test_file_leafname>/appdir/
+ * application binary is located (e.g. <test_file_leafname>/dir.app/).
  *
- * Note: The appdir subdirectory is needed for platforms other than Mac OS X so
- *       the tests can run in parallel due to update staging creating a lock
- *       file named moz_update_in_progress.lock in the parent directory of the
- *       installation directory.
+ * Note: The dir.app subdirectory under <test_file_leafname> is needed for
+ *       platforms other than Mac OS X so the tests can run in parallel due to
+ *       update staging creating a lock file named moz_update_in_progress.lock in
+ *       the parent directory of the installation directory.
  *
  * @return  The relative path to the directory where application binary is
  *          located.
  */
 function getApplyDirPath() {
-  if (IS_MACOSX) {
-    return gTestID + DIR_APP_SUFFIX + DIR_APP_REL_PATH;
-  }
-  return gTestID + DIR_APP_REL_PATH;
+  return gTestID + "/dir.app/";
 }
 
 /**
  * Helper function for getting the nsIFile for a file in the directory where the
  * update will be applied.
  *
  * The files for the update are located two directories below the apply to
  * directory since Mac OS X sets the last modified time for the root directory
@@ -747,64 +734,38 @@ function getTestDirFile(aRelPath) {
 }
 
 /**
  * Helper function for getting the directory that was updated. This can either
  * be the directory where the application binary is located or the directory
  * that contains the staged update.
  */
 function getUpdatedDirPath() {
-  let updatedDirPath = gTestID;
-  if (IS_MACOSX) {
-    updatedDirPath += DIR_APP_SUFFIX;
-  } else {
-    // The appdir subdirectory is needed so the tests can run in parallel due to
-    // update staging creating a lock file named moz_update_in_progress.lock in
-    // the parent directory of the installation directory.
-    updatedDirPath += DIR_APP_REL_PATH;
-  }
-  if (gStageUpdate) {
-    updatedDirPath += DIR_UPDATED + "/";
-  } else if (IS_MACOSX) {
-    updatedDirPath += DIR_APP_REL_PATH;
-  }
-  return updatedDirPath;
+  return getApplyDirPath() + (gStageUpdate ? DIR_UPDATED +  "/" : "");
 }
 
 /**
  * Helper function for getting the directory where files are added, removed,
  * and modified by the simple.mar update file.
  *
  * @return  nsIFile for the directory where files are added, removed, and
  *          modified by the simple.mar update file.
  */
 function getUpdateTestDir() {
-  let updateTestDir = getApplyDirFile(null, true);
-
-  if (IS_MACOSX) {
-    updateTestDir = updateTestDir.parent.parent;
-  }
-  updateTestDir.append("update_test");
-  return updateTestDir;
+  return getApplyDirFile("update_test", true);
 }
 
 /**
  * Helper function for getting the updating directory which is used by the
  * updater to extract the update manifest and patch files.
  *
  * @return  nsIFile for the directory for the updating directory.
  */
 function getUpdatingDir() {
-  let updatingDir = getApplyDirFile(null, true);
-
-  if (IS_MACOSX) {
-    updatingDir = updatingDir.parent.parent;
-  }
-  updatingDir.append("updating");
-  return updatingDir;
+  return getApplyDirFile("updating", true);
 }
 
 #ifdef XP_WIN
 XPCOMUtils.defineLazyGetter(this, "gInstallDirPathHash",
                             function test_gInstallDirPathHash() {
   // Figure out where we should check for a cached hash value
   if (!MOZ_APP_BASENAME)
     return null;
@@ -936,17 +897,17 @@ function getMockUpdRootD() {
 #else
 /**
  * Helper function for getting the update root directory used by the tests. This
  * returns the same directory as returned by nsXREDirProvider::GetUpdateRootDir
  * in nsXREDirProvider.cpp so an application will be able to find the update
  * when running a test that launches the application.
  */
 function getMockUpdRootD() {
-  return getApplyDirFile(null, true);
+  return getApplyDirFile(DIR_BIN_REL_PATH, true);
 }
 #endif
 
 /**
  * Helper function for getting the nsIFile for the directory where the update
  * has been applied.
  *
  * This will be the same as getApplyDirFile for foreground updates, but will
@@ -1046,16 +1007,17 @@ function runUpdate(aExpectedExitValue, a
     }
   }
 
   let applyToDir = getApplyDirFile(null, true);
   let applyToDirPath = applyToDir.path;
   if (gStageUpdate || gSwitchApp) {
     applyToDirPath += "/" + DIR_UPDATED + "/";
   }
+
   if (IS_WIN) {
     // Convert to native path
     applyToDirPath = applyToDirPath.replace(/\//g, "\\");
   }
 
   let callbackApp = getApplyDirFile("a/b/" + gCallbackBinFile);
   callbackApp.permissions = PERMS_DIRECTORY;
 
@@ -1336,37 +1298,38 @@ function copyFileToTestAppDir(aFileRelPa
   for (let i = 0; i < pathParts.length; i++) {
     if (pathParts[i]) {
       srcFile.append(pathParts[i]);
     }
   }
 
   if (IS_MACOSX && !srcFile.exists()) {
     logTestInfo("unable to copy file since it doesn't exist! Checking if " +
-                 fileRelPath + DIR_APP_SUFFIX + " exists. Path: " +
+                 fileRelPath + ".app exists. Path: " +
                  srcFile.path);
     srcFile = gGREDirOrig.clone();
     for (let i = 0; i < pathParts.length; i++) {
       if (pathParts[i]) {
-        srcFile.append(pathParts[i] + (pathParts.length - 1 == i ? DIR_APP_SUFFIX : ""));
+        srcFile.append(pathParts[i] + (pathParts.length - 1 == i ? ".app" : ""));
       }
     }
-    fileRelPath = fileRelPath + DIR_APP_SUFFIX;
+    fileRelPath = fileRelPath + ".app";
   }
+
   if (!srcFile.exists()) {
     do_throw("Unable to copy file since it doesn't exist! Path: " +
              srcFile.path);
   }
 
   // Symlink libraries. Note that the XUL library on Mac OS X doesn't have a
   // file extension and this will always be false on Windows.
   let shouldSymlink = (pathParts[pathParts.length - 1] == "XUL" ||
                        fileRelPath.substr(fileRelPath.length - 3) == ".so" ||
                        fileRelPath.substr(fileRelPath.length - 6) == ".dylib");
-  let destFile = getApplyDirFile(fileRelPath, true);
+  let destFile = getApplyDirFile(DIR_BIN_REL_PATH + fileRelPath, true);
   if (!shouldSymlink) {
     if (!destFile.exists()) {
       try {
         srcFile.copyToFollowingLinks(destFile.parent, destFile.leafName);
       } catch (e) {
         // Just in case it is partially copied
         if (destFile.exists()) {
           try {
@@ -2586,17 +2549,17 @@ function createAppInfo(aID, aName, aVers
  * and stderr to null. This is needed to prevent output from the application
  * from ending up in the xpchsell log.
  */
 function getProcessArgs(aExtraArgs) {
   if (!aExtraArgs) {
     aExtraArgs = [];
   }
 
-  let appBinPath = getApplyDirFile(FILE_APP_BIN, false).path;
+  let appBinPath = getApplyDirFile(DIR_BIN_REL_PATH + FILE_APP_BIN, false).path;
   if (/ /.test(appBinPath)) {
     appBinPath = '"' + appBinPath + '"';
   }
 
   let args;
   if (IS_UNIX) {
     let launchScript = getLaunchScript();
     // Precreate the script with executable permissions
@@ -2656,22 +2619,22 @@ function getLaunchScript() {
  */
 function adjustGeneralPaths() {
   let dirProvider = {
     getFile: function AGP_DP_getFile(aProp, aPersistent) {
       aPersistent.value = true;
       switch (aProp) {
         case NS_GRE_DIR:
           if (gUseTestAppDir) {
-            return getApplyDirFile(null, true);
+            return getApplyDirFile(DIR_BIN_REL_PATH, true);
           }
           break;
         case XRE_EXECUTABLE_FILE:
           if (gUseTestAppDir) {
-            return getApplyDirFile(FILE_APP_BIN, true);
+            return getApplyDirFile(DIR_BIN_REL_PATH + FILE_APP_BIN, true);
           }
           break;
         case XRE_UPDATE_ROOT_DIR:
           return getMockUpdRootD();
       }
       return null;
     },
     QueryInterface: function(aIID) {
@@ -2739,17 +2702,17 @@ function adjustGeneralPaths() {
 
 
 /**
  * Helper function for launching the application to apply an update.
  */
 function launchAppToApplyUpdate() {
   logTestInfo("start - launching application to apply update");
 
-  let appBin = getApplyDirFile(FILE_APP_BIN, false);
+  let appBin = getApplyDirFile(DIR_BIN_REL_PATH + FILE_APP_BIN, false);
 
   if (typeof(customLaunchAppToApplyUpdate) == typeof(Function)) {
     customLaunchAppToApplyUpdate();
   }
 
   let launchBin = getLaunchBin();
   let args = getProcessArgs();
   logTestInfo("launching " + launchBin.path + " " + args.join(" "));
--- a/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
+++ b/toolkit/mozapps/update/tests/unit_base_updater/marStageSuccessComplete.js
@@ -237,16 +237,18 @@ function runHelperProcess(args) {
   process.run(true, args, args.length);
   do_check_eq(process.exitValue, 0);
 }
 
 function createSymlink() {
   let args = ["setup-symlink", "moz-foo", "moz-bar", "target",
               getApplyDirFile().path + "/a/b/link"];
   runHelperProcess(args);
+  getApplyDirFile("a/b/link", false).permissions = 0o666;
+  
   args = ["setup-symlink", "moz-foo2", "moz-bar2", "target2",
           getApplyDirFile().path + "/a/b/link2", "change-perm"];
   runHelperProcess(args);
 }
 
 function removeSymlink() {
   let args = ["remove-symlink", "moz-foo", "moz-bar", "target",
               getApplyDirFile().path + "/a/b/link"];
@@ -283,18 +285,18 @@ function run_test() {
     TEST_FILES.push({
       description      : "Readable symlink",
       fileName         : "link",
       relPathDir       : "a/b/",
       originalContents : "test",
       compareContents  : "test",
       originalFile     : null,
       compareFile      : null,
-      originalPerms    : 0o664,
-      comparePerms     : 0o664
+      originalPerms    : 0o666,
+      comparePerms     : 0o666
     });
   }
 
   runUpdate(0, STATE_APPLIED, null);
 
   if (IS_MACOSX) {
     logTestInfo("testing last modified time on the apply to directory has " +
                 "changed after a successful update (bug 600098)");
--- a/toolkit/mozapps/update/tests/unit_base_updater/xpcshell.ini
+++ b/toolkit/mozapps/update/tests/unit_base_updater/xpcshell.ini
@@ -10,37 +10,36 @@
 head = head_update.js
 tail =
 generated-files = head_update.js
 
 [marSuccessComplete.js]
 [marSuccessPartial.js]
 [marFailurePartial.js]
 [marStageSuccessComplete.js]
-skip-if = os == 'mac' || toolkit == 'gonk'
+skip-if = toolkit == 'gonk'
 reason = bug 820380
 [marStageSuccessPartial.js]
-skip-if = os == 'mac'
 [marVersionDowngrade.js]
 run-if = os == 'win'
 [marWrongChannel.js]
 run-if = os == 'win'
 [marStageFailurePartial.js]
 [marCallbackAppSuccessComplete_win.js]
 run-if = os == 'win'
 [marCallbackAppSuccessPartial_win.js]
 run-if = os == 'win'
 [marCallbackAppStageSuccessComplete_win.js]
 run-if = os == 'win'
 [marCallbackAppStageSuccessPartial_win.js]
 run-if = os == 'win'
 [marAppInUseSuccessComplete.js]
 skip-if = toolkit == 'gonk'
 [marAppInUseStageSuccessComplete_unix.js]
-run-if = os == 'linux' || os == 'sunos'
+run-if = os == 'linux' || os == 'sunos' || os == 'mac'
 [marAppInUseStageFailureComplete_win.js]
 run-if = os == 'win'
 [marAppInUseFallbackStageFailureComplete_win.js]
 run-if = os == 'win'
 [marFileLockedFailureComplete_win.js]
 run-if = os == 'win'
 [marFileLockedFailurePartial_win.js]
 run-if = os == 'win'