diff options
Diffstat (limited to 'framework/suites.py')
-rw-r--r-- | framework/suites.py | 134 |
1 files changed, 0 insertions, 134 deletions
diff --git a/framework/suites.py b/framework/suites.py deleted file mode 100644 index 5b892c5..0000000 --- a/framework/suites.py +++ /dev/null @@ -1,134 +0,0 @@ -# -# Copyright © 2012 Intel Corporation -# -# Permission is hereby granted, free of charge, to any person obtaining a -# copy of this software and associated documentation files (the "Software"), -# to deal in the Software without restriction, including without limitation -# the rights to use, copy, modify, merge, publish, distribute, sublicense, -# and/or sell copies of the Software, and to permit persons to whom the -# Software is furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice (including the next -# paragraph) shall be included in all copies or substantial portions of the -# Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL -# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS -# IN THE SOFTWARE. -# -import json -import xml.etree.ElementTree as ET -import os.path as path -import re - -#import framework.test - -#__all__ = ['TestSuite'] - -############################################################################# -##### Test suite descriptions -############################################################################# - -class TestSuite: - """ - Description of a test suite. - - For now, this contains the following information: - - Name - - Description - - Absolute path to the XML test list file - - How to invoke tests - - How to interpret tests results - - How to pass specific flags such as platform, quick mode, and so on. - - Dictionary of tests - """ - def __init__(self, xmlFile): - tree = ET.parse(xmlFile) - suiteElem = tree.getroot() - - self.name = suiteElem.attrib['name'] - self.description = suiteElem.attrib['description'] - self.testlist_file = path.abspath(path.join(path.dirname(xmlFile.name), suiteElem.attrib['tests'])) - - resultElem = suiteElem.find('result') - - self.status_default = resultElem.attrib['default'] - self.status_re = {} - for rx in resultElem: - self.status_re[rx.attrib['status']] = re.compile(rx.text) - - # XXX: parse <platforms> and <quick> - - self.tests = {} - - def interpretResult(self, output): - """ - Interpret a test's output and return its result status. - - Applies the suite's regular expressions to the output, seeing which - one matches. If none match, returns the suite's default status. - - The result will be either 'pass', 'fail', or 'skip'. - """ - for status, re in self.status_re.items(): - if re.search(output) is not None: - return status - - return self.status_default - -############################################################################# -##### Configuration file reading -############################################################################# - -def availableSuites(): - """ - Read the ~/.robynrc file and fetch a list of available test suites. - - Returns a dictionary whose keys are suite names, and whose items are - absolute paths to the JSON suite description file. - - Does not create TestSuite objects and populate the test suite information. - """ - # XXX: load list of available suites from ~/.robynrc or such - return {'piglit': '/home/kwg/Projects/piglit/robyn-piglit.xml', - 'glean': '/home/kwg/Projects/piglit/robyn-glean.xml'} - -### [str] x bool -> {str -> TestSuite} -def loadSuiteInfo(desiredSuites, loadTests): - """ - Load TestSuite descriptions for a list of requested suites. - """ - suiteFiles = availableSuites() - - suiteInfo = {} - - for name in desiredSuites: - if name not in suiteFiles: - print('error: unknown test suite "%s".\n' % name) - print(' Available Suites:') - for s in suiteFiles.keys(): - print(' -', s) - return {} - - with open(suiteFiles[name], 'r') as fp: - suiteInfo[name] = TestSuite(fp) - - if loadTests: - loadTestList(suiteInfo[name]) - - return suiteInfo - -### TestSuite -> None -def loadTestList(suite): - """Actually load the tests.""" - - with open(suite.testlist_file) as fp: - js = json.load(fp) - - suite.tests = js - - return None |