Bug 849270 - Add --symbols-path to marionette test runner, r=jgriffin, a=test-only
authorAndrew Halberstadt <ahalberstadt@mozilla.com>
Wed, 03 Apr 2013 10:58:53 -0400
changeset 118958 a8409aef121a619a85f369dbc1803245e91dd78b
parent 118957 add77bd3bef3923338f411ca5d4eb5f2f43ca33f
child 118959 c7a09b6d07464bfa356e8b85c264f6ed273c7ec3
push id617
push userahalberstadt@mozilla.com
push dateWed, 03 Apr 2013 15:33:44 +0000
reviewersjgriffin, test-only
bugs849270
milestone18.0
Bug 849270 - Add --symbols-path to marionette test runner, r=jgriffin, a=test-only
testing/marionette/client/marionette/b2ginstance.py
testing/marionette/client/marionette/runtests.py
--- a/testing/marionette/client/marionette/b2ginstance.py
+++ b/testing/marionette/client/marionette/b2ginstance.py
@@ -110,22 +110,20 @@ class B2GInstance(object):
         local_profiles_ini = tempfile.NamedTemporaryFile()
         self.dm.getFile(remote_profiles_ini, local_profiles_ini.name)
         cfg = ConfigParser()
         cfg.readfp(local_profiles_ini)
 
         remote_profiles = []
         for section in cfg.sections():
             if cfg.has_option(section, 'Path'):
-                is_relative = 0
-                if cfg.has_option(section, 'IsRelative'):
-                    is_relative = cfg.getint(section, 'IsRelative')
-
-                remote_profiles.append(posixpath.join(remote_profiles_ini, cfg.get(section, 'Path'))
-                                        if is_relative else cfg.get(section, 'Path'))
+                if cfg.has_option(section, 'IsRelative') and cfg.get(section, 'IsRelative'):
+                    remote_profiles.append(posixpath.join(posixpath.dirname(remote_profiles_ini), cfg.get(section, 'Path')))
+                else:
+                    remote_profiles.append(cfg.get(section, 'Path'))
         return remote_profiles
 
     def check_for_crashes(self, symbols_path):
         remote_dump_dirs = [posixpath.join(p, 'minidumps') for p in self.check_remote_profiles()]
         crashed = False
         for remote_dump_dir in remote_dump_dirs:
             print "checking for crashes in '%s'" % remote_dump_dir
             local_dump_dir = tempfile.mkdtemp()
--- a/testing/marionette/client/marionette/runtests.py
+++ b/testing/marionette/client/marionette/runtests.py
@@ -8,16 +8,17 @@ import inspect
 import logging
 from optparse import OptionParser
 import os
 import unittest
 import socket
 import sys
 import time
 import platform
+import traceback
 import moznetwork
 import xml.dom.minidom as dom
 
 from manifestparser import TestManifest
 from mozhttpd import MozHttpd
 
 from marionette import Marionette
 from marionette_test import MarionetteJSTestCase, MarionetteTestCase
@@ -181,17 +182,18 @@ class MarionetteTextTestRunner(unittest.
 class MarionetteTestRunner(object):
 
     def __init__(self, address=None, emulator=None, emulatorBinary=None,
                  emulatorImg=None, emulator_res='480x800', homedir=None,
                  bin=None, profile=None, autolog=False, revision=None,
                  es_server=None, rest_server=None, logger=None,
                  testgroup="marionette", noWindow=False, logcat_dir=None,
                  xml_output=None, repeat=0, perf=False, perfserv=None,
-                 gecko_path=None, testvars=None, tree=None, device=None):
+                 gecko_path=None, testvars=None, tree=None, device=None,
+                 symbols_path=None):
         self.address = address
         self.emulator = emulator
         self.emulatorBinary = emulatorBinary
         self.emulatorImg = emulatorImg
         self.emulator_res = emulator_res
         self.homedir = homedir
         self.bin = bin
         self.profile = profile
@@ -210,16 +212,17 @@ class MarionetteTestRunner(object):
         self.xml_output = xml_output
         self.repeat = repeat
         self.perf = perf
         self.perfserv = perfserv
         self.gecko_path = gecko_path
         self.testvars = {} 
         self.tree = tree
         self.device = device
