Bug 524125 Provide makefile target for bloat tests and don't hard-code path to symbols. New target is 'mailbloat'. r=gozer
authorMark Banner <bugzilla@standard8.plus.com>
Tue, 22 Dec 2009 20:04:16 +0000
changeset 4587 9911eaa87f34d48a79b0be2d7102024f5fdbc9be
parent 4586 45c6417d76886d5a30e05280eb3e2b0b9d9a5cee
child 4588 7602c7333e3e7ff7149d784aeadf705228280a80
push idunknown
push userunknown
push dateunknown
reviewersgozer
bugs524125
Bug 524125 Provide makefile target for bloat tests and don't hard-code path to symbols. New target is 'mailbloat'. r=gozer
mail/build.mk
mailnews/test/performance/bloat/runtest.py
mailnews/test/performance/bloat/setUpBloatTest.py
mailnews/testsuite-targets.mk
--- a/mail/build.mk
+++ b/mail/build.mk
@@ -74,18 +74,16 @@ tier_app_dirs += \
 ifdef MOZ_CALENDAR
 tier_app_dirs += calendar/lightning
 endif
 
 tier_app_dirs += \
 	mail \
 	$(NULL)
 
-endif # COMM_BUILD
-
 installer:
 	@$(MAKE) -C mail/installer installer
 
 package:
 	@$(MAKE) -C mail/installer
 
 package-compare:
 	@$(MAKE) -C mail/installer package-compare
@@ -95,16 +93,19 @@ install::
 
 source-package::
 	@$(MAKE) -C mail/installer source-package
 
 upload::
 	@$(MAKE) -C mail/installer upload
 
 ifdef ENABLE_TESTS
+# Additional mailnews targets to call automated test suites
+include $(topsrcdir)/mailnews/testsuite-targets.mk
+
 # Instructions below this line are for mail/ specific tests.
 
 MOZMILLDIR=$(DEPTH)/mozilla/_tests/mozmill
 
 ifneq (,$(filter mac cocoa,$(MOZ_WIDGET_TOOLKIT)))
 # Mac options
 APP_NAME = $(MOZ_APP_DISPLAYNAME)
 ifdef MOZ_DEBUG
@@ -123,9 +124,11 @@ mozmill::
 	runtestlist.py --list=mozmilltests.list --binary=$(PROGRAM) \
 	--dir=$(topsrcdir)/mail/test/mozmill \
 	--default-profile=$(PROGRAM_LOCATION)/defaults/profile $(MOZMILL_EXTRA)
 
 mozmill-one::
 	cd $(MOZMILLDIR) && MACOSX_DEPLOYMENT_TARGET= $(PYTHON) runtest.py \
 	--test=$(topsrcdir)/mail/test/mozmill/$(SOLO_TEST) --binary=$(PROGRAM) \
 	--default-profile=$(PROGRAM_LOCATION)/defaults/profile $(MOZMILL_EXTRA)
