commit my working maemkit patch. bug 503439, r=jmaher
authorAki Sasaki <asasaki@mozilla.com>
Wed, 29 Jul 2009 10:22:24 -0700
changeset 3 e244a72c094a9121bccacb3393ad66d103785b7a
parent 2 ba8ae7730e36a1961756aea20991bbd49c492cce
child 4 31b3f98dab462b9c05d305ffe43cdb1b5f22df4f
push id4
push userasasaki@mozilla.com
push dateWed, 29 Jul 2009 17:22:42 +0000
reviewersjmaher
bugs503439
commit my working maemkit patch. bug 503439, r=jmaher
chromedriver.py
maemkit-windows.cfg
maemkit.cfg
maemkit.py
mochidriver.py
refdriver.py
xpcdriver.py
--- a/chromedriver.py
+++ b/chromedriver.py
@@ -54,12 +54,16 @@ class ChromeDriver(maemkit.MaemKit):
     for option in ["utility-path","appname","xre-path","certificate-path"]:
       self.mochitestCommand.append("--" + option + "=" + os.path.normpath(self.options[option]))
     mCommand = " ".join(self.mochitestCommand)
 
     for directory in self.directories:
       targetdir = os.path.normpath(os.path.join(self.options["testroot"], "chrome"))
       self.rmdir(targetdir)
       self.copytree(os.path.normpath(os.path.join(self.options["backupdir"], str(directory))), targetdir)
-      self.addCommand(mCommand + " --log-file=" + os.path.normpath(os.path.join(self.options["logdir"], self.getLogFileName(directory))))
+      logfile = os.path.normpath(os.path.join(self.options["logdir"],
+                                 self.getLogFileName(directory)))
+      self.addCommand("%s --log-file=%s" % (mCommand, logfile))
+      if self.options['verbose'] and os.path.exists(logfile):
+          print ''.join(open(logfile).readlines())
 
   def parseLogs(self):
     self.stitchLogs()
--- a/maemkit-windows.cfg
+++ b/maemkit-windows.cfg
@@ -11,17 +11,17 @@ debug = 1
 autorun = True
 close-when-done = True
 test-path =  
 utility-path = c:/release/bin
 certificate-path = c:/release/certs
 split-directories = "toolkit/content/tests/widgets","content/canvas/test","content/html/content/test","layout/style/test","content/base/test","dom/tests/mochitest/dom-level1-core","dom/tests/mochitest/dom-level2-core"
 split-percentage = 20
 testroot = c:/release/mochitest
-log-file = log_mochitests.txt
+log-file = log_mochitest.txt
 
 [chrome]
 autorun = True
 close-when-done = True
 utility-path = c:/release/bin
 certificate-path = c:/release/certs
 backupdir = chrome.bak
 testroot = c:/release/mochitest
--- a/maemkit.cfg
+++ b/maemkit.cfg
@@ -1,48 +1,53 @@
 [general]
 xre-path = /media/mmc1/release/fennec/xulrunner
 appname = /media/mmc1/release/fennec/fennec
 total-clients = 1
 client-number = 1
-logdir = logs
+logdir = /media/mmc1/release/maemkit_logs
 ostype = linux
 debug = 1
 
 [mochitest]
 autorun = True
 close-when-done = True
-test-path =  
+test-path = None
 utility-path = /media/mmc1/release/bin
 certificate-path = /media/mmc1/release/certs
 split-directories = "toolkit/content/tests/widgets","content/canvas/test","content/html/content/test","layout/style/test","content/base/test","dom/tests/mochitest/dom-level1-core","dom/tests/mochitest/dom-level2-core"
 split-percentage = 20
 testroot = /media/mmc1/release/mochitest
-log-file = log_mochitests.txt
+log-file = /media/mmc1/release/log_mochitest.txt
+verbose = 1
 
 [chrome]
 autorun = True
 close-when-done = True
 utility-path = /media/mmc1/release/bin
 certificate-path = /media/mmc1/release/certs
 backupdir = chrome.bak
 testroot = /media/mmc1/release/mochitest
