예제 #1
0
    def checkForCrashes(self, browser_config, profile_dir):
        if platform.system() in ('Windows', 'Microsoft'):
            stackwalkpaths = ['win32', 'minidump_stackwalk.exe']
        elif platform.system() == 'Linux':
            if platform.machine() == 'armv6l':
                stackwalkpaths = ['maemo', 'minidump_stackwalk']
            elif '64' in platform.architecture()[0]: #are we 64 bit?
                stackwalkpaths = ['linux64', 'minidump_stackwalk']
            else:
                stackwalkpaths = ['linux', 'minidump_stackwalk']
        elif platform.system() == 'Darwin':
            stackwalkpaths = ['osx', 'minidump_stackwalk']
        else:
            return
        stackwalkbin = os.path.join(os.path.dirname(__file__), 'breakpad', *stackwalkpaths)

        found = False
        for dump in glob.glob(os.path.join(profile_dir, 'minidumps', '*.dmp')):
            utils.noisy("Found crashdump: " + dump)
            if browser_config['symbols_path']:
                nullfd = open(os.devnull, 'w')
                subprocess.call([stackwalkbin, dump, browser_config['symbols_path']], stderr=nullfd)
                nullfd.close()
            os.remove(dump)
            found = True

        if found:
            raise talosError("crash during run (stack found)")
예제 #2
0
파일: ttest.py 프로젝트: wlach/talos
    def cleanupAndCheckForCrashes(self, browser_config, profile_dir):
        cleanup_result = self._ffprocess.cleanupProcesses(browser_config['process'], 
                                                          browser_config['child_process'], 
                                                          browser_config['browser_wait']) 
        if platform.system() in ('Windows', 'Microsoft'):
            stackwalkpaths = ['win32', 'minidump_stackwalk.exe']
        elif platform.system() == 'Linux':
            if platform.machine() == 'armv6l':
                stackwalkpaths = ['maemo', 'minidump_stackwalk']
            elif '64' in platform.architecture()[0]: #are we 64 bit?
                stackwalkpaths = ['linux64', 'minidump_stackwalk']
            else:
                stackwalkpaths = ['linux', 'minidump_stackwalk']
        elif platform.system() == 'Darwin':
            stackwalkpaths = ['osx', 'minidump_stackwalk']
        else:
            return
        stackwalkbin = os.path.join(os.path.dirname(__file__), 'breakpad', *stackwalkpaths)

        found = False
        minidumpdir = os.path.join(profile_dir, 'minidumps')
        if browser_config['remote'] == True:
            minidumpdir = tempfile.mkdtemp()
            self._ffprocess.testAgent.getDirectory(profile_dir + '/minidumps/', minidumpdir)
        
        for dump in glob.glob(os.path.join(minidumpdir, '*.dmp')):
            utils.noisy("Found crashdump: " + dump)
            if browser_config['symbols_path']:
                nullfd = open(os.devnull, 'w')
                subprocess.call([stackwalkbin, dump, browser_config['symbols_path']], stderr=nullfd)
                nullfd.close()
            os.remove(dump)
            found = True

        if browser_config['remote'] == True:
            self._hostproc.removeDirectory(minidumpdir)
   
        if found:
            if cleanup_result:
                raise talosError("stack found after process termination (" + cleanup_result+ ")")
            else:
                raise talosError("crash during run (stack found)")