-endif
+endif # ENABLE_TESTS
+
+endif # COMM_BUILD
--- a/mailnews/test/performance/bloat/runtest.py
+++ b/mailnews/test/performance/bloat/runtest.py
@@ -40,42 +40,44 @@
 Runs the Bloat test harness
 """
 
 import optparse
 import sys
 import os
 import shutil
 
+import automation
+from automationutils import checkForCrashes
+
 class BloatRunTestOptions(optparse.OptionParser):
     """Parses Bloat runtest.py commandline options."""
     def __init__(self, **kwargs):
         optparse.OptionParser.__init__(self, **kwargs)
         defaults = {}
 
-        self.add_option("--objdir",
-                        action = "store", type = "string", dest = "objdir",
+        self.add_option("--distdir",
+                        action = "store", type = "string", dest = "distdir",
                         help = "object directory of build to run")
-        defaults["objdir"] = "objdir-tb"
+        defaults["distdir"] = "distdir-tb"
 
         self.add_option("--bin",
                         action = "store", type = "string", dest = "bin",
                         help = "application binary name")
         defaults["bin"] = "thunderbird"
 
         self.add_option("--brand",
                         action = "store", type = "string", dest = "brand",
                         help = "The current branding, including Debug if necessary")
         defaults["brand"] = "Shredder"
 
-        self.add_option("--release",
-                        action = "store_false", dest = "debug",
-                        help = "Specify if the build is a release build")
-
-        defaults["debug"] = True
+        self.add_option("--symbols-path",
+                        action = "store", type = "string", dest = "symbols",
+                        help = "The path to the symbol files from build_symbols")
+        defaults["symbols"] = ""
 
         self.add_option("--extra-startup-arg",
                         action = "store", type = "string", dest = "extraArg",
                         help = "Extra startup argument if required, at the moment this will only support one extra argument with no parameters")
         defaults["extraArg"] = ""
 
         self.set_defaults(**defaults);
 
@@ -84,49 +86,40 @@ Usage instructions for runtest.py.
 All arguments must be specified.
 """
         self.set_usage(usage)
 
 
 parser = BloatRunTestOptions()
 options, args = parser.parse_args()
 
-if options.objdir == "" or options.bin == "" or options.brand == "":
+if options.distdir == "" or options.bin == "" or options.brand == "":
   parser.print_help()
   sys.exit(1)
 
-OBJDIR = os.path.abspath(os.path.realpath(options.objdir))
-AUTOMATION_DIR = os.path.join(OBJDIR, 'mozilla', 'build')
-sys.path.append(AUTOMATION_DIR)
-import automation
-from automationutils import checkForCrashes
-
-# XXX Symbols path is currently hard-coded to what we expect - bug 524125 will
-# fix this. 
-SYMBOLS_PATH = os.path.abspath(os.path.join(AUTOMATION_DIR, "../dist/crashreporter-symbols"))
+DISTDIR = os.path.abspath(os.path.realpath(options.distdir))
+print DISTDIR
 
 CWD = os.getcwd()
 SCRIPTDIR = os.path.abspath(os.path.realpath(os.path.dirname(sys.argv[0])))
 
 if automation.IS_MAC:
-  if options.debug:
-    APPBUNDLE = options.brand + 'Debug.app'
-  else:
-    APPBUNDLE = options.brand + '.app'
-
-  BINDIR = os.path.join(OBJDIR, 'mozilla', 'dist', APPBUNDLE, 'Contents', 'MacOS')
+  APPBUNDLE = options.brand + '.app'
+  BINDIR = os.path.join(DISTDIR, APPBUNDLE, 'Contents', 'MacOS')
 else:
-  BINDIR = os.path.join(OBJDIR, 'mozilla', 'dist', 'bin')
+  BINDIR = os.path.join(DISTDIR, 'bin')
 
 if automation.IS_MAC:
   EXECUTABLE = options.bin + '-bin'
 else:
   EXECUTABLE = options.bin
 BIN = os.path.join(BINDIR, EXECUTABLE)
-PROFILE = os.path.join(OBJDIR, 'mozilla', '_leaktest', 'leakprofile')
+PROFILE = os.path.join(DISTDIR, '..', '_leaktest', 'leakprofile')
+print BIN
+print EXECUTABLE
 
 # Wipe the profile
 if os.path.exists(PROFILE):
   shutil.rmtree(PROFILE)
 os.mkdir(PROFILE)
 
 defaultEnv = dict(os.environ)
 defaultEnv['NO_EM_RESTART'] = '1'
