diff options
author | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 03:50:13 -0800 |
---|---|---|
committer | Kenneth Graunke <kenneth@whitecape.org> | 2012-11-25 03:50:13 -0800 |
commit | 595610b9f4b7b6914fd235322d2bc00d761d25c7 (patch) | |
tree | c10c14d5ea6a447451dcc38f87888d9429ff88b0 /suites | |
parent | 53a5b78d4ed126f1f45f021b55cd3abf3a28ac24 (diff) |
new plugin architecture! now loading oglconform test list.
Diffstat (limited to 'suites')
-rw-r--r-- | suites/__init__.py | 39 | ||||
-rw-r--r-- | suites/oglconform.py | 70 |
2 files changed, 109 insertions, 0 deletions
diff --git a/suites/__init__.py b/suites/__init__.py new file mode 100644 index 0000000..f7d5dd3 --- /dev/null +++ b/suites/__init__.py @@ -0,0 +1,39 @@ +import os +import os.path as path +import importlib +from glob import iglob + +__all__ = ['loadTestLists'] + +def loadPlugins(config): + ''' + Find and import all submodules in the current package's directory. + + Rather than making everyone enumerate all the types of tests, they can + simply drop .py files in here. As long as they have a generateTestList() + function, they'll be loaded and work. + ''' + plugins = {} + suitesDir = path.dirname(path.realpath(__file__)) + for pyfile in iglob(path.join(suitesDir, '[!_]*.py')): + p = path.basename(pyfile)[:-3] + plugin = importlib.import_module('suites.' + p) + if plugin.init(config): + plugins[p] = plugin + + return plugins + + +def loadTestLists(config, desiredSuites): + '''Generate the necessary test lists! + + desiredSuites may be None (to load all test suites). + ''' + suites = loadPlugins(config) + tests = {} + for suite, plugin in suites.items(): + if not desiredSuites or suite in desiredSuites: + tests[suite] = plugin.makeTestList() + + return tests + diff --git a/suites/oglconform.py b/suites/oglconform.py new file mode 100644 index 0000000..86d0bc2 --- /dev/null +++ b/suites/oglconform.py @@ -0,0 +1,70 @@ +# +# 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 re +from subprocess import call, DEVNULL +from framework.test import Test + +__all__ = ['init', 'makeTestList'] + +### +## Plugin initialization +### +oglc = None +def init(config): + global oglc + try: + # Get the oglconform binary path from the configuration file + block = config['oglconform'] + oglc = block['binary'] + return True + except KeyError: + return False + +skip_re = re.compile(r'Total Not run: 1|no test in schedule is compat|GLSL [134].[0-5]0 is not supported|wont be scheduled due to lack of compatible fbconfig') +pass_re = re.compile(r'Total Passed : 1') + +class OGLCTest(Test): + def __init__(self, oglc, category, subtest): + Test.__init__(self, [oglc, '-minFmt', '-v', '4', '-test', category, subtest]) + + def interpretResult(self, out, err, exitcode): + if skip_re.search(out) is not None: + return 'skip' + elif pass_re.search(out) is not None: + return 'pass' + + return 'fail' + +def makeTestList(): + tempfile = '/tmp/oglc.tests' + call([oglc, '-generateTestList', tempfile], stdout=DEVNULL, stderr=DEVNULL) + with open(tempfile) as f: + testlist = f.read().splitlines() + + d = {} + for l in testlist: + category, test = l.split() + d['oglconform/' + category + '/' + test] = OGLCTest(oglc, category, test) + + return d |