diff options
author | Dylan Baker <dylanx.c.baker@intel.com> | 2014-09-10 12:07:43 -0700 |
---|---|---|
committer | Dylan Baker <dylanx.c.baker@intel.com> | 2014-10-14 14:50:39 -0700 |
commit | c57ae4387b801e0c428c7baa6827d653d29b1b6f (patch) | |
tree | 0d377cd34418dc8b330aa6460fa5bd1ae73d056b /framework | |
parent | 3d00e91606e06b1c74a3d479176f6ddc0de19db2 (diff) |
framework/test: refactor abstract Test and PiglitTest
This creates two separate modules for these classes.
Making this change allows us to separate the basic building blocks of
Test classes and the concrete implementations.
Signed-off-by: Dylan Baker <dylanx.c.baker@intel.com>
Diffstat (limited to 'framework')
-rw-r--r-- | framework/profile.py | 5 | ||||
-rw-r--r-- | framework/test/__init__.py | 7 | ||||
-rw-r--r-- | framework/test/base.py (renamed from framework/test/exectest.py) | 53 | ||||
-rw-r--r-- | framework/test/gleantest.py | 3 | ||||
-rw-r--r-- | framework/test/glsl_parser_test.py | 2 | ||||
-rw-r--r-- | framework/test/gtest.py | 2 | ||||
-rw-r--r-- | framework/test/oclconform.py | 2 | ||||
-rw-r--r-- | framework/test/piglit_test.py | 80 | ||||
-rw-r--r-- | framework/test/shader_test.py | 2 | ||||
-rw-r--r-- | framework/tests/exectest_test.py | 3 |
10 files changed, 99 insertions, 60 deletions
diff --git a/framework/profile.py b/framework/profile.py index 6a0f5a8ad..0d00e352a 100644 --- a/framework/profile.py +++ b/framework/profile.py @@ -35,7 +35,7 @@ import importlib from framework.dmesg import get_dmesg from framework.log import LogManager -import framework.test +from framework.test.base import Test __all__ = [ 'TestProfile', @@ -183,12 +183,11 @@ class TestProfile(object): Arguments: opts -- a core.Options instance backend -- a results.Backend derived instance - """ self._pre_run_hook() - framework.test.Test.OPTS = opts + Test.OPTS = opts chunksize = 1 diff --git a/framework/test/__init__.py b/framework/test/__init__.py index fe98c5ee3..9767cbe0a 100644 --- a/framework/test/__init__.py +++ b/framework/test/__init__.py @@ -20,8 +20,13 @@ """ Module that provides test classes and helpers """ +# By importing every exported function from each module in the package we +# create a general use API, but allow it to be controlled by setting the +# __all__ in each module + from __future__ import absolute_import -from .exectest import * +from .base import * +from .piglit_test import * from .gleantest import * from .glsl_parser_test import * from .shader_test import * diff --git a/framework/test/exectest.py b/framework/test/base.py index 0d90094b2..348568ec6 100644 --- a/framework/test/exectest.py +++ b/framework/test/base.py @@ -34,24 +34,14 @@ import threading import signal import itertools import abc -try: - import simplejson as json -except ImportError: - import json from framework.core import Options from framework.results import TestResult -__all__ = ['Test', - 'PiglitTest', - 'TEST_BIN_DIR'] - -if 'PIGLIT_BUILD_DIR' in os.environ: - TEST_BIN_DIR = os.path.join(os.environ['PIGLIT_BUILD_DIR'], 'bin') -else: - TEST_BIN_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), - '../bin')) +__all__ = [ + 'Test', +] class ProcessTimeout(threading.Thread): @@ -343,40 +333,3 @@ class Test(object): self.result['out'] = out.decode('utf-8', 'replace') self.result['err'] = err.decode('utf-8', 'replace') self.result['returncode'] = returncode - - -class PiglitTest(Test): - """ - PiglitTest: Run a "native" piglit test executable - - Expect one line prefixed PIGLIT: in the output, which contains a result - dictionary. The plain output is appended to this dictionary - """ - def __init__(self, *args, **kwargs): - super(PiglitTest, self).__init__(*args, **kwargs) - - # Prepend TEST_BIN_DIR to the path. - self._command[0] = os.path.join(TEST_BIN_DIR, self._command[0]) - - def is_skip(self): - """ Native Piglit-test specific skip checking - - If the platform for the run doesn't suppoprt glx (either directly as - glx or through the hybrid glx/x11_egl setup that is default), then skip - any glx specific tests. - - """ - if self.OPTS.env['PIGLIT_PLATFORM'] not in ['glx', 'mixed_glx_egl']: - split_command = os.path.split(self._command[0])[1] - if split_command.startswith('glx-'): - return True - return False - - def interpret_result(self): - outlines = self.result['out'].split('\n') - outpiglit = (s[7:] for s in outlines if s.startswith('PIGLIT:')) - - for piglit in outpiglit: - self.result.recursive_update(json.loads(piglit)) - self.result['out'] = '\n'.join( - s for s in outlines if not s.startswith('PIGLIT:')) diff --git a/framework/test/gleantest.py b/framework/test/gleantest.py index 7795d1f2d..6ec285d45 100644 --- a/framework/test/gleantest.py +++ b/framework/test/gleantest.py @@ -23,7 +23,8 @@ """ Glean support """ import os -from .exectest import Test, TEST_BIN_DIR +from .base import Test +from .piglit_test import TEST_BIN_DIR __all__ = [ 'GleanTest', diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py index b808a6168..77c3ac182 100644 --- a/framework/test/glsl_parser_test.py +++ b/framework/test/glsl_parser_test.py @@ -27,7 +27,7 @@ import os.path as path import re import sys -from .exectest import PiglitTest +from .piglit_test import PiglitTest __all__ = [ 'GLSLParserTest', diff --git a/framework/test/gtest.py b/framework/test/gtest.py index ba7926fc5..81dab38f8 100644 --- a/framework/test/gtest.py +++ b/framework/test/gtest.py @@ -23,7 +23,7 @@ # import re -from .exectest import Test +from .base import Test __all__ = [ 'GTest', diff --git a/framework/test/oclconform.py b/framework/test/oclconform.py index 014df6c7d..9d8bcafbb 100644 --- a/framework/test/oclconform.py +++ b/framework/test/oclconform.py @@ -30,7 +30,7 @@ from os.path import join from sys import stderr from framework.core import PIGLIT_CONFIG -from .exectest import Test +from .base import Test __all__ = [ 'OCLConform', diff --git a/framework/test/piglit_test.py b/framework/test/piglit_test.py new file mode 100644 index 000000000..0f1f40e1e --- /dev/null +++ b/framework/test/piglit_test.py @@ -0,0 +1,80 @@ +# +# 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: +# +# This permission notice 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 AUTHOR(S) 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. + +""" Module provides a base class for Tests """ + +import os +try: + import simplejson as json +except ImportError: + import json + +from .base import Test + + +__all__ = [ + 'PiglitTest', + 'TEST_BIN_DIR' +] + +if 'PIGLIT_BUILD_DIR' in os.environ: + TEST_BIN_DIR = os.path.join(os.environ['PIGLIT_BUILD_DIR'], 'bin') +else: + TEST_BIN_DIR = os.path.normpath(os.path.join(os.path.dirname(__file__), + '../../bin')) + + +class PiglitTest(Test): + """ + PiglitTest: Run a "native" piglit test executable + + Expect one line prefixed PIGLIT: in the output, which contains a result + dictionary. The plain output is appended to this dictionary + """ + def __init__(self, *args, **kwargs): + super(PiglitTest, self).__init__(*args, **kwargs) + + # Prepend TEST_BIN_DIR to the path. + self._command[0] = os.path.join(TEST_BIN_DIR, self._command[0]) + + def is_skip(self): + """ Native Piglit-test specific skip checking + + If the platform for the run doesn't suppoprt glx (either directly as + glx or through the hybrid glx/x11_egl setup that is default), then skip + any glx specific tests. + + """ + if self.OPTS.env['PIGLIT_PLATFORM'] not in ['glx', 'mixed_glx_egl']: + split_command = os.path.split(self._command[0])[1] + if split_command.startswith('glx-'): + return True + return False + + def interpret_result(self): + outlines = self.result['out'].split('\n') + outpiglit = (s[7:] for s in outlines if s.startswith('PIGLIT:')) + + for piglit in outpiglit: + self.result.recursive_update(json.loads(piglit)) + self.result['out'] = '\n'.join( + s for s in outlines if not s.startswith('PIGLIT:')) diff --git a/framework/test/shader_test.py b/framework/test/shader_test.py index a3779d0b1..1ec493050 100644 --- a/framework/test/shader_test.py +++ b/framework/test/shader_test.py @@ -27,7 +27,7 @@ import os import os.path as path import re -from .exectest import PiglitTest +from .piglit_test import PiglitTest __all__ = [ 'ShaderTest', diff --git a/framework/tests/exectest_test.py b/framework/tests/exectest_test.py index 24d4a6d46..cc4c23b23 100644 --- a/framework/tests/exectest_test.py +++ b/framework/tests/exectest_test.py @@ -25,7 +25,8 @@ import nose.tools as nt import framework.tests.utils as utils from framework.log import LogManager from framework.dmesg import DummyDmesg -from framework.test import PiglitTest, Test +from framework.test import PiglitTest +from framework.test.base import Test # Helpers |