Changes

Jump to: navigation, search

Run tests.py

3,377 bytes added, 17:13, 14 December 2006
no edit summary
# Contributor(s):
# Elizabeth Chak <elichak@gmail.com> (Seneca@York)
# Annie Sullivan <annie.sullivan@gmail.com> (original developer of the
# Performance Testing framework)
#
# Alternatively, the contents of this file may be used under the terms of
# ***** END LICENSE BLOCK *****
  """Runs This file runs extension performance tests.  This file It runs Ts (startup time) and Tp (page load time) tests for an extension with different profiles. Before this file is written, there were many problems with configuring the framework. Users were thrown with errors that took a long time to debug and solve. This file faciliates a user in configuring a framework with minimal frustration and time. It tries to eliminate as many user errors as possible, errors that users are prone to making while configuring the framework. Informative messages are shown to the user whenever they make an accidental error while configuring the framework. Comments: At first the program wouldn't exit on sys.exit() Rob Campbell suggested that I look into Ben Smedberg's killableprocess.py. It doesn't work with this because it's using Python 2.3 Haven't figured out how to work around the exceptions about ctypes library when I try to use killableprocess.py
"""
"""#### # Since python doesn't have 'switch' statements, this class # aims to duplicate C's original switch functionality and # structure with reasonable accuracy"""####
class switch(object):
def __init__(self, value):
return False
"""#### # This is a helper module that handles any exception"""####
def ExpHandler(*posargs):
return wrapper
##### Runs the Ts and Tp tests on the given config file and generates a report.# The file is validated to ensure that the config file is valid. However, it# doesn't check if all the profile items are valid. Only partial validation was# done. The firefox profile is checked to ensure that it is a valid location# of the browser that is used for testing.## To change the preferences that are set on the profiles that are # tested (config.yaml), you may edit the arrays in the main function below.# Args:# @type string# @param filename: the name of the config file where the profile of the # test is stored# # @type boolean# @return returns whether the test was successful or not ## @type dict# @param yaml[item]: the list of profile item values from the yaml file## @type list of yaml[item] dict values# @param test_configs## @type list# @param test_names; profile names; in our case, title, filename and other # test profile items: firefox, extensions ######@ExpHandler((KeyError, Exception))#wouldn't return value from module if this is not commented out
def test_file(filename):
"""Runs the Ts and Tp tests on the given config file and generates a report.
To change the preferences that are set on the profiles that are
tested (config.yaml), edit the arrays in the main function below.
Args:
@type string
@param filename: the name of the file to run the tests on
@type boolean
@return returns whether the test was successful or not
"""
test_configs = []
from time import sleep
# Instantiating a progress bar object to show the progress each time a profile is used for testing # With that said, the progress bar will show again if the user runs more than 1 config file progbar = pb.progressbarClass(4) #4 stages
# Run startup time test
progbar.progress(1)#progress bar stage 1 completed
ts_times = ts.RunStartupTests(paths.BASE_PROFILE_DIR,
test_configs,
TS_NUM_RUNS)
progbar.progress(2)#progress bar stage 2 completed
# Run page load test. For possible values of counters argument, see
# http://technet2.microsoft.com/WindowsServer/en/Library/86b5d116-6fb3-427b-af8c-9077162125fe1033.mspx?mfr=true
#are: title, filename and other test items: firefox, extensions
#and preferences
progbar.progress(3)#progress bar stage 3 completed
report.GenerateReport(title,
filename_prefix,
tp_counters,
TP_RESOLUTION)
progbar.progress(4)#progress bar stage 4 completed
return 1
##### # Checks the paths in paths.py to see if they are pointing to the right location.# If it doesn't, the user will be shown informative messages to fix the problem.# In the case of a missing directory, the user will be prompted if he/she would like# the directory to be created. It also checks if the base profile directory have# any contents or else the program will throw a nasty ZeroDivision Error. File paths# that uses the file url has to be parsed before being checked.# # Args:# @type list# @param path_dirs: a list of the dir path constant values in paths.py # # @type list# @param test_files: a list of the file path constant values in paths.py (file urls)##### #@ExpHandler((IOError, Exception))#wouldn't return value from module if this is not commented out
def checkPaths():
# Checks if the following paths exist (initialized in paths.py)
sys.exit(error) # it doesn't exit the program, why?
sys.stdout.flush()
#validates the file urls
validateURLS = True
return 0
return 0
###### Main funtion:# It will validate the required files, directories and configuration before performing the # Firefox Performance Testing. If the required configuration files/dirs don't validate, users# cannot start Firefox Performance Testing until the error is fixed.# User may list as many space-seperated config file arguments as possible when they run this file # Tells the user when the performance testing is starting, completed or failed/halted.#####
if __name__=='__main__':
testComplete = False
elif not testComplete:
print "Performance testing failed"
 
</pre>
1
edit

Navigation menu