예제 #3
0
파일: ttest.py 프로젝트: wlach/talos
    def runTest(self, browser_config, test_config):
        """
            Runs an url based test on the browser as specified in the browser_config dictionary
  
        Args:
            browser_config:  Dictionary of configuration options for the browser (paths, prefs, etc)
            test_config   :  Dictionary of configuration for the given test (url, cycles, counters, etc)

        """
        self.initializeLibraries(browser_config)

        utils.debug("operating with platform_type : " + self.platform_type)
        counters = test_config[self.platform_type + 'counters']
        resolution = test_config['resolution']
        all_browser_results = []
        all_counter_results = []
        format = ""
        utils.setEnvironmentVars(browser_config['env'])
        utils.setEnvironmentVars({'MOZ_CRASHREPORTER_NO_REPORT': '1'})

        if browser_config['symbols_path']:
            utils.setEnvironmentVars({'MOZ_CRASHREPORTER': '1'})
        else:
            utils.setEnvironmentVars({'MOZ_CRASHREPORTER_DISABLE': '1'})

        utils.setEnvironmentVars({"LD_LIBRARY_PATH" : os.path.dirname(browser_config['browser_path'])})

        profile_dir = None

        try:
            running_processes = self._ffprocess.checkAllProcesses(browser_config['process'], browser_config['child_process'])
            if running_processes:
                msg = " already running before testing started (unclean system)"
                utils.debug(browser_config['process'] + msg)
                raise talosError("Found processes still running: %s. Please close them before running talos." % ", ".join(running_processes))

            for bundlename in browser_config['bundles']:
                self._ffsetup.InstallBundleInBrowser(browser_config['browser_path'],
                                                     bundlename,
                                                     browser_config['bundles'][bundlename])
  
            # add any provided directories to the installed browser
            for dir in browser_config['dirs']:
                self._ffsetup.InstallInBrowser(browser_config['browser_path'], 
                                            browser_config['dirs'][dir])
  
            # make profile path work cross-platform
            test_config['profile_path'] = os.path.normpath(test_config['profile_path'])
            profile_dir, temp_dir = self.createProfile(test_config['profile_path'], browser_config)
            if os.path.isfile(browser_config['browser_log']):
                os.chmod(browser_config['browser_log'], 0777)
                os.remove(browser_config['browser_log'])
            self.initializeProfile(profile_dir, browser_config)
    
            utils.debug("initialized " + browser_config['process'])
            if test_config['shutdown']:
                shutdown = []
            if 'responsiveness' in test_config and test_config['responsiveness']:
               utils.setEnvironmentVars({'MOZ_INSTRUMENT_EVENT_LOOP': '1'})
               utils.setEnvironmentVars({'MOZ_INSTRUMENT_EVENT_LOOP_THRESHOLD': '20'})
               utils.setEnvironmentVars({'MOZ_INSTRUMENT_EVENT_LOOP_INTERVAL': '10'})
               responsiveness = []

            for i in range(test_config['cycles']):
                if os.path.isfile(browser_config['browser_log']):
                    os.chmod(browser_config['browser_log'], 0777)
                    os.remove(browser_config['browser_log'])
                time.sleep(browser_config['browser_wait']) #wait out the browser closing
                # check to see if the previous cycle is still hanging around 
                if (i > 0) and self._ffprocess.checkAllProcesses(browser_config['process'], browser_config['child_process']):
                    raise talosError("previous cycle still running")

                # Execute the test's head script if there is one
                if 'head' in test_config:
                    try:
                        subprocess.call(['python', test_config['head']])
                    except:
                        raise talosError("error executing head script: %s" % sys.exc_info()[0])

                # Run the test 
                browser_results = ""
                if 'timeout' in test_config:
                     timeout = test_config['timeout']
                else:
                    timeout = 7200 # 2 hours
                total_time = 0
                output = ''
                url = test_config['url']
                command_line = self._ffprocess.GenerateBrowserCommandLine(browser_config['browser_path'],
                                                                        browser_config['extra_args'],
                                                                        profile_dir, 
                                                                        url)
  
                utils.debug("command line: " + command_line)

                b_log = browser_config['browser_log']
                if (self.remote == True):
                    b_log = browser_config['deviceroot'] + '/' + browser_config['browser_log']

                b_cmd = self._ffprocess.GenerateBControllerCommandLine(command_line, browser_config, test_config)
                process = subprocess.Popen(b_cmd, universal_newlines=True, shell=True, bufsize=0, env=os.environ)
  
                #give browser a chance to open
                # this could mean that we are losing the first couple of data points
                #   as the tests starts, but if we don't provide
                # some time for the browser to start we have trouble connecting the CounterManager to it
                time.sleep(browser_config['browser_wait'])
                #set up the counters for this test
                if counters:
                    cm = self.cmanager.CounterManager(self._ffprocess, browser_config['process'], counters)
                counter_results = {}
                for counter in counters:
                    counter_results[counter] = []

                startTime = -1
                dumpResult = ""
                #the main test loop, monitors counters and checks for browser output
                while total_time < timeout:
                    # Sleep for [resolution] seconds
                    time.sleep(resolution)
                    total_time += resolution
                    fileData = self._ffprocess.getFile(b_log)
                    if (len(fileData) > 0):
                        utils.noisy(fileData.replace(dumpResult, ''))
                        dumpResult = fileData
        

                    # Get the output from all the possible counters
                    for count_type in counters:
                        val = cm.getCounterValue(count_type)
                        if (val):
                            counter_results[count_type].append(val)
                    if process.poll() != None: #browser_controller completed, file now full
                        timed_out = False
                        break
                        
                if total_time >= timeout:
                    raise talosError("timeout exceeded")
                else:
                    #stop the counter manager since this test is complete
                    if counters:
                        cm.stopMonitor()

                    if not os.path.isfile(browser_config['browser_log']):
                        raise talosError("no output from browser")
                    results_file = open(browser_config['browser_log'], "r")
                    results_raw = results_file.read()
                    results_file.close()
  
                    match = self.RESULTS_REGEX.search(results_raw)
                    tpmatch = self.RESULTS_TP_REGEX.search(results_raw)
                    failmatch = self.RESULTS_REGEX_FAIL.search(results_raw)
                    if match:
                        browser_results += match.group(1)
                        startTime = int(match.group(2))
                        endTime = int(match.group(4))
                        format = "tsformat"
                    #TODO: this a stop gap until all of the tests start outputting the same format
                    elif tpmatch:
                        match = tpmatch
                        browser_results += match.group(1)
                        startTime = int(match.group(2))
                        endTime = int(match.group(4))
                        format = "tpformat"
                    elif failmatch:
                        match = failmatch
                        browser_results += match.group(1)
                        raise talosError(match.group(1))
                    else:
                        raise talosError("unrecognized output format")
  
                time.sleep(browser_config['browser_wait']) 
                #clean up any stray browser processes
                self.cleanupAndCheckForCrashes(browser_config, profile_dir)
                #clean up the bcontroller process
                timer = 0
                while ((process.poll() is None) and timer < browser_config['browser_wait']):
                    time.sleep(1)
                    timer+=1
 
                if test_config['shutdown']:
                    shutdown.append(endTime - startTime)
                if 'responsiveness' in test_config and test_config['responsiveness']:
                    responsiveness = self.RESULTS_RESPONSIVENESS_REGEX.findall(results_raw)

                all_browser_results.append(browser_results)
                all_counter_results.append(counter_results)

                # Execute the test's tail script if there is one
                if 'tail' in test_config:
                    try:
                        subprocess.call(['python', test_config['tail']])
                    except:
                        raise talosError("error executing tail script: %s" % sys.exc_info()[0])

            self.cleanupProfile(temp_dir)
            utils.restoreEnvironmentVars()
            if test_config['shutdown']:
                all_counter_results.append({'shutdown' : shutdown})      
            if 'responsiveness' in test_config and test_config['responsiveness']:
                all_counter_results.append({'responsiveness' : responsiveness})      
            return (all_browser_results, all_counter_results, format)
        except:
            try:
                if 'cm' in vars():
                    cm.stopMonitor()

                if os.path.isfile(browser_config['browser_log']):
                    results_file = open(browser_config['browser_log'], "r")
                    results_raw = results_file.read()
                    results_file.close()
                    utils.noisy(results_raw)

                if profile_dir:
                    try:
                        self.cleanupAndCheckForCrashes(browser_config, profile_dir)
                    except talosError:
                        pass

                if vars().has_key('temp_dir'):
                    self.cleanupProfile(temp_dir)
            except talosError, te:
                utils.debug("cleanup error: " + te.msg)
            except:
                utils.debug("unknown error during cleanup")
            raise
