Bug 480077 - automation.py.in : additional fix to bug 472706 for |runApp()| return value(s); (Bv1a) Replace external times by internal duration ++; r=jwalden+bmo
authorSerge Gautherie <sgautherie.bz@free.fr>
Thu, 05 Mar 2009 19:01:39 +0100
changeset 25783 3622aadb857bf9624cc97914996c78ffc36df65b
parent 25782 2072d9ddce60e5ea1ca0e0f063f79b460c300360
child 25784 b3c526cd653bd174a5e6f714245e0a19c94fa14c
push idunknown
push userunknown
push dateunknown
reviewersjwalden
bugs480077, 472706
milestone1.9.2a1pre
Bug 480077 - automation.py.in : additional fix to bug 472706 for |runApp()| return value(s); (Bv1a) Replace external times by internal duration ++; r=jwalden+bmo
build/automation.py.in
build/leaktest.py.in
build/pgo/profileserver.py.in
layout/tools/reftest/runreftest.py
testing/mochitest/runtests.py.in
--- a/build/automation.py.in
+++ b/build/automation.py.in
@@ -115,17 +115,17 @@ class Process(subprocess.Popen):
     if IS_WIN32:
       import platform
       pid = "%i" % self.pid
       if platform.release() == "2000":
         # Windows 2000 needs 'kill.exe' from the 'Windows 2000 Resource Kit tools'. (See bug 475455.)
         try:
           subprocess.Popen(["kill", "-f", pid]).wait()
         except:
-          log.info("TEST-UNEXPECTED-FAIL | Missing 'kill' utility to kill process with pid=%s. Kill it manually!", pid)
+          log.info("TEST-UNEXPECTED-FAIL | (automation.py) | Missing 'kill' utility to kill process with pid=%s. Kill it manually!", pid)
       else:
         # Windows XP and later.
         subprocess.Popen(["taskkill", "/F", "/PID", pid]).wait()
     else:
       os.kill(self.pid, signal.SIGKILL)
 
 
 #################
