ndex: testing/performance/talos/ffprocess_linux.py =================================================================== RCS file: /cvsroot/mozilla/testing/performance/talos/ffprocess_linux.py,v retrieving revision 1.8 diff -u -1 -0 -r1.8 ffprocess_linux.py --- testing/performance/talos/ffprocess_linux.py 14 Apr 2008 22:38:19 -0000 1.8 +++ testing/performance/talos/ffprocess_linux.py 22 May 2008 01:36:34 -0000 @@ -36,36 +36,37 @@ # ***** END LICENSE BLOCK ***** import subprocess import signal import os from select import select import time -def GenerateFirefoxCommandLine(firefox_path, profile_dir, url): +def GenerateFirefoxCommandLine(firefox_path, extra_args, profile_dir, url): """Generates the command line for a process to run Firefox Args: firefox_path: String containing the path to the firefox exe to use profile_dir: String containing the directory of the profile to run Firefox in url: String containing url to start with. """ profile_arg = '' if profile_dir: profile_arg = '-profile %s' % profile_dir - cmd = '%s %s %s' % (firefox_path, - profile_arg, - url) + cmd = '%s %s %s %s' % (firefox_path, + extra_args, + profile_arg, + url) return cmd def GetPidsByName(process_name): """Searches for processes containing a given string. This function is UNIX specific. Args: process_name: The string to be searched for Index: testing/performance/talos/ffprocess_mac.py =================================================================== RCS file: /cvsroot/mozilla/testing/performance/talos/ffprocess_mac.py,v retrieving revision 1.9 diff -u -1 -0 -r1.9 ffprocess_mac.py --- testing/performance/talos/ffprocess_mac.py 14 Apr 2008 22:38:19 -0000 1.9 +++ testing/performance/talos/ffprocess_mac.py 22 May 2008 01:36:34 -0000 @@ -40,36 +40,37 @@ #HACK - http://www.gossamer-threads.com/lists/python/bugs/593800 #To stop non-threadsafe popen nonsense, should be removed when we upgrade to #python 2.5 or later subprocess._cleanup = lambda: None import signal import os import time from select import select -def GenerateFirefoxCommandLine(firefox_path, profile_dir, url): +def GenerateFirefoxCommandLine(firefox_path, extra_args, profile_dir, url): """Generates the command line for a process to run Firefox Args: firefox_path: String containing the path to the firefox binary to use profile_dir: String containing the directory of the profile to run Firefox in url: String containing url to start with. """ profile_arg = '' if profile_dir: profile_arg = '-profile %s' % profile_dir - cmd = '%s -foreground %s %s' % (firefox_path, - profile_arg, - url) + cmd = '%s -foreground %s %s %s' % (firefox_path, + extra_args, + profile_arg, + url) return cmd def GetPidsByName(process_name): """Searches for processes containing a given string. Args: process_name: The string to be searched for Returns: Index: testing/performance/talos/ffprocess_win32.py =================================================================== RCS file: /cvsroot/mozilla/testing/performance/talos/ffprocess_win32.py,v retrieving revision 1.6 diff -u -1 -0 -r1.6 ffprocess_win32.py --- testing/performance/talos/ffprocess_win32.py 14 Apr 2008 22:38:19 -0000 1.6 +++ testing/performance/talos/ffprocess_win32.py 22 May 2008 01:36:34 -0000 @@ -36,37 +36,38 @@ # ***** END LICENSE BLOCK ***** import win32api import win32file import win32pdhutil import win32pdh import win32pipe import msvcrt -def GenerateFirefoxCommandLine(firefox_path, profile_dir, url): +def GenerateFirefoxCommandLine(firefox_path, extra_args, profile_dir, url): """Generates the command line for a process to run Firefox Args: firefox_path: String containing the path to the firefox exe to use profile_dir: String containing the directory of the profile to run Firefox in url: String containing url to start with. """ profile_arg = '' if profile_dir: profile_dir = profile_dir.replace('\\', '\\\\\\') profile_arg = '-profile %s' % profile_dir - cmd = '%s %s %s' % (firefox_path, - profile_arg, - url) + cmd = '%s %s %s %s' % (firefox_path, + extra_args, + profile_arg, + url) return cmd def TerminateProcess(pid): """Helper function to terminate a process, given the pid Args: pid: integer process id of the process to terminate. """ Index: testing/performance/talos/ffsetup.py =================================================================== RCS file: /cvsroot/mozilla/testing/performance/talos/ffsetup.py,v retrieving revision 1.5 diff -u -1 -0 -r1.5 ffsetup.py --- testing/performance/talos/ffsetup.py 14 Apr 2008 22:38:19 -0000 1.5 +++ testing/performance/talos/ffsetup.py 22 May 2008 01:36:34 -0000 @@ -133,32 +133,32 @@ # add the provided directory to the given firefox install fromfiles = glob.glob(os.path.join(dir_path, '*')) todir = os.path.join(os.path.dirname(firefox_path), os.path.basename(os.path.normpath(dir_path))) for fromfile in fromfiles: if not os.path.isfile(os.path.join(todir, os.path.basename(fromfile))): shutil.copy(fromfile, todir) utils.debug("installed " + fromfile) else: utils.debug("WARNING: file already installed (" + fromfile + ")") -def InitializeNewProfile(firefox_path, profile_dir, init_url): +def InitializeNewProfile(firefox_path, extra_args, process_name, profile_dir, init_url): """Runs Firefox with the new profile directory, to negate any performance hit that could occur as a result of starting up with a new profile. Also kills the "extra" Firefox that gets spawned the first time Firefox is run with a new profile. Args: firefox_path: String containing the path to the Firefox exe profile_dir: The full path to the profile directory to load """ PROFILE_REGEX = re.compile('__metrics(.*)__metrics', re.DOTALL|re.MULTILINE) res = 1 - cmd = ffprocess.GenerateFirefoxCommandLine(firefox_path, profile_dir, init_url) + cmd = ffprocess.GenerateFirefoxCommandLine(firefox_path, extra_args, profile_dir, init_url) (match, timed_out) = ffprocess.RunProcessAndWaitForOutput(cmd, - 'firefox', - PROFILE_REGEX, - 30) + process_name, + PROFILE_REGEX, + 30) if (not timed_out): print match else: res = 0 return res Index: testing/performance/talos/run_tests.py =================================================================== RCS file: /cvsroot/mozilla/testing/performance/talos/run_tests.py,v retrieving revision 1.28 diff -u -1 -0 -r1.28 run_tests.py --- testing/performance/talos/run_tests.py 14 May 2008 22:14:56 -0000 1.28 +++ testing/performance/talos/run_tests.py 22 May 2008 01:36:34 -0000 @@ -255,57 +255,74 @@ """ browser_config = [] tests = [] title = '' testdate = '' csv_dir = '' results_server = '' results_link = '' results = {} - + process_name = {} + extra_args = {} + # Read in the profile info from the YAML config file config_file = open(filename, 'r') yaml_config = yaml.load(config_file) config_file.close() for item in yaml_config: if item == 'title': title = yaml_config[item] elif item == 'testdate': testdate = yaml_config[item] elif item == 'csv_dir': csv_dir = os.path.normpath(yaml_config[item]) if not os.path.exists(csv_dir): print "FAIL: path \"" + csv_dir + "\" does not exist" sys.exit(0) elif item == 'results_server': results_server = yaml_config[item] elif item == 'results_link' : results_link = yaml_config[item] + elif item == 'process_name' : + process_name = yaml_config['process_name'] + elif item == 'extra_args' : + extra_args = yaml_config['extra_args'] + if (results_link != results_server != ''): if not post_file.link_exists(results_server, results_link): sys.exit(0) browser_config = {'preferences' : yaml_config['preferences'], 'extensions' : yaml_config['extensions'], 'firefox' : yaml_config['firefox'], 'branch' : yaml_config['branch'], 'buildid' : yaml_config['buildid'], 'profile_path' : yaml_config['profile_path'], 'env' : yaml_config['env'], 'dirs' : yaml_config['dirs'], 'init_url' : yaml_config['init_url']} #normalize paths to work accross platforms browser_config['firefox'] = os.path.normpath(browser_config['firefox']) if browser_config['profile_path'] != {}: browser_config['profile_path'] = os.path.normpath(browser_config['profile_path']) for dir in browser_config['dirs']: browser_config['dirs'][dir] = os.path.normpath(browser_config['dirs'][dir]) + + #processname. + if process_name == {}: + browser_config['process_name'] = "firefox" + else: + browser_config['process_name'] = process_name + + #extra_args + browser_config['extra_args'] = extra_args + tests = yaml_config['tests'] config_file.close() if (testdate != ''): date = int(time.mktime(time.strptime(testdate, '%a, %d %b %Y %H:%M:%S GMT'))) else: date = int(time.time()) #TODO get this into own file utils.debug("using testdate: %d" % date) utils.debug("actual date: %d" % int(time.time())) utils.stamped_msg(title, "Started") Index: testing/performance/talos/ttest.py =================================================================== RCS file: /cvsroot/mozilla/testing/performance/talos/ttest.py,v retrieving revision 1.14 diff -u -1 -0 -r1.14 ttest.py --- testing/performance/talos/ttest.py 14 Apr 2008 22:38:19 -0000 1.14 +++ testing/performance/talos/ttest.py 22 May 2008 01:36:34 -0000 @@ -75,58 +75,62 @@ # Regula expression for getting results from most tests RESULTS_REGEX = re.compile('__start_report(.*)__end_report', re.DOTALL | re.MULTILINE) # Regular expression to get stats for page load test (Tp) - should go away once data passing is standardized RESULTS_TP_REGEX = re.compile('__start_tp_report(.*)__end_tp_report', re.DOTALL | re.MULTILINE) RESULTS_GENERIC = re.compile('(.*)', re.DOTALL | re.MULTILINE) RESULTS_REGEX_FAIL = re.compile('__FAIL(.*)__FAIL', re.DOTALL|re.MULTILINE) -def checkBrowserAlive(): +def checkBrowserAlive(browser_config): #is the browser actually up? - return (ffprocess.ProcessesWithNameExist("firefox") and not ffprocess.ProcessesWithNameExist("crashreporter", "talkback", "dwwin")) + return (ffprocess.ProcessesWithNameExist(browser_config['process_name']) and not ffprocess.ProcessesWithNameExist("crashreporter", "talkback", "dwwin")) -def checkAllProcesses(): +def checkAllProcesses(browser_config): #is anything browser related active? - return ffprocess.ProcessesWithNameExist("firefox", "crashreporter", "talkback", "dwwin") + return ffprocess.ProcessesWithNameExist(browser_config['process_name'], "crashreporter", "talkback", "dwwin") -def cleanupProcesses(): - #kill any remaining firefox processes - ffprocess.TerminateAllProcesses("firefox", "crashreporter", "dwwin", "talkback") +def cleanupProcesses(browser_config): + #kill any remaining processes + ffprocess.TerminateAllProcesses(browser_config['process_name'], "crashreporter", "dwwin", "talkback") #check if anything is left behind - if checkAllProcesses(): + if checkAllProcesses(browser_config): #this is for windows machines. when attempting to send kill messages to win processes the OS # always gives the process a chance to close cleanly before terminating it, this takes longer # and we need to give it a little extra time to complete time.sleep(10) - if checkAllProcesses(): + if checkAllProcesses(browser_config): raise talosError("failed to cleanup") def createProfile(browser_config): if browser_config["profile_path"] != {}: # Create the new profile temp_dir, profile_dir = ffsetup.CreateTempProfileDir(browser_config['profile_path'], browser_config['preferences'], browser_config['extensions']) utils.debug("created profile") else: # no profile path was set in the config, set the profile_dir to an empty string. profile_dir = "" return profile_dir, temp_dir def initializeProfile(profile_dir, browser_config): if browser_config["profile_path"] != {}: - if not (ffsetup.InitializeNewProfile(browser_config['firefox'], profile_dir, browser_config['init_url'])): + if not (ffsetup.InitializeNewProfile(browser_config['firefox'], + browser_config['extra_args'], + browser_config['process_name'], + profile_dir, + browser_config['init_url'])): raise talosError("failed to initialize browser") time.sleep(10) - if checkAllProcesses(): + if checkAllProcesses(browser_config): raise talosError("browser failed to close after being initialized") def cleanupProfile(dir, browser_config): # Delete the temp profile directory Make it writeable first, # because every once in a while Firefox seems to drop a read-only # file into it. if browser_config["profile_path"] != {}: ffsetup.MakeDirectoryContentsWritable(dir) shutil.rmtree(dir) @@ -142,63 +146,63 @@ 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)") + if checkAllProcesses(browser_config): + utils.debug("A process with the name of " + browser_config['process_name'] + "already running before testing started (unclean system)") raise talosError("system not clean") - # add any provided directories to the installed firefox + # add any provided directories to the install directory. 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") + utils.debug("initialized " + browser_config['process_name']) 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(): + if (i > 0) and checkAllProcesses(browser_config): 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 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) + command_line = ffprocess.GenerateFirefoxCommandLine(browser_config['firefox'], browser_config['extra_args'], 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 = CounterManager(browser_config['process_name'], counters) cm.startMonitor() counter_results = {} for counter in counters: counter_results[counter] = [] busted = False while total_time < timeout: # Sleep for [resolution] seconds time.sleep(resolution) total_time += resolution @@ -234,41 +238,41 @@ 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(): + if not checkBrowserAlive(browser_config): busted = True 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() + cleanupProcesses(browser_config) cleanupProfile(temp_dir, browser_config) utils.restoreEnvironmentVars() return (all_browser_results, all_counter_results) except: try: - cleanupProcesses() + cleanupProcesses(browser_config) 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