+        self.symbols_path = symbols_path
 
         if testvars:
             if not os.path.exists(testvars):
                 raise Exception('--testvars file does not exist')
             
             import json
             with open(testvars) as f:
                 self.testvars = json.loads(f.read())
@@ -278,32 +281,34 @@ class MarionetteTestRunner(object):
             host, port = self.address.split(':')
             if self.emulator:
                 self.marionette = Marionette.getMarionetteOrExit(
                                              host=host, port=int(port),
                                              connectToRunningEmulator=True,
                                              homedir=self.homedir,
                                              baseurl=self.baseurl,
                                              logcat_dir=self.logcat_dir,
-                                             gecko_path=self.gecko_path)
+                                             gecko_path=self.gecko_path,
+                                             symbols_path=self.symbols_path)
             else:
                 self.marionette = Marionette(host=host,
                                              port=int(port),
                                              baseurl=self.baseurl)
         elif self.emulator:
             self.marionette = Marionette.getMarionetteOrExit(
                                          emulator=self.emulator,
                                          emulatorBinary=self.emulatorBinary,
                                          emulatorImg=self.emulatorImg,
                                          emulator_res=self.emulator_res,
                                          homedir=self.homedir,
                                          baseurl=self.baseurl,
                                          noWindow=self.noWindow,
                                          logcat_dir=self.logcat_dir,
-                                         gecko_path=self.gecko_path)
+                                         gecko_path=self.gecko_path,
+                                         symbols_path=self.symbols_path)
         else:
             raise Exception("must specify binary, address or emulator")
 
     def post_to_autolog(self, elapsedtime):
         self.logger.info('posting results to autolog')
 
         logfile = None
         if self.emulator:
@@ -350,16 +355,21 @@ class MarionetteTestRunner(object):
         while self.repeat >=0:
             for test in tests:
                 self.run_test(test, testtype)
             self.repeat -= 1
         self.logger.info('\nSUMMARY\n-------')
         self.logger.info('passed: %d' % self.passed)
         self.logger.info('failed: %d' % self.failed)
         self.logger.info('todo: %d' % self.todo)
+        try:
+            self.marionette.check_for_crash()
+        except:
+            traceback.print_exc()
+
         self.elapsedtime = datetime.utcnow() - starttime
         if self.autolog:
             self.post_to_autolog(self.elapsedtime)
         if self.perfrequest and options.perf:
             try:
                 self.perfrequest.submit()
             except Exception, e:
                 print "Could not submit to datazilla"
@@ -631,16 +641,20 @@ def parse_options():
                       help='path to B2G gecko binaries that should be '
                       'installed on the device or emulator')
     parser.add_option('--testvars', dest='testvars', action='store',
                       default=None,
                       help='path to a JSON file with any test data required')
     parser.add_option('--tree', dest='tree', action='store',
                       default='b2g',
                       help='the tree that the revsion parameter refers to')
+    parser.add_option('--symbols-path', dest='symbols_path', action='store',
+                      default=None,
+                      help='absolute path to directory containing breakpad '
+                      'symbols, or the URL of a zip file containing symbols')
 
     options, tests = parser.parse_args()
 
     if not tests:
         parser.print_usage()
         parser.exit()
 
     if not options.emulator and not options.address and not options.bin:
@@ -685,17 +699,18 @@ def startTestRunner(runner_class, option
                           tree=options.tree,
                           autolog=options.autolog,
                           xml_output=options.xml_output,
                           repeat=options.repeat,
                           perf=options.perf,
                           perfserv=options.perfserv,
                           gecko_path=options.gecko_path,
                           testvars=options.testvars,
-                          device=options.device)
+                          device=options.device,
+                          symbols_path=options.symbols_path)
     runner.run_tests(tests, testtype=options.type)
     return runner
 
 def cli(runner_class=MarionetteTestRunner):
     options, tests = parse_options()
     runner = startTestRunner(runner_class, options, tests)
     if runner.failed > 0:
         sys.exit(10)