@@ -403,32 +403,29 @@ def environment(env = None, xrePath = DI
 
   return env
 
 ###############
 # RUN THE APP #
 ###############
 
 def runApp(testURL, env, app, profileDir, extraArgs, runSSLTunnel = False, utilityPath = DIST_BIN, xrePath = DIST_BIN, certPath = CERTS_SRC_DIR):
-  "Run the app, returning a tuple containing the status code and the time at which it was started."
+  "Run the app, log the duration it took to execute, return the status code."
+
   if IS_TEST_BUILD and runSSLTunnel:
     # create certificate database for the profile
     certificateStatus = fillCertificateDB(profileDir, certPath, utilityPath, xrePath)
     if certificateStatus != 0:
-      log.info("TEST-UNEXPECTED FAIL | Certificate integration failed")
+      log.info("TEST-UNEXPECTED FAIL | (automation.py) | Certificate integration failed")
       return certificateStatus
-  
+
     # start ssltunnel to provide https:// URLs capability
     ssltunnel = os.path.join(utilityPath, "ssltunnel" + BIN_SUFFIX)
     ssltunnelProcess = Process([ssltunnel, os.path.join(profileDir, "ssltunnel.cfg")], env = environment(xrePath = xrePath))
-    log.info("SSL tunnel pid: %d", ssltunnelProcess.pid)
-  
-  "Run the app, returning the time at which it was started."
-  # mark the start
-  start = datetime.now()
+    log.info("INFO | (automation.py) | SSL tunnel pid: %d", ssltunnelProcess.pid)
 
   # now run with the profile we created
   cmd = app
   if IS_MAC and not IS_CAMINO and not cmd.endswith("-bin"):
     cmd += "-bin"
   cmd = os.path.abspath(cmd)
 
   args = []
@@ -442,22 +439,25 @@ def runApp(testURL, env, app, profileDir
 
   args.extend(("-no-remote", "-profile", profileDirectory))
   if testURL is not None:
     if IS_CAMINO:
       args.extend(("-url", testURL))
     else:
       args.append((testURL))
   args.extend(extraArgs)
+
+  startTime = datetime.now()
   proc = Process([cmd] + args, env = environment(env), stdout = subprocess.PIPE, stderr = subprocess.STDOUT)
-  log.info("Application pid: %d", proc.pid)
+  log.info("INFO | (automation.py) | Application pid: %d", proc.pid)
   line = proc.stdout.readline()
   while line != "":
     log.info(line.rstrip())
     line = proc.stdout.readline()
   status = proc.wait()
   if status != 0:
-    log.info("TEST-UNEXPECTED-FAIL | Exited with code %d during test run", status)
+    log.info("TEST-UNEXPECTED-FAIL | (automation.py) | Exited with code %d during test run", status)
+  log.info("INFO | (automation.py) | Application ran for: %s", str(datetime.now() - startTime))
 
   if IS_TEST_BUILD and runSSLTunnel:
     ssltunnelProcess.kill()
-  
-  return (status, start)
+
+  return status
--- a/build/leaktest.py.in
+++ b/build/leaktest.py.in
@@ -79,11 +79,11 @@ if __name__ == '__main__':
         browserEnv["XPCOM_DEBUG_BREAK"] = "stack"
     if automation.UNIXISH:
         browserEnv["LD_LIBRARY_PATH"] = os.path.join(SCRIPT_DIR, DIST_BIN)
         browserEnv["MOZILLA_FIVE_HOME"] = os.path.join(SCRIPT_DIR, DIST_BIN)
         browserEnv["GNOME_DISABLE_CRASH_DIALOG"] = "1"
 
     url = "http://localhost:%d/bloatcycle.html" % PORT
     appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
-    (status, start) = automation.runApp(url, browserEnv, appPath,
-                                        PROFILE_DIRECTORY, extraArgs)
+    status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY,
+                               extraArgs)
     sys.exit(status)
--- a/build/pgo/profileserver.py.in
+++ b/build/pgo/profileserver.py.in
@@ -59,23 +59,21 @@ class EasyServer(SocketServer.TCPServer)
 if __name__ == '__main__':
   httpd = EasyServer(("", PORT), SimpleHTTPServer.SimpleHTTPRequestHandler)
   t = threading.Thread(target=httpd.serve_forever)
   t.setDaemon(True) # don't hang on exit
   t.start()
 
   automation.initializeProfile(PROFILE_DIRECTORY)
   browserEnv = dict(os.environ)
- 
+
   # These variables are necessary for correct application startup; change
   # via the commandline at your own risk.
   browserEnv["NO_EM_RESTART"] = "1"
   browserEnv["XPCOM_DEBUG_BREAK"] = "warn"
   if automation.UNIXISH:
     browserEnv["LD_LIBRARY_PATH"] = os.path.join(SCRIPT_DIR, automation.DIST_BIN)
     browserEnv["MOZILLA_FIVE_HOME"] = os.path.join(SCRIPT_DIR, automation.DIST_BIN)
 
   url = "http://localhost:%d/index.html" % PORT
   appPath = os.path.join(SCRIPT_DIR, automation.DEFAULT_APP)
-  (status, start) = automation.runApp(url, browserEnv, appPath, 
-                                      PROFILE_DIRECTORY, {})
+  status = automation.runApp(url, browserEnv, appPath, PROFILE_DIRECTORY, {})
   sys.exit(status)
-
--- a/layout/tools/reftest/runreftest.py
+++ b/layout/tools/reftest/runreftest.py
@@ -80,17 +80,17 @@ def main():
                     action = "store", type = "string", dest = "app",
                     default = os.path.join(SCRIPT_DIRECTORY, automation.DEFAULT_APP),
                     help = "absolute path to application, overriding default")
   parser.add_option("--extra-profile-file",
                     action = "append", dest = "extraProfileFiles",
                     default = [],
                     help = "copy specified files/dirs to testing profile")
   options, args = parser.parse_args()