예제 #4
0
def runTest(browser_config, test_config):
  """
  Runs an url based test on the browser as specified in the browser_config dictionary
  
  Args:
    browser_config:  Dictionary of configuration options for the browser (paths, prefs, etc)
    test_config   :  Dictionary of configuration for the given test (url, cycles, counters, etc)
  
  """
 
  utils.debug("operating with platform_type : " + platform_type)
  counters = test_config[platform_type + 'counters']
  resolution = test_config['resolution']
  all_browser_results = []
  all_counter_results = []
  format = ""
  utils.setEnvironmentVars(browser_config['env'])
  utils.setEnvironmentVars({'MOZ_CRASHREPORTER_NO_REPORT': '1'})

  if browser_config['symbols_path']:
      utils.setEnvironmentVars({'MOZ_CRASHREPORTER': '1'})
  else:
      utils.setEnvironmentVars({'MOZ_CRASHREPORTER_DISABLE': '1'})

  utils.setEnvironmentVars({"LD_LIBRARY_PATH" : os.path.dirname(browser_config['browser_path'])})

  profile_dir = None

  try:
    if ffprocess.checkAllProcesses(browser_config['process']):
      utils.debug(browser_config['process'] + " already running before testing started (unclean system)")
      raise talosError("system not clean")
  
    # add any provided directories to the installed browser
    for dir in browser_config['dirs']:
      ffsetup.InstallInBrowser(browser_config['browser_path'], browser_config['dirs'][dir])
  
    # make profile path work cross-platform
    test_config['profile_path'] = os.path.normpath(test_config['profile_path'])
    profile_dir, temp_dir = test_config['profile_path'], test_config['profile_path']
    if os.path.isfile(browser_config['browser_log']):
      os.chmod(browser_config['browser_log'], 0777)
      os.remove(browser_config['browser_log'])
    #initializeProfile(profile_dir, browser_config)
    
    utils.debug("initialized " + browser_config['process'])
    if test_config['shutdown']:
      shutdown = []
  
    for i in range(test_config['cycles']):
      if os.path.isfile(browser_config['browser_log']):
        os.chmod(browser_config['browser_log'], 0777)
        os.remove(browser_config['browser_log'])
      time.sleep(browser_config['browser_wait']) #wait out the browser closing
      # check to see if the previous cycle is still hanging around 
      if (i > 0) and ffprocess.checkAllProcesses(browser_config['process']):
        raise talosError("previous cycle still running")
      # Run the test 
      browser_results = ""
      if 'timeout' in test_config:
        timeout = test_config['timeout']
      else:
        timeout = 7200 # 2 hours
      total_time = 0
      output = ''
      url = test_config['url']
      command_line = ffprocess.GenerateBrowserCommandLine(browser_config['browser_path'], browser_config['extra_args'], profile_dir, url)
  
      utils.debug("command line: " + command_line)
      bcontroller = path('talos/bcontroller.py') 
      if 'url_mod' in test_config:
        process = subprocess.Popen('python %s --command "%s" --mod "%s" --name %s --timeout %d --log %s' % (bcontroller, command_line, test_config['url_mod'], browser_config['process'], browser_config['browser_wait'], browser_config['browser_log']), universal_newlines=True, shell=True, bufsize=0, env=os.environ)
      else:
        process = subprocess.Popen('python %s --command "%s" --name %s --timeout %d --log %s' % (bcontroller, command_line, browser_config['process'], browser_config['browser_wait'], browser_config['browser_log']), universal_newlines=True, shell=True, bufsize=0, env=os.environ)
  
      #give browser a chance to open
      # this could mean that we are losing the first couple of data points as the tests starts, but if we don't provide
      # some time for the browser to start we have trouble connecting the CounterManager to it
      time.sleep(browser_config['browser_wait'])
      #set up the counters for this test
      if counters:
        cm = CounterManager(browser_config['process'], counters)
        cm.startMonitor()
      counter_results = {}
      for counter in counters:
        counter_results[counter] = []
     
      startTime = -1
      while total_time < timeout: #the main test loop, monitors counters and checks for browser ouptut
        # Sleep for [resolution] seconds
        time.sleep(resolution)
        total_time += resolution
        
        # Get the output from all the possible counters
        for count_type in counters:
          val = cm.getCounterValue(count_type)
          if (val):
            counter_results[count_type].append(val)
        if process.poll() != None: #browser_controller completed, file now full
          #stop the counter manager since this test is complete
          if counters:
            cm.stopMonitor()
          if not os.path.isfile(browser_config['browser_log']):
            raise talosError("no output from browser")
          results_file = open(browser_config['browser_log'], "r")
          results_raw = results_file.read()
          results_file.close()
          utils.noisy(results_raw)
  
          match = RESULTS_REGEX.search(results_raw)
          if match:
            browser_results += match.group(1)
            startTime = int(match.group(2))
            endTime = int(match.group(3))
            utils.debug("Matched basic results: " + browser_results)
            format = "tsformat"
            break
          #TODO: this a stop gap until all of the tests start outputting the same format
          match = RESULTS_TP_REGEX.search(results_raw)
          if match:
            browser_results += match.group(1)
            startTime = int(match.group(2))
            endTime = int(match.group(3))
            utils.debug("Matched tp results: " + browser_results)
            format = "tpformat"
            break
          match = RESULTS_REGEX_FAIL.search(results_raw)
          if match:
            browser_results += match.group(1)
            utils.debug("Matched fail results: " + browser_results)
            raise talosError(match.group(1))
          raise talosError("unrecognized output format")
  
      if total_time >= timeout:
        raise talosError("timeout exceeded")
  
      time.sleep(browser_config['browser_wait']) 
      #clean up the process
      timer = 0
      while ((process.poll() is None) and timer < browser_config['browser_wait']):
        time.sleep(1)
        timer+=1
 
      if test_config['shutdown']:
          shutdown.append(endTime - startTime)

      checkForCrashes(browser_config, profile_dir)

      utils.debug("Completed test with: " + browser_results)
  
      all_browser_results.append(browser_results)
      all_counter_results.append(counter_results)
     
    ffprocess.cleanupProcesses(browser_config['process'], browser_config['browser_wait']) 
    #cleanupProfile(temp_dir)

    utils.restoreEnvironmentVars()
    if test_config['shutdown']:
      all_counter_results.append({'shutdown' : shutdown})      
    return (all_browser_results, all_counter_results, format)
  except:
    try:
      if 'cm' in vars():
        cm.stopMonitor()

      if os.path.isfile(browser_config['browser_log']):
        results_file = open(browser_config['browser_log'], "r")
        results_raw = results_file.read()
        results_file.close()
        utils.noisy(results_raw)

      ffprocess.cleanupProcesses(browser_config['process'], browser_config['browser_wait'])

      if profile_dir:
          try:
              checkForCrashes(browser_config, profile_dir)
          except talosError:
              pass

      if vars().has_key('temp_dir'):
        pass
        #cleanupProfile(temp_dir)
    except talosError, te:
      utils.debug("cleanup error: " + te.msg)
    except:
      utils.debug("unknown error during cleanup")
    raise