@@ -162,16 +155,26 @@ COMMANDS = [
   },
   {
    'name': 'leakTests',
    'args': ['-profile',         PROFILE,
             '--trace-malloc',   'malloc.log',
             '--shutdown-leaks', 'sdleak.log',
            ],
    'env': {'XPCOM_MEM_BLOAT_LOG': 'trace-bloat.log'},
+  },
+  {
+   'name': 'cleanup tests',
+   'bin':  sys.executable,
+   'args': ['setUpBloatTest.py',
+            '--profile-dir=' + PROFILE,
+            '--binary-dir=' + BINDIR,
+            '--cleanup'
+           ],
+    'cwd': SCRIPTDIR,
   }
 ]
 
 
 for cmd in COMMANDS:
   # Some scripts rely on the cwd
   cwd = CWD
   if 'cwd' in cmd:
@@ -205,17 +208,17 @@ for cmd in COMMANDS:
     print >> sys.stderr, "%s=%s"%(envkey, mailnewsEnv[envkey])
 
   proc = automation.Process([binary] + args, env = mailnewsEnv)
 
   status = proc.wait()
   if status != 0:
     print >> sys.stderr, "TEST-UNEXPECTED-FAIL | runtest.py | Exited with code %d during test run"%(status)
 
-  if checkForCrashes(os.path.join(PROFILE, "minidumps"), SYMBOLS_PATH, cmd['name']):
+  if checkForCrashes(os.path.join(PROFILE, "minidumps"), options.symbols, cmd['name']):
     print >> sys.stderr, 'TinderboxPrint: ' + cmd['name'] + '<br/><em class="testfail">CRASH</em>'
     status = -1
 
   if status != 0:
     sys.exit(status)
 
   print >> sys.stderr, 'INFO | runtest.py | ' + cmd['name'] + ' executed successfully.'
 
--- a/mailnews/test/performance/bloat/setUpBloatTest.py
+++ b/mailnews/test/performance/bloat/setUpBloatTest.py
@@ -41,32 +41,38 @@ import re
 import shutil
 from subprocess import Popen,PIPE
 import sys
 
 # append the common directory so we can import the common module
 sys.path.append(os.path.join(os.getcwd(), '../common'))
 import setUpCommonMailNews
 
+copyFiles = ["bloatComposeOverlay.js",
+             "bloatComposeOverlay.xul",
+             "bloatAddrOverlay.js",
+             "bloatAddrOverlay.xul",
+             "bloatMainOverlay.js",
+             "bloatMainOverlay.xul"];
+
 class BloatProfileOptions(optparse.OptionParser):
     """Parses Set Up Bloat Profile commandline options."""
     def __init__(self, **kwargs):
         optparse.OptionParser.__init__(self, **kwargs)
         defaults = {}
 
+        self.add_option("--cleanup",
+                        action = "store_true", dest = "cleanup",
+                        help = "Clean up rather than shut down.")
+        defaults["cleanup"] = False
+
         setUpCommonMailNews.AddCommonOptions(self, defaults);
 
 def copyChromeFiles(destination):
     # Copy bloat*Overlay.js/xul to the chrome directory
-    copyFiles = ["bloatComposeOverlay.js",
-                 "bloatComposeOverlay.xul",
-                 "bloatAddrOverlay.js",
-                 "bloatAddrOverlay.xul",
-                 "bloatMainOverlay.js",
-                 "bloatMainOverlay.xul"];
     for file in copyFiles:
         shutil.copy(file, destination)
 
 def createManifest(chromeDir, manifestFileName):
     # Formulate a manifest to allow load of and overlay the bloatTestOverlay.xul
     # file onto the main windows
     fileLocation = chromeDir + "/" + manifestFileName
     try:
