Bug 711692 - Intermittent service callback log failure fix. r=rstrong.
authorBrian R. Bondy <netzen@gmail.com>
Wed, 04 Jan 2012 23:19:18 -0500
changeset 85012 a788eb31a0aaf6c0a7d3c9b167ca1c727b3b0cc5
parent 85011 1dc69ce16ae3867ab718ac5eec7666d23d891324
child 85013 025e1bd0f6f26217530d56943d39fb53a49887c2
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersrstrong
bugs711692
milestone12.0a1
Bug 711692 - Intermittent service callback log failure fix. r=rstrong.
toolkit/mozapps/update/test/unit/head_update.js.in
--- a/toolkit/mozapps/update/test/unit/head_update.js.in
+++ b/toolkit/mozapps/update/test/unit/head_update.js.in
@@ -640,22 +640,22 @@ function runUpdateUsingService(aInitialS
     do_throw("Unable to find updater binary!");
   }
   let applyToUpdater = getApplyDirFile(null, true);
   if (applyToUpdater.path != binDir.path) {
     do_print("copying " + updater.path + " to: " + applyToUpdater.path);
     updater.copyTo(applyToUpdater, UPDATER_BIN_FILE);
   }
 
-  // We can't get sync behavior here since Firefox does not wait for the
-  // process launched through the service to finish.  Since the service
-  // launches the updater in the background, providing an observer argument
-  // doesn't solve anything either, so we will rely on watching the
-  // update.status file instead.
-  process.runAsync(args, args.length);
+  // Firefox does not wait for the service command to finish, but
+  // we still launch the process sync to avoid intemittent failures with
+  // the log file not being written out yet.
+  // We will rely on watching the update.status file and waiting for the service
+  // to stop to know the service command is done.
+  process.run(true, args, args.length);
 
   resetEnvironment();
 
   function timerCallback(timer) {
     // Wait for the expected status
     let status = readStatusFile(updatesDir);
     // For failed status, we don't care what the failure code is
     if (aExpectedStatus == STATE_FAILED) {
@@ -1160,16 +1160,26 @@ function checkCallbackAppLog() {
  */
 function checkCallbackServiceLog() {
   do_check_neq(gServiceLaunchedCallbackLog, null);
 
   let expectedLogContents = gServiceLaunchedCallbackArgs.join("\n") + "\n";
   let logFile = AUS_Cc["@mozilla.org/file/local;1"].createInstance(AUS_Ci.nsILocalFile);
   logFile.initWithPath(gServiceLaunchedCallbackLog);
   let logContents = readFile(logFile);
+ 
+  // It is possible for the log file contents check to occur before the log file
+  // contents are completely written so wait until the contents are the expected
+  // value. If the contents are never the expected value then the test will
+  // fail by timing out.
+  if (logContents != expectedLogContents) {
+    logTestInfo("callback service log not expected value, waiting longer");
+    do_timeout(TEST_HELPER_TIMEOUT, checkCallbackServiceLog);
+    return;
+  }
 
   logTestInfo("testing that the callback application successfully launched " +
               "and the expected command line arguments passed to it");
   do_check_eq(logContents, expectedLogContents);
 
   // Use a timeout to give any files that were in use additional time to close.
   do_timeout(TEST_HELPER_TIMEOUT, do_test_finished);
 }