예제 #5
0
def runTest(browser_config, test_config):
  """
  Runs an url based test on the browser as specified in the browser_config dictionary
  
  Args:
    browser_config:  Dictionary of configuration options for the browser (paths, prefs, etc)
    test_config   :  Dictionary of configuration for the given test (url, cycles, counters, etc)
  
  """
 
  utils.debug("operating with platform_type : " + platform_type)
  counters = test_config[platform_type + 'counters']
  resolution = test_config['resolution']
  all_browser_results = []
  all_counter_results = []
  utils.setEnvironmentVars(browser_config['env'])


  try:
    if checkAllProcesses():
      utils.debug("firefox already running before testing started (unclean system)")
      raise talosError("system not clean")
  
    # add any provided directories to the installed firefox
    for dir in browser_config['dirs']:
      ffsetup.InstallInBrowser(browser_config['firefox'], browser_config['dirs'][dir])
   
    profile_dir, temp_dir = createProfile(browser_config)
    initializeProfile(profile_dir, browser_config)
    
    utils.debug("initialized firefox")
    ffprocess.Sleep()
  
    for i in range(test_config['cycles']):
      # check to see if the previous cycle is still hanging around 
      if (i > 0) and checkAllProcesses():
        raise talosError("previous cycle still running")
      # Run the test 
      browser_results = ""
      if 'timeout' in test_config:
        timeout = test_config['timeout']
      else:
        timeout = 28800 # 8 hours
      if 'pagetimeout' in test_config:
         pagetimeout = test_config['pagetimeout']
      else:
         pagetimeout = 28800 # 8 hours
      total_time = 0
      output = ''
      url = test_config['url']
      if 'url_mod' in test_config:
        url += eval(test_config['url_mod']) 
      command_line = ffprocess.GenerateFirefoxCommandLine(browser_config['firefox'], profile_dir, url)
  
      utils.debug("command line: " + command_line)
  
      process = subprocess.Popen(command_line, stdout=subprocess.PIPE, universal_newlines=True, shell=True, bufsize=0, env=os.environ)
      handle = process.stdout
  
      #give firefox a chance to open
      # this could mean that we are losing the first couple of data points as the tests starts, but if we don't provide
      # some time for the browser to start we have trouble connecting the CounterManager to it
      ffprocess.Sleep()
      #set up the counters for this test
      if counters:
        cm = CounterManager("firefox", counters)
        cm.startMonitor()
      counter_results = {}
      for counter in counters:
        counter_results[counter] = []
     
      busted = False 
      lastNoise = 0
      while total_time < timeout:
        # Sleep for [resolution] seconds
        time.sleep(resolution)
        total_time += resolution
        lastNoise += resolution
        
        # Get the output from all the possible counters
        for count_type in counters:
          val = cm.getCounterValue(count_type)
  
          if (val):
            counter_results[count_type].append(val)
  
        # Check to see if page load times were outputted
        (bytes, current_output) = ffprocess.NonBlockingReadProcessOutput(handle)
        output += current_output
        match = RESULTS_GENERIC.search(current_output)
        if match:
          if match.group(1):
            utils.noisy(match.group(1))
            lastNoise = 0
        match = RESULTS_REGEX.search(output)
        if match:
          browser_results += match.group(1)
          utils.debug("Matched basic results: " + browser_results)
          break
        #TODO: this a stop gap until all of the tests start outputting the same format
        match = RESULTS_TP_REGEX.search(output)
        if match:
          browser_results += match.group(1)
          utils.debug("Matched tp results: " + browser_results)
          break
        match = RESULTS_REGEX_FAIL.search(output)
        if match:
          browser_results += match.group(1)
          utils.debug("Matched fail results: " + browser_results)
          raise talosError(match.group(1))
  
        #ensure that the browser is still running
        #check at intervals of 60 - this is just to cut down on load 
        #use the busted check to ensure that we aren't catching a bad time slice where the browser has
        # completed the test and closed but we haven't picked up the result yet
        if busted:
          raise talosError("browser crash")
        if (total_time % 60 == 0): 
          if not checkBrowserAlive():
            busted = True
        
        if lastNoise > pagetimeout:
          raise talosError("browser frozen")
  
      if total_time >= timeout:
        raise talosError("timeout exceeded")
  
      #stop the counter manager since this test is complete
      if counters:
        cm.stopMonitor()
  
      utils.debug("Completed test with: " + browser_results)
  
      all_browser_results.append(browser_results)
      all_counter_results.append(counter_results)
     
    cleanupProcesses() 
    cleanupProfile(temp_dir, browser_config)

    utils.restoreEnvironmentVars()
      
    return (all_browser_results, all_counter_results)
  except:
    try:
      cleanupProcesses()
      if vars().has_key('temp_dir'):
        cleanupProfile(temp_dir, browser_config)
    except talosError, te:
      utils.debug("cleanup error: " + te.msg)
    except:
      utils.debug("unknown error during cleanup")
    raise