-log-file = log_chrome.txt
+log-file = /media/mmc1/release/log_chrome.txt
+verbose = 0
 
 [reftest]
 split-directories = "layout/reftests/bugs/reftest.list","modules/libpr0n/test/reftest/reftest.list"
 split-percentage = 100
 testroot = /media/mmc1/release/reftest/tests
 utility-path = /media/mmc1/release/reftest
 manifest = /media/mmc1/release/reftest/tests/layout/reftests/reftest.list
-log-file = log_reftest.txt
+log-file = /media/mmc1/release/log_reftest.txt
+verbose = 1
 
 [crashtest]
 testroot = /media/mmc1/release/reftest/tests
 utility-path = /media/mmc1/release/reftest
 manifest = /media/mmc1/release/reftest/tests/testing/crashtest/crashtests.list
-log-file = log_crashtest.txt
+log-file = /media/mmc1/release/log_crashtest.txt
+verbose = 1
 
 [xpcshell]
 testroot = /media/mmc1/release/xpcshell/tests
 utility-path = /media/mmc1/release/xpcshell
 manifest = /media/mmc1/release/xpcshell/tests/all-test-dirs.list
-log-file = log_xpcshell.txt
+log-file = /media/mmc1/release/log_xpcshell.txt
+verbose = 1
--- a/maemkit.py
+++ b/maemkit.py
@@ -1,9 +1,9 @@
-import os, sys, re, copy, shutil
+import os, sys, re, copy, shutil, distutils
 import ConfigParser, optparse
 import datetime, time, subprocess, commands
 
 class MaemKit(object):
   config_options = {}
   default_options = {}
   testtype = "mochitest"
   testdriver = ""
@@ -77,25 +77,25 @@ class MaemKit(object):
     general = self.getConfigFile("general")
     for section in self.testtypes:
       self.config_options[section].update(general)
       self.config_options[section].update(self.getConfigFile(section))
 
   def getCli(self):
     parser = optparse.OptionParser()
 