@@ -84,16 +90,21 @@ def createManifest(chromeDir, manifestFi
     text = """\
 overlay chrome://messenger/content/messenger.xul chrome://mailnewstest/content/bloatMainOverlay.xul
 overlay chrome://messenger/content/addressbook/addressbook.xul chrome://mailnewstest/content/bloatAddrOverlay.xul
 overlay chrome://messenger/content/messengercompose/messengercompose.xul chrome://mailnewstest/content/bloatComposeOverlay.xul
 """
     f.write(text)
     f.close()
 
+def removeFiles(destination, manifestFileName):
+    for file in copyFiles:
+        os.remove(os.path.join(destination, file))
+
+    os.remove(os.path.join(destination, manifestFileName))
 
 def main():
     # Argument parsing and checking
     parser = BloatProfileOptions()
     options, args = parser.parse_args()
 
     if options.binaryDir=="" or options.profileDir=="":
         print "Binary and Profile Directories must be supplied"
@@ -101,21 +112,22 @@ def main():
  
     if not os.path.exists(options.binaryDir) or not os.path.exists(options.profileDir):
         print "Binary and Profile Directories must be exist"
         sys.exit(2)
 
     # The main work
     print "Running setUpBloatTest.py"
 
-    copyChromeFiles(options.binaryDir + "/chrome")
-
-    createManifest(options.binaryDir + "/chrome", "mailnewstest.manifest")
-
-    setUpCommonMailNews.copyCommonProfileFiles(options.profileDir)
+    if options.cleanup:
+        removeFiles(options.binaryDir + "/chrome", "mailnewstest.manifest")
+    else:
+        copyChromeFiles(options.binaryDir + "/chrome")
+        createManifest(options.binaryDir + "/chrome", "mailnewstest.manifest")
+        setUpCommonMailNews.copyCommonProfileFiles(options.profileDir)
 
     print "setUpBloatTest.py completed succesfully"
 
 #########
 # DO IT #
 #########
 
 if __name__ == "__main__":
new file mode 100644
--- /dev/null
+++ b/mailnews/testsuite-targets.mk
@@ -0,0 +1,55 @@
+# ***** BEGIN LICENSE BLOCK *****
+# Version: MPL 1.1/GPL 2.0/LGPL 2.1
+#
+# The contents of this file are subject to the Mozilla Public License Version
+# 1.1 (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+# http://www.mozilla.org/MPL/
+#
+# Software distributed under the License is distributed on an "AS IS" basis,
+# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
+# for the specific language governing rights and limitations under the
+# License.
+#
+# The Original Code is the MailNews Test Suite.
+#
+# The Initial Developer of the Original Code is
+# Mozilla Messaging.
+# Portions created by the Initial Developer are Copyright (C) 2009
+# the Initial Developer. All Rights Reserved.
+#
+# Contributor(s):
+#   Mark Banner <bugzilla@standard8.plus.com> (Initial Code)
+#
+# Alternatively, the contents of this file may be used under the terms of
+# either the GNU General Public License Version 2 or later (the "GPL"), or
+# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
+# in which case the provisions of the GPL or the LGPL are applicable instead
+# of those above. If you wish to allow use of your version of this file only
+# under the terms of either the GPL or the LGPL, and not to allow others to
+# use your version of this file under the terms of the MPL, indicate your
+# decision by deleting the provisions above and replace them with the notice
+# and other provisions required by the GPL or the LGPL. If you do not delete
+# the provisions above, a recipient may use your version of this file under
+# the terms of any one of the MPL, the GPL or the LGPL.
+#
+# ***** END LICENSE BLOCK *****
+
+APP_NAME := $(MOZ_APP_DISPLAYNAME)
+
+ifdef MOZ_DEBUG
+APP_NAME := $(APP_NAME)Debug
+endif
+
+SYMBOLS_PATH := --symbols-path=$(DIST)/crashreporter-symbols
+
+ifdef MOZ_SUITE
+EXTRA_BLOAT_ARGS := -mail
+endif
+
+mailbloat:
+	$(PYTHON) -u $(topsrcdir)/mozilla/config/pythonpath.py \
+        -I$(DIST)/../build \
+        $(topsrcdir)/mailnews/test/performance/bloat/runtest.py \
+	--distdir=$(DIST) --bin=$(MOZ_APP_NAME) --brand=$(APP_NAME) \
+	$(SYMBOLS_PATH) $(EXTRA_BLOAT_ARGS)