summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-04-20 13:01:15 -0700
committerKenneth Graunke <kenneth@whitecape.org>2012-04-20 13:01:15 -0700
commitad157035fc1ee33c14c0523626559894b2961de0 (patch)
treefcab81f1ef4b62f1ae6e9c92086c0c1b791f8706
parentefb54763df0c3baee75f7eeffe34400abc342210 (diff)
Ditch the JSON, use XML
-rw-r--r--framework/suites.py53
-rw-r--r--framework/xsuite.py141
-rwxr-xr-xprograms/run.py3
3 files changed, 34 insertions, 163 deletions
diff --git a/framework/suites.py b/framework/suites.py
index abd968c..f85a84f 100644
--- a/framework/suites.py
+++ b/framework/suites.py
@@ -21,6 +21,7 @@
# IN THE SOFTWARE.
#
import json
+import xml.etree.ElementTree as ET
import os.path as path
import re
@@ -28,6 +29,8 @@ import re
#__all__ = ['TestSuite', 'TestKind']
+kinds = {}
+
class TestSuite:
"""
Description of a test suite.
@@ -36,19 +39,24 @@ class TestSuite:
- Name
- Description
- List of registered TestKinds
- - Absolute path to the JSON test list file
+ - Absolute path to the XML test list file
- Dictionary of tests
"""
- def __init__(self, jsonFile):
- js = json.load(jsonFile)
+ def __init__(self, xmlFile):
+ tree = ET.parse(xmlFile)
+ xmlSuite = tree.getroot()
- self.name = js['name']
- self.description = js['description']
- self.types = map(TestKind, js['types'].items())
- self.testlist_file = path.abspath(path.join(path.dirname(jsonFile.name), js['tests']))
- self.tests = {}
+ self.name = xmlSuite.attrib['name']
+ self.description = xmlSuite.attrib['description']
+ self.testlist_file = path.abspath(path.join(path.dirname(xmlFile.name), xmlSuite.attrib['tests']))
+ self.kinds = {}
+ for xmlKind in xmlSuite[0]:
+ self.kinds[xmlKind.attrib['tag']] = TestKind(xmlKind)
-kinds = {}
+ # Register the kinds...
+ kinds.update(self.kinds)
+
+ self.tests = {}
class TestKind:
"""
@@ -62,22 +70,26 @@ class TestKind:
Test suites may register several different types of tests. In the
JSON test list, the "type" tag indicates what kind of test it is.
"""
- def __init__(self, name, desc):
- self.default_result = desc['default_result']
+ def __init__(self, xmlKind):
+ xmlResult = xmlKind.find('result')
+
+ self.default_result = xmlResult.attrib['default']
self.regexs = {}
- for status, exp in desc['regexp'].items():
- self.regexs[status] = re.compile(exp)
+ for rx in xmlResult:
+ self.regexs[rx.attrib['status']] = re.compile(rx.text)
+
+ # XXX: parse <platforms> and <quick>
# Register this Kind so it's available
# XXX: may want to move this into the caller...or caller's caller
- assert name not in kinds
- kinds[name] = self
+ #assert name not in kinds
+ #kinds[name] = self
def interpretResult(self):
- for status, re in self.regexs.items():
- if re.search(out) is not None:
- result = status
- break
+ #for status, re in self.regexs.items():
+ #if re.search(out) is not None:
+ #result = status
+ #break
result = self.default_result
def availableSuites():
@@ -90,7 +102,7 @@ def availableSuites():
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-suite.json'}
+ return {'piglit': '/home/kwg/Projects/piglit/robyn-suite.xml'}
### [str] x bool -> {str -> TestSuite}
def loadSuiteInfo(desiredSuites, loadTests):
@@ -124,7 +136,6 @@ def loadTestList(suite):
with open(suite.testlist_file) as fp:
js = json.load(fp)
- for file in tests
suite.tests = js
return None
diff --git a/framework/xsuite.py b/framework/xsuite.py
deleted file mode 100644
index f85a84f..0000000
--- a/framework/xsuite.py
+++ /dev/null
@@ -1,141 +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', 'TestKind']
-
-kinds = {}
-
-class TestSuite:
- """
- Description of a test suite.
-
- For now, this contains the following information:
- - Name
- - Description
- - List of registered TestKinds
- - Absolute path to the XML test list file
- - Dictionary of tests
- """
- def __init__(self, xmlFile):
- tree = ET.parse(xmlFile)
- xmlSuite = tree.getroot()
-
- self.name = xmlSuite.attrib['name']
- self.description = xmlSuite.attrib['description']
- self.testlist_file = path.abspath(path.join(path.dirname(xmlFile.name), xmlSuite.attrib['tests']))
- self.kinds = {}
- for xmlKind in xmlSuite[0]:
- self.kinds[xmlKind.attrib['tag']] = TestKind(xmlKind)
-
- # Register the kinds...
- kinds.update(self.kinds)
-
- self.tests = {}
-
-class TestKind:
- """
- Description of a class of tests (e.g. Piglit's ExecTest, GleanTest, ...).
-
- Robyn needs to know several facts about tests:
- - How to invoke them
- - How to interpret results
- - How to pass specific flags such as platform, quick mode, and so on.
-
- Test suites may register several different types of tests. In the
- JSON test list, the "type" tag indicates what kind of test it is.
- """
- def __init__(self, xmlKind):
- xmlResult = xmlKind.find('result')
-
- self.default_result = xmlResult.attrib['default']
- self.regexs = {}
- for rx in xmlResult:
- self.regexs[rx.attrib['status']] = re.compile(rx.text)
-
- # XXX: parse <platforms> and <quick>
-
- # Register this Kind so it's available
- # XXX: may want to move this into the caller...or caller's caller
- #assert name not in kinds
- #kinds[name] = self
-
- def interpretResult(self):
- #for status, re in self.regexs.items():
- #if re.search(out) is not None:
- #result = status
- #break
- result = self.default_result
-
-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-suite.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
diff --git a/programs/run.py b/programs/run.py
index 6bec187..9a39e58 100755
--- a/programs/run.py
+++ b/programs/run.py
@@ -71,7 +71,8 @@ def main(argv):
suites = framework.suites.loadSuiteInfo(options.suites, True)
- print(suites['piglit'].tests)
+ for test in sorted(suites['piglit'].tests.keys()):
+ print(test)
if __name__ == '__main__':
main(sys.argv[1:])