-  
+
   if len(args) != 1:
     print >>sys.stderr, "No reftest.list specified."
     sys.exit(1)
 
   options.app = getFullPath(options.app)
   if not os.path.exists(options.app):
     print """Error: Path %(app)s doesn't exist.
 Are you executing $objdir/_tests/reftest/runreftest.py?""" \
@@ -130,28 +130,26 @@ Are you executing $objdir/_tests/reftest
         leaks = open(leakLogFile, "r")
         # For the time being, simply copy the log. (Bug 469518)
         log.info(leaks.read().rstrip())
         leaks.close()
 
     # run once with -silent to let the extension manager do its thing
     # and then exit the app
     log.info("REFTEST INFO | runreftest.py | Performing extension manager registration: start.\n")
-    (status, start) = automation.runApp(None, browserEnv, options.app,
-                                        profileDir,
-                                        extraArgs = ["-silent"])
+    status = automation.runApp(None, browserEnv, options.app, profileDir,
+                               extraArgs = ["-silent"])
     # We don't care to call |processLeakLog()| for this step.
     log.info("\nREFTEST INFO | runreftest.py | Performing extension manager registration: end.")
 
     # then again to actually run reftest
     log.info("REFTEST INFO | runreftest.py | Running tests: start.\n")
     reftestlist = getFullPath(args[0])
-    (status, start) = automation.runApp(None, browserEnv, options.app,
-                                        profileDir,
-                                        extraArgs = ["-reftest", reftestlist])
+    status = automation.runApp(None, browserEnv, options.app, profileDir,
+                               extraArgs = ["-reftest", reftestlist])
     processLeakLog()
     log.info("\nREFTEST INFO | runreftest.py | Running tests: end.")
   finally:
     if profileDir is not None:
       shutil.rmtree(profileDir)
   sys.exit(status)
 
 def copyExtraFilesToProfile(options, profileDir):
--- a/testing/mochitest/runtests.py.in
+++ b/testing/mochitest/runtests.py.in
@@ -389,22 +389,22 @@ Are you executing $objdir/_tests/testing
     if len(urlOpts) > 0:
       testURL += "?" + "&".join(urlOpts)
 
   browserEnv["XPCOM_MEM_BLOAT_LOG"] = LEAK_REPORT_FILE
 
   if options.fatalAssertions:
     browserEnv["XPCOM_DEBUG_BREAK"] = "stack-and-abort"
 
-  (status, start) = automation.runApp(testURL, browserEnv, options.app,
-                                      PROFILE_DIRECTORY, options.browserArgs,
-                                      runSSLTunnel = True,
-                                      utilityPath=options.utilityPath,
-                                      xrePath=options.xrePath,
-                                      certPath=options.certPath)
+  status = automation.runApp(testURL, browserEnv, options.app,
+                             PROFILE_DIRECTORY, options.browserArgs,
+                             runSSLTunnel = True,
+                             utilityPath = options.utilityPath,
+                             xrePath = options.xrePath,
+                             certPath = options.certPath)
 
   # Server's no longer needed, and perhaps more importantly, anything it might
   # spew to console shouldn't disrupt the leak information table we print next.
   server.stop()
 
   if not os.path.exists(LEAK_REPORT_FILE):
     log.info("WARNING refcount logging is off, so leaks can't be detected!")
   else:
@@ -471,22 +471,16 @@ Are you executing $objdir/_tests/testing
                      "instance": instance,
                      "name": name,
                      "size": matches.group("size"),
                      "rest": rest })
     if not seenTotal:
       log.info("TEST-UNEXPECTED-FAIL | runtests-leaks | missing output line for total leaks!")
     leaks.close()
 
-
-  # print test run times
-  finish = datetime.now()
-  log.info(" started: %s", str(start))
-  log.info("finished: %s", str(finish))
-
   # delete the profile and manifest
   os.remove(manifest)
 
   # hanging due to non-halting threads is no fun; assume we hit the errors we
   # were going to hit already and exit with a success code
   sys.exit(0)