예제 #6
0
    def runTest(self, browser_config, test_config):
        """
            Runs an url based test on the browser as specified in the browser_config dictionary
  
        Args:
            browser_config:  Dictionary of configuration options for the browser (paths, prefs, etc)
            test_config   :  Dictionary of configuration for the given test (url, cycles, counters, etc)

        """
        self.initializeLibraries(browser_config)
 
        utils.debug("operating with platform_type : " + self.platform_type)
        counters = test_config[self.platform_type + 'counters']
        resolution = test_config['resolution']
        all_browser_results = []
        all_counter_results = []
        format = ""
        utils.setEnvironmentVars(browser_config['env'])
        utils.setEnvironmentVars({'MOZ_CRASHREPORTER_NO_REPORT': '1'})

        if browser_config['symbols_path']:
            utils.setEnvironmentVars({'MOZ_CRASHREPORTER': '1'})
        else:
            utils.setEnvironmentVars({'MOZ_CRASHREPORTER_DISABLE': '1'})

        utils.setEnvironmentVars({"LD_LIBRARY_PATH" : os.path.dirname(browser_config['browser_path'])})

        profile_dir = None

        try:
            if self._ffprocess.checkAllProcesses(browser_config['process'], browser_config['child_process']):
                msg = " already running before testing started (unclean system)"
                utils.debug(browser_config['process'] + msg)
                raise talosError("system not clean")

            for bundlename in browser_config['bundles']:
                self._ffsetup.InstallBundleInBrowser(browser_config['browser_path'],
                                                     bundlename,
                                                     browser_config['bundles'][bundlename])
  
            # add any provided directories to the installed browser
            for dir in browser_config['dirs']:
                self._ffsetup.InstallInBrowser(browser_config['browser_path'], 
                                            browser_config['dirs'][dir])
  
            # make profile path work cross-platform
            test_config['profile_path'] = os.path.normpath(test_config['profile_path'])
            profile_dir, temp_dir = self.createProfile(test_config['profile_path'], browser_config)
            if os.path.isfile(browser_config['browser_log']):
                os.chmod(browser_config['browser_log'], 0777)
                os.remove(browser_config['browser_log'])
            self.initializeProfile(profile_dir, browser_config)
    
            utils.debug("initialized " + browser_config['process'])
            if test_config['shutdown']:
                shutdown = []

            for i in range(test_config['cycles']):
                if os.path.isfile(browser_config['browser_log']):
                    os.chmod(browser_config['browser_log'], 0777)
                    os.remove(browser_config['browser_log'])
                time.sleep(browser_config['browser_wait']) #wait out the browser closing
                # check to see if the previous cycle is still hanging around 
                if (i > 0) and self._ffprocess.checkAllProcesses(browser_config['process'], browser_config['child_process']):
                    raise talosError("previous cycle still running")

                # Execute the test's head script if there is one
                if 'head' in test_config:
                    try:
                        subprocess.call(['python', test_config['head']])
                    except:
                        raise talosError("error executing head script: %s" % sys.exc_info()[0])

                # Run the test 
                browser_results = ""
                if 'timeout' in test_config:
                     timeout = test_config['timeout']
                else:
                    timeout = 7200 # 2 hours
                total_time = 0
                output = ''
                url = test_config['url']
                command_line = self._ffprocess.GenerateBrowserCommandLine(browser_config['browser_path'],
                                                                        browser_config['extra_args'],
                                                                        profile_dir, 
                                                                        url)
  
                utils.debug("command line: " + command_line)
 
                b_cmd = 'python bcontroller.py --command "%s"' % (command_line)
                b_cmd += ' --child_process %s ' % (browser_config['child_process'])
                b_cmd += ' --name %s ' % (browser_config['process'])
                b_cmd += ' --timeout %d ' % (browser_config['browser_wait'])
                b_cmd += ' --log %s ' % (browser_config['browser_log'])
                if 'url_mod' in test_config:
                    b_cmd += ' --mod "%s" ' % (test_config['url_mod'])

                if (self.remote == True):
                    b_cmd += ' --host "%s" ' % (browser_config['host'])
                    b_cmd += ' --port "%s" ' % (browser_config['port'])
                    b_cmd += ' --deviceRoot "%s" ' % (browser_config['deviceroot'])

                process = subprocess.Popen(b_cmd, universal_newlines=True, shell=True, bufsize=0, env=os.environ)
  
                #give browser a chance to open
                # this could mean that we are losing the first couple of data points
                #   as the tests starts, but if we don't provide
                # some time for the browser to start we have trouble connecting the CounterManager to it
                time.sleep(browser_config['browser_wait'])
                #set up the counters for this test
                if counters:
                    cm = self.cmanager.CounterManager(self._ffprocess, browser_config['process'], counters)
                counter_results = {}
                for counter in counters:
                    counter_results[counter] = []

                startTime = -1
                dumpResult = ""
                #the main test loop, monitors counters and checks for browser ouptut
                while total_time < timeout:
                    # Sleep for [resolution] seconds
                    time.sleep(resolution)
                    total_time += resolution
                    fileData = self._ffprocess.getFile(browser_config['browser_log'])
                    if (len(fileData) > 0):
                        utils.noisy(fileData.replace(dumpResult, ''))
                        dumpResult = fileData
        

                    # Get the output from all the possible counters
                    for count_type in counters:
                        val = cm.getCounterValue(count_type)
                        if (val):
                            counter_results[count_type].append(val)
                    if process.poll() != None: #browser_controller completed, file now full
                        timed_out = False
                        break
                        
                if total_time >= timeout:
                    raise talosError("timeout exceeded")
                else:
                    #stop the counter manager since this test is complete
                    if counters:
                        cm.stopMonitor()

                    if not os.path.isfile(browser_config['browser_log']):
                        raise talosError("no output from browser")
                    results_file = open(browser_config['browser_log'], "r")
                    results_raw = results_file.read()
                    results_file.close()
  
                    match = self.RESULTS_REGEX.search(results_raw)
                    tpmatch = self.RESULTS_TP_REGEX.search(results_raw)
                    failmatch = self.RESULTS_REGEX_FAIL.search(results_raw)
                    if match:
                        browser_results += match.group(1)
                        startTime = int(match.group(2))
                        endTime = int(match.group(3))
                        format = "tsformat"
                    #TODO: this a stop gap until all of the tests start outputting the same format
                    elif tpmatch:
                        match = tpmatch
                        browser_results += match.group(1)
                        startTime = int(match.group(2))
                        endTime = int(match.group(3))
                        format = "tpformat"
                    elif failmatch:
                        match = failmatch
                        browser_results += match.group(1)
                        raise talosError(match.group(1))
                    else:
                        raise talosError("unrecognized output format")
  
                time.sleep(browser_config['browser_wait']) 
                #clean up the process
                timer = 0
                while ((process.poll() is None) and timer < browser_config['browser_wait']):
                    time.sleep(1)
                    timer+=1
 
                if test_config['shutdown']:
                    shutdown.append(endTime - startTime)

                self.checkForCrashes(browser_config, profile_dir)

                all_browser_results.append(browser_results)
                all_counter_results.append(counter_results)

                # Execute the test's tail script if there is one
                if 'tail' in test_config:
                    try:
                        subprocess.call(['python', test_config['tail']])
                    except:
                        raise talosError("error executing tail script: %s" % sys.exc_info()[0])

            self._ffprocess.cleanupProcesses(browser_config['process'], browser_config['child_process'], browser_config['browser_wait']) 
            self.cleanupProfile(temp_dir)

            utils.restoreEnvironmentVars()
            if test_config['shutdown']:
                all_counter_results.append({'shutdown' : shutdown})      
            return (all_browser_results, all_counter_results, format)
        except:
            try:
                if 'cm' in vars():
                    cm.stopMonitor()

                if os.path.isfile(browser_config['browser_log']):
                    results_file = open(browser_config['browser_log'], "r")
                    results_raw = results_file.read()
                    results_file.close()
                    utils.noisy(results_raw)

                self._ffprocess.cleanupProcesses(browser_config['process'], browser_config['child_process'], 
                                                browser_config['browser_wait'])

                if profile_dir:
                    try:
                        self.checkForCrashes(browser_config, profile_dir)
                    except talosError:
                        pass

                if vars().has_key('temp_dir'):
                    self.cleanupProfile(temp_dir)
            except talosError, te:
                utils.debug("cleanup error: " + te.msg)
            except:
                utils.debug("unknown error during cleanup")
            raise