-    parser.add_option("--testtype", "-t", 
+    parser.add_option("--testtype", "-t",
                        default="mochitest", action="store", type="string", dest="testtype",
                        help="Which test to run: mochitest, chrome, reftest, crashtest")
 
-    parser.add_option("--client-number", 
+    parser.add_option("--client-number",
                        default="-1", action="store", type="int", dest="clientnumber",
                        help="Which client you are in a parallel run. Range is 0:total-clients")
 
-    parser.add_option("--total-clients", 
+    parser.add_option("--total-clients",
                        default="-1", action="store", type="int", dest="totalclients",
                        help="Number of clients in your testpass in parallel mode.  Used with client-number")
 
     #TODO: add other cli options;  need to figure out which ones we really care about
     (cli_options, args) = parser.parse_args()
     self.testtype = cli_options.testtype
     if (cli_options.clientnumber != -1): self.config_options[self.testtype]["client-number"] = cli_options.clientnumber
     if (cli_options.totalclients != -1): self.config_options[self.testtype]["total-clients"] = cli_options.totalclients
@@ -129,21 +129,22 @@ class MaemKit(object):
       if (retry == True):
         #TODO: consider putting this in a thread so it isn't blocking
         std_out += sub_proc.stdout.read();
         std_err += sub_proc.stderr.read();
       if (sub_proc.poll() is not None):
         std_out += sub_proc.stdout.read();
         std_err += sub_proc.stderr.read();
         break
-      time.sleep(1)                                       
+      time.sleep(1)
     retVal = std_out + "\n" + std_err
 
     if (datetime.datetime.now() - starttime >= datetime.timedelta(minutes=timeout)):
       retVal = "*** TIMEOUT ***"
+#    print retVal
     return retVal
 
   #parse log files, tally results
   #TODO: test on all types of logs
   def stitchLogs(self):
     p = 0
     f = 0
     t = 0
@@ -160,21 +161,27 @@ class MaemKit(object):
           res = None
           res = myre.match(line)
           if (res):
             if (res.group(1) == "PASS"): p = p + 1
             if (res.group(1) == "UNEXPECTED"): f = f + 1
             if (res.group(1) == "KNOWN"): t = t + 1
             masterLog.write(line)
 
-    masterLog.write("\n\n-------------------------\n")
-    masterLog.write("INFO PASSED: " + str(p) + "\n")
-    masterLog.write("INFO FAILED: " + str(f) + "\n")
-    masterLog.write("INFO TODO: " + str(t) + "\n")
+#    masterLog.write("\n\n-------------------------\n")
+#    masterLog.write("INFO Passed: " + str(p) + "\n")
+#    masterLog.write("INFO Failed: " + str(f) + "\n")
+#    masterLog.write("INFO Todo: " + str(t) + "\n")
+    summarystr = "\n\n-------------------------\n"
+    summarystr += "INFO Passed: " + str(p) + "\n"
+    summarystr += "INFO Failed: " + str(f) + "\n"
+    summarystr += "INFO Todo: " + str(t) + "\n"
+    masterLog.write(summarystr)
     masterLog.close()
+    print summarystr
 
 
   def cleanup(self):
     #TODO: figure out a method for killing process on wince (custom program)
     #TODO: what if we are using firefox instead of fennec?
     terminate = "killall"
     if (self.dirtype == '\\\\'): terminate = "tskill"
 
@@ -239,17 +246,17 @@ class MaemKit(object):
     root = os.path.dirname(os.path.normpath(src))
     if (file == "*"): file = ".*"
     p = re.compile(file)
 
     try:
       files = [file for file in os.listdir(root) if p.match(file)]
       for file in files:
         if (os.path.isdir(os.path.join(root,file)) == False):
-          shutil.copy(os.path.join(root, file), dest) 
+          shutil.copy(os.path.join(root, file), dest)
     except:
       if (self.debug > 1): print "exception in copy: " + os.path.normpath(file) + " " + os.path.normpath(dst)
       pass
 
   def move(self, src, dst):
     try:
       dest = os.path.normpath(dst)
       filename = os.path.basename(os.path.normpath(src))
--- a/mochidriver.py
+++ b/mochidriver.py
@@ -49,39 +49,39 @@ class MochiKit(maemkit.MaemKit):
     self.directories = relDirectories
 
 
   #Put directory back to normal; not necessary, but good to have
   def stitchDirectory(self, aDir):
     dirlist = []
 
     basedir = os.path.normpath(os.path.join(self.options["testroot"], "tests"))
-    for root, dirs, files in os.walk(os.path.join(basedir, aDir)): 
+    for root, dirs, files in os.walk(os.path.join(basedir, aDir)):
       dirlist = dirs
       break
 
     numtosplit = abs(100 / int(self.options["split-percentage"]))
     try:
       if (dirlist.index(str(numtosplit)) >= 0):
         try:
-	  if (dirlist.index(str(numtosplit + 1)) >= 0): stitch = True
+          if (dirlist.index(str(numtosplit + 1)) >= 0): stitch = True
         except: stitch = False
     except: stitch = True
 
     base_dir = os.path.normpath(os.path.join(basedir, aDir))
 
     if (stitch == True):
       myre = re.compile("^([0-9]+)$")
       for dir in dirlist:
         res = myre.match(dir)
         if (res):
           try:
             self.move(os.path.normpath(os.path.join(os.path.join(base_dir, res.group(1)), "*")), base_dir)
             self.rmdir(os.path.normpath(os.path.join(base_dir, res.group(1))))
-          except: 
+          except:
             if (self.debug >= 1): print "couldn't find directory: " + res.group(1) + " in " + aDir
             pass
 
       try:
         self.move(os.path.normpath(os.path.join(os.path.join(base_dir, "tests"), "*")), base_dir)
         self.rmdir(os.path.normpath(os.path.join(base_dir, "tests")))
       except:
         if (self.debug >= 1): print "no directory tests in: " + aDir
@@ -93,17 +93,17 @@ class MochiKit(maemkit.MaemKit):
     num_files = 0
     for root,dirs,files in os.walk(os.path.normpath(os.path.join(os.path.join(self.options["testroot"], "tests"), aDir))):
       num_files = len(files)
       break
 
     bDir = os.path.normpath(os.path.join(os.path.join(self.options["testroot"], "tests"), aDir))
 
     dirlist = []
-    for root, dirs, files in os.walk(bDir): 
+    for root, dirs, files in os.walk(bDir):
       dirlist = dirs
       break
 
     self.mkdir(os.path.join(bDir, "tests"))
     self.move(os.path.join(bDir, "test_*"), os.path.join(bDir, "tests"))
 
     num_files = 0
     testfiles = []
@@ -128,37 +128,37 @@ class MochiKit(maemkit.MaemKit):
 
     num_copy = num_files / numtosplit
     count = 0
     round = 0
     for file in testfiles:
       self.copyfile(os.path.join(os.path.join(bDir, "tests"), file), os.path.join(bDir, str(round)))
 
       count = count + 1
-      if (count >= num_copy): 
+      if (count >= num_copy):
         count = 0
         if (round < numtosplit - 1): round = round + 1
 
     self.rmdir(os.path.join(bDir, "tests"))
 
 
   def getTests(self):
     rootdir = os.path.normpath(os.path.join(self.options["testroot"], "tests"))
-    if (self.options["test-path"] != ""): 
+    if (self.options["test-path"] != None):
       rootdir = os.path.normpath(os.path.join(rootdir, self.options["test-path"]))
     self.getDirectories(rootdir)
 
   def prepTests(self):
 
     # We need to copy to testdirs as self.splitDirectory modifies the self.directories variable
     testdirs = []
     for dir in self.directories: testdirs.append(dir)
 
-    for dir in testdirs: 
-      try: 
+    for dir in testdirs:
+      try:
         if (self.options["split-directories"].index(dir) >= 0): self.splitDirectory(dir)
       except: continue
 
     self.directories = self.splitListParallel(self.directories, self.options)
 
   def runTests(self):
     self.mkLogDir(self.options["logdir"])
 
@@ -167,12 +167,14 @@ class MochiKit(maemkit.MaemKit):
     for option in ["utility-path","appname","xre-path","certificate-path"]:
       self.mochitestCommand.append("--" + option + "=" + os.path.normpath(self.options[option]))
     mCommand = " ".join(self.mochitestCommand)
 
     for directory in self.directories:
       mydir = directory.replace('\\', '/')
       logfile = os.path.join(self.options["logdir"],  self.getLogFileName(directory))
       self.addCommand(mCommand + " --test-path=" + mydir + " --log-file=" + logfile)
+      if self.options['verbose'] and os.path.exists(logfile):
+          print ''.join(open(logfile).readlines())
       self.cleanup() #just for safety measures
 
   def parseLogs(self):
     self.stitchLogs()
--- a/refdriver.py
+++ b/refdriver.py
@@ -92,16 +92,18 @@ class RefDriver(maemkit.MaemKit):
 
     for dir in RefDriver.directories:
       logfile = os.path.join(self.options["logdir"],  self.getLogFileName(dir))
       logHandle = open(logfile, "w")
       utilname = os.path.normpath(os.path.join(self.options["utility-path"], "runreftest.py"))
       output = RefDriver.addCommand(self, "python " + utilname + " --appname=" + os.path.normpath(RefDriver.options["appname"]) + " " + dir, True)
       logHandle.write(output)
       logHandle.close()
+      if self.options['verbose'] and os.path.exists(logfile):
+          print ''.join(open(logfile).readlines())
       RefDriver.cleanup(self)
 
 class Reftest(RefDriver):
 
   def __init__(self, mkit):
     self.dirtype = mkit.dirtype
     self.addOptions(mkit.config_options["reftest"])
 
--- a/xpcdriver.py
+++ b/xpcdriver.py
@@ -55,12 +55,14 @@ class XpcDriver(maemkit.MaemKit):
 
       logfile = os.path.join(self.options["logdir"],  self.getLogFileName(test))
       logHandle = open(logfile, "w")
       testResults = self.addCommand(command, timeout=5)
       if (testResults == "*** TIMEOUT ***"):
         testResults = "TEST-UNEXPECTED-FAIL | " + test + " | TIMEOUT "
       logHandle.write(testResults)
       logHandle.close()
-    self.cleanup() 
+      if self.options['verbose'] and os.path.exists(logfile):
+        print ''.join(open(logfile).readlines())
+    self.cleanup()
 
   def parseLogs(self):
     self.stitchLogs()