Bug 711692 - Fail if service is started and doesn't stop at test start. r=bbondy.
authorRobert Strong <rstrong@mozilla.com>
Wed, 04 Jan 2012 23:19:19 -0500
changeset 85017 780d40dcf3c078dce9d9c9932d8958180d8442f7
parent 85016 5c67bc43f94d8e67e55c00c5331bf2850ec3c5ae
child 85018 bda3dc1ca333f941eeed6d8a5b7e6665cf9d5fa8
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)
reviewersbbondy
bugs711692
milestone12.0a1
Bug 711692 - Fail if service is started and doesn't stop at test start. r=bbondy.
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
@@ -549,37 +549,41 @@ function runUpdateUsingService(aInitialS
     let file = AUS_Cc["@mozilla.org/file/directory_service;1"].
                getService(AUS_Ci.nsIProperties).
                get("CmAppData", AUS_Ci.nsIFile);
     file.append("Mozilla");
     file.append("logs");
     file.append("maintenanceservice.log");
     return readFile(file);
   }
-  function waitForServiceStop() {
+  function waitForServiceStop(aFailTest) {
     logTestInfo("Waiting for service to stop if necessary...");
     // Use the helper bin to ensure the service is stopped. If not
     // stopped then wait for the service to be stopped (at most 20 seconds)
     let helperBin = do_get_file(HELPER_BIN_FILE);
     let helperBinArgs = ["wait-for-service-stop", 
                          "MozillaMaintenance", 
                          "20"];
     let helperBinProcess = AUS_Cc["@mozilla.org/process/util;1"].
                            createInstance(AUS_Ci.nsIProcess);
     helperBinProcess.init(helperBin);
     helperBinProcess.run(true, helperBinArgs, helperBinArgs.length);
     if (helperBinProcess.exitValue != 0) {
-      logTestInfo("maintenance service could not stop, may cause failures.");
+      if (aFailTest) {
+        do_throw("maintenance service did not stop, forcing test failure.");
+      } else {
+        logTestInfo("maintenance service did not stop, may cause failures.");
+      }
     } else {
       logTestInfo("Service stopped.");
     }
   }
 
   // Make sure the service from the previous test is already stopped.
-  waitForServiceStop();
+  waitForServiceStop(true);
 
   // Prevent the cleanup function from begin run more than once
   if (typeof(gRegisteredServiceCleanup) === "undefined") {
     gRegisteredServiceCleanup = true;
 
     do_register_cleanup(function serviceCleanup() {
       resetEnvironment();
 
@@ -693,17 +697,17 @@ function runUpdateUsingService(aInitialS
       return;
     }
     do_check_eq(status, aExpectedStatus);
 
     timer.cancel();
     timer = null;
 
     // Make sure all of the logs are written out.
-    waitForServiceStop();
+    waitForServiceStop(false);
 
     if (aCheckSvcLog) {
       checkServiceLogs(svcOriginalLog);
     } 
     aCallback();
   }
 
   let timer = AUS_Cc["@mozilla.org/timer;1"].createInstance(AUS_Ci.nsITimer);