summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2012-11-25 03:50:13 -0800
committerKenneth Graunke <kenneth@whitecape.org>2012-11-25 03:50:13 -0800
commit595610b9f4b7b6914fd235322d2bc00d761d25c7 (patch)
treec10c14d5ea6a447451dcc38f87888d9429ff88b0 /framework
parent53a5b78d4ed126f1f45f021b55cd3abf3a28ac24 (diff)
new plugin architecture! now loading oglconform test list.
Diffstat (limited to 'framework')
-rw-r--r--framework/config.py40
-rw-r--r--framework/suites.py134
-rw-r--r--framework/test.py54
3 files changed, 94 insertions, 134 deletions
diff --git a/framework/config.py b/framework/config.py
new file mode 100644
index 0000000..c56e308
--- /dev/null
+++ b/framework/config.py
@@ -0,0 +1,40 @@
+#
+# 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 sys
+import os.path as path
+from configparser import ConfigParser
+import xdg.BaseDirectory as xdg
+
+__all__ = ['load']
+
+def load():
+ config = ConfigParser()
+
+ rcdir = xdg.load_first_config('robyn')
+ if rcdir:
+ rcfile = path.join(xdg.load_first_config('robyn'), 'robynrc')
+ config.read(rcfile)
+ else:
+ print('warning: could not read ~/.config/robyn/robynrc.')
+
+ return config
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
diff --git a/framework/test.py b/framework/test.py
new file mode 100644
index 0000000..cdcb905
--- /dev/null
+++ b/framework/test.py
@@ -0,0 +1,54 @@
+#
+# 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.
+#
+
+from framework.process import runProgram
+
+__all__ = ['runProgram']
+
+#class TestResult:
+ #def __init__(self, status, valgrind_status, exitcode, out, err):
+ # visuals??????
+
+
+class Test:
+ def __init__(self, command):
+ self.command = command
+
+ def run(self):
+ out, err, exitcode, finished = runProgram(self.command, timeout)
+
+ return {'out': out, 'err': err, 'exitcode': exitcode,
+ 'status': self.resultStatus(out, err, exitcode, finished)}
+
+ def resultStatus(self, out, err, exitcode, finished):
+ if not finished:
+ return 'timeout'
+ elif exitcode in (-5, -6, -8, -10, -11, -1073741819, -1073741676):
+ # Unix: -5/SIGTRAP, -6/SIGABRT, -8/SIGFPE, -10/SIGUSR1, -11/SIGSEGV
+ # Windows: 0xc0000005 EXCEPTION_ACCESS_VIOLATION,
+ # 0xc0000094 EXCEPTION_INT_DIVIDE_BY_ZERO
+ return 'crash'
+
+ return self.suite.interpretResult(out)
+
+