Test only - additional logging and some cleanup for Bug 909489 - Intermittent test_0202_app_launch_apply_update_dirlocked.js | Test timed out | test failed (with xpcshell return code: 1). r=bbondy
authorRobert Strong <robert.bugzilla@gmail.com>
Fri, 30 Aug 2013 15:19:37 -0700
changeset 145140 7fce549724536ffe80bb2cf4abb9c10306b08158
parent 145139 aff6afb77f62802574a28e38fc9315b89c595200
child 145141 cb7653a95aa87d1444f260d8120821e7eed19b8a
push id25195
push userryanvm@gmail.com
push dateSat, 31 Aug 2013 01:00:12 +0000
treeherdermozilla-central@4ba8dda1ee31 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs909489
milestone26.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
Test only - additional logging and some cleanup for Bug 909489 - Intermittent test_0202_app_launch_apply_update_dirlocked.js | Test timed out | test failed (with xpcshell return code: 1). r=bbondy
toolkit/mozapps/update/test/unit/head_update.js.in
toolkit/mozapps/update/test/unit/test_0202_app_launch_apply_update_dirlocked.js
--- a/toolkit/mozapps/update/test/unit/head_update.js.in
+++ b/toolkit/mozapps/update/test/unit/head_update.js.in
@@ -313,16 +313,17 @@ if (APP_BIN_NAME == "xulrunner") {
     setUpdateChannel("test_channel");
   }
 }
 
 /**
  * Nulls out the most commonly used global vars used by tests as appropriate.
  */
 function cleanUp() {
+  logTestInfo("start - general test cleanup");
   removeUpdateDirsAndFiles();
 
   // Force the update manager to reload the update data to prevent it from
   // writing the old data to the files that have just been removed.
   reloadUpdateManagerData();
 
   if (gChannel) {
     gPrefRoot.removeObserver(PREF_APP_UPDATE_CHANNEL, observer);
@@ -343,16 +344,17 @@ function cleanUp() {
     gXHR.onerror     = null;
     gXHR.onload      = null;
     gXHR.onprogress  = null;
 
     gXHR             = null;
   }
 
   gTestserver = null;
+  logTestInfo("finish - general test cleanup");
 }
 
 /**
  * Sets the most commonly used preferences used by tests
  */
 function setDefaultPrefs() {
   Services.prefs.setBoolPref(PREF_APP_UPDATE_ENABLED, true);
   Services.prefs.setBoolPref(PREF_APP_UPDATE_METRO_ENABLED, true);
@@ -1557,24 +1559,51 @@ function removeCallbackCopy() {
   let appBinCopy = getAppDir();
   appBinCopy.append(TEST_ID + FILE_WIN_TEST_EXE);
   if (appBinCopy.exists()) {
     try {
       logTestInfo("attempting removal of file: " + appBinCopy.path);
       appBinCopy.remove(false);
     }
     catch (e) {
-      logTestInfo("non-fatal error removing file during cleanup (will try " +
-                  "again). File: " + appBinCopy.path + " Exception: " + e);
+      logTestInfo("non-fatal error removing file after test finished (will " +
+                  "try again). File: " + appBinCopy.path + " Exception: " + e);
       do_timeout(TEST_HELPER_TIMEOUT, removeCallbackCopy);
       return;
     }
   }
-  // Use a timeout to give any files that were in use additional 
-  // time to close.  Same as updater.exe without service tests.
+  logTestInfo("attempting removal of the updater binary");
+  removeUpdater();
+}
+
+
+/**
+ * Helper function for updater tests that removes the updater binary before
+ * ending the test so the updater binary isn't in use during test cleanup.
+ */
+function removeUpdater() {
+  if (IS_WIN) {
+    // Remove the copy of the application executable used for the test on
+    // Windows if it exists.
+    let updater = getUpdatesDir();
+    updater.append("0");
+    updater.append(UPDATER_BIN_FILE);
+    if (updater.exists()) {
+      try {
+        updater.remove(false);
+      }
+      catch (e) {
+        logTestInfo("non-fatal error removing file after test finished (will " +
+                    "try again). File: " + updater.path + " Exception: " + e);
+        do_timeout(TEST_HELPER_TIMEOUT, removeUpdater);
+        return;
+      }
+    }
+  }
+  logTestInfo("calling do_test_finished");
   do_test_finished();
 }
 
 // Waits until files that are in use that break tests are no longer in use and
 // then calls removeCallbackCopy.
 function waitForFilesInUse() {
   let maintSvcInstaller = getAppDir();
   maintSvcInstaller.append("MAINTENANCE_SERVICE_INSTALLER_BIN_FILE");
@@ -2108,18 +2137,20 @@ function adjustPathsOnWindows() {
           iid.equals(AUS_Ci.nsISupports))
         return this;
       throw AUS_Cr.NS_ERROR_NO_INTERFACE;
     }
   };
   let ds = Services.dirsvc.QueryInterface(AUS_Ci.nsIDirectoryService);
   ds.QueryInterface(AUS_Ci.nsIProperties).undefine(NS_GRE_DIR);
   ds.registerProvider(dirProvider);
-  do_register_cleanup(function() {
+  do_register_cleanup(function APOW_cleanup() {
+    logTestInfo("start - unregistering directory provider");
     ds.unregisterProvider(dirProvider);
+    logTestInfo("finish - unregistering directory provider");
   });
   logTestInfo("finish - setup new process directory");
 }
 
 let gWindowsBinDir = null;
 
 /**
  * This function makes XREExeF and UpdRootD point to unique locations so
--- a/toolkit/mozapps/update/test/unit/test_0202_app_launch_apply_update_dirlocked.js
+++ b/toolkit/mozapps/update/test/unit/test_0202_app_launch_apply_update_dirlocked.js
@@ -78,21 +78,23 @@ function symlinkUpdateFilesIntoBundleDir
   if (source2.exists()) {
     source2.remove(true);
   }
   ret = symlink(dest2.path, source2.path);
   do_check_eq(ret, 0);
   do_check_true(source2.exists());
 
   // Cleanup the symlinks when the test is finished.
-  do_register_cleanup(function() {
+  do_register_cleanup(function AUFIBD_cleanup() {
+    logTestInfo("start - unlinking symlinks");
     let ret = unlink(source.path);
     do_check_false(source.exists());
     let ret = unlink(source2.path);
     do_check_false(source2.exists());
+    logTestInfo("finish - unlinking symlinks");
   });
 
   // Now, make sure that getUpdatesRootDir returns the application bundle
   // directory, to make the various stuff in the test framework to work
   // correctly.
   getUpdatesRootDir = getAppDir;
 }
 
@@ -193,16 +195,17 @@ function run_test() {
     createInstance(AUS_Ci.nsIUpdateProcessor).
     processUpdate(gActiveUpdate);
 
   logTestInfo("processUpdate completed - calling checkUpdateApplied");
   checkUpdateApplied();
 }
 
 function end_test() {
+  logTestInfo("start - test cleanup");
   // Remove the files added by the update.
   let updateTestDir = getUpdateTestDir();
   try {
     logTestInfo("removing update test directory " + updateTestDir.path);
     removeDirRecursive(updateTestDir);
   }
   catch (e) {
     logTestInfo("unable to remove directory - path: " + updateTestDir.path +
@@ -225,16 +228,17 @@ function end_test() {
   }
 
   if (IS_UNIX) {
     // This will delete the launch script if it exists.
     getLaunchScript();
   }
 
   cleanUp();
+  logTestInfo("finish - test cleanup");
 }
 
 function shouldAdjustPathsOnMac() {
   // When running xpcshell tests locally, xpcshell and firefox-bin do not live
   // in the same directory.
   let dir = getCurrentProcessDir();
   return (IS_MACOSX && dir.leafName != "MacOS");
 }