Commit 3d00e916 authored by Dylan Baker's avatar Dylan Baker

framework: Move tests derived classes into a package

This moves all of the classes that derive from Test into a package
called test. This patch looks very large, but is mostly just moving
files around and changing imports to account for this.

So why all of this code churn? The big advantage is that through
__init__.py magic there is one module to be imported, framework.test.
This module contains all of the public classes, functions, and
constants, in one place while hiding the rest, but allowing them to be
accessed explicitly.
Signed-off-by: default avatarDylan Baker <dylanx.c.baker@intel.com>
parent 85e382fe
......@@ -35,7 +35,7 @@ import importlib
from framework.dmesg import get_dmesg
from framework.log import LogManager
import framework.exectest
import framework.test
__all__ = [
'TestProfile',
......@@ -188,7 +188,7 @@ class TestProfile(object):
"""
self._pre_run_hook()
framework.exectest.Test.OPTS = opts
framework.test.Test.OPTS = opts
chunksize = 1
......
# Copyright (c) 2014 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 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.
""" Module that provides test classes and helpers """
from __future__ import absolute_import
from .exectest import *
from .gleantest import *
from .glsl_parser_test import *
from .shader_test import *
from .gtest import *
from .opencv import *
from .oclconform import *
......@@ -23,9 +23,12 @@
""" Glean support """
import os
from .exectest import Test, TEST_BIN_DIR
__all__ = [
'GleanTest',
]
# GleanTest: Execute a sub-test of Glean
class GleanTest(Test):
......
......@@ -29,6 +29,12 @@ import sys
from .exectest import PiglitTest
__all__ = [
'GLSLParserTest',
'add_glsl_parser_test',
'import_glsl_parser_tests',
]
def add_glsl_parser_test(group, filepath, test_name):
"""Add an instance of GLSLParserTest to the given group."""
......
......@@ -23,8 +23,12 @@
#
import re
from .exectest import Test
__all__ = [
'GTest',
]
from framework.exectest import Test
class GTest(Test):
def interpret_result(self):
......
......@@ -30,7 +30,13 @@ from os.path import join
from sys import stderr
from framework.core import PIGLIT_CONFIG
from framework.exectest import Test
from .exectest import Test
__all__ = [
'OCLConform',
'add_oclconform_tests',
]
def get_test_section_name(test):
return 'oclconform-{}'.format(test)
......
......@@ -26,9 +26,14 @@ from __future__ import print_function
import re
import subprocess
from os import path
from framework.gtest import GTest
from .gtest import GTest
from framework.core import PIGLIT_CONFIG
__all__ = [
'OpenCVTest',
'add_opencv_tests',
]
class OpenCVTest(GTest):
def __init__(self, test_prog, testname):
......
......@@ -29,7 +29,12 @@ import re
from .exectest import PiglitTest
__all__ = ['add_shader_test', 'add_shader_test_dir']
__all__ = [
'ShaderTest',
'ShaderTestParserException',
'add_shader_test',
'add_shader_test_dir'
]
class ShaderTest(PiglitTest):
......
......@@ -34,10 +34,7 @@ import nose.tools as nt
from nose.plugins.skip import SkipTest
import framework.dmesg as dmesg
import framework.core
import framework.exectest
import framework.gleantest
import framework.shader_test
import framework.glsl_parser_test
import framework.test
import framework.backends
import framework.tests.utils as utils
......@@ -333,12 +330,12 @@ def test_json_serialize_updated_result():
@utils.nose_generator
def test_testclasses_dmesg():
""" Generator that creates tests for """
lists = [(framework.exectest.PiglitTest,
lists = [(framework.test.PiglitTest,
['attribs', '-auto', '-fbo'], 'PiglitTest'),
(framework.gleantest.GleanTest, 'basic', "GleanTest"),
(framework.shader_test.ShaderTest,
(framework.test.GleanTest, 'basic', "GleanTest"),
(framework.test.ShaderTest,
'tests/shaders/loopfunc.shader_test', 'ShaderTest'),
(framework.glsl_parser_test.GLSLParserTest,
(framework.test.GLSLParserTest,
'tests/glslparsertest/shaders/main1.vert', 'GLSLParserTest')]
for tclass, tfile, desc in lists:
......
......@@ -22,10 +22,10 @@
import nose.tools as nt
from framework.exectest import PiglitTest, Test
import framework.tests.utils as utils
from framework.log import LogManager
from framework.dmesg import DummyDmesg
import framework.tests.utils as utils
from framework.test import PiglitTest, Test
# Helpers
......
......@@ -21,9 +21,7 @@
""" Tests for the glean class. Requires Nose """
from __future__ import print_function
import os
from nose.plugins.skip import SkipTest
from framework.gleantest import GleanTest
from framework.test import GleanTest
def test_initialize_gleantest():
......
......@@ -23,9 +23,9 @@
import sys
import os
import nose.tools as nt
import framework.glsl_parser_test as glsl
import framework.test as glsl
import framework.tests.utils as utils
from framework.exectest import TEST_BIN_DIR
from framework.test import TEST_BIN_DIR
# Nose does not capture stderr, so all of the error catching tetss will spam
# the console, however, it does capture stdout, so redirecting stderr to stdout
......
......@@ -21,7 +21,7 @@
""" Module providing tests for gtest """
from framework.gtest import GTest
from framework.test import GTest
def test_initialize_gtest():
......
......@@ -20,7 +20,7 @@
""" Module for testing opencv """
from framework.opencv import OpenCVTest
from framework.test import OpenCVTest
def test_initialize_opencvtest():
......
......@@ -22,13 +22,13 @@
import os
import nose.tools as nt
import framework.shader_test as shader_test
import framework.test as testm
import framework.tests.utils as utils
def test_initialize_shader_test():
""" Test that ShaderTest initializes """
shader_test.ShaderTest('tests/spec/glsl-es-1.00/execution/sanity.shader_test')
testm.ShaderTest('tests/spec/glsl-es-1.00/execution/sanity.shader_test')
def test_parse_gl_test_no_decimal():
......@@ -36,8 +36,8 @@ def test_parse_gl_test_no_decimal():
data = ('[require]\n'
'GL = 2\n')
with utils.with_tempfile(data) as temp:
with nt.assert_raises(shader_test.ShaderTestParserException) as exc:
shader_test.ShaderTest(temp)
with nt.assert_raises(testm.ShaderTestParserException) as exc:
testm.ShaderTest(temp)
nt.assert_equal(exc.exception, "No GL version set",
msg="A GL version was passed without a decimal, "
"which should have raised an exception, but "
......@@ -50,7 +50,7 @@ def test_parse_gles2_test():
'GL ES >= 2.0\n'
'GLSL ES >= 1.00\n')
with utils.with_tempfile(data) as temp:
test = shader_test.ShaderTest(temp)
test = testm.ShaderTest(temp)
nt.assert_equal(
os.path.basename(test.command[0]), "shader_runner_gles2",
......@@ -64,7 +64,7 @@ def test_parse_gles3_test():
'GL ES >= 3.0\n'
'GLSL ES >= 3.00\n')
with utils.with_tempfile(data) as temp:
test = shader_test.ShaderTest(temp)
test = testm.ShaderTest(temp)
nt.assert_equal(
os.path.basename(test.command[0]), "shader_runner_gles3",
......@@ -74,10 +74,10 @@ def test_parse_gles3_test():
def test_add_shader_test():
""" Test that add_shader_test works """
shader_test.add_shader_test(
testm.add_shader_test(
{}, 'test', 'tests/spec/glsl-es-3.00/execution/sanity.shader_test')
def test_add_shader_test_dir():
""" Test that add_shader_test_dir works """
shader_test.add_shader_test_dir({}, 'tests/spec/glsl-es-3.00/execution')
testm.add_shader_test_dir({}, 'tests/spec/glsl-es-3.00/execution')
......@@ -64,7 +64,7 @@ def setup_module_search_path():
def is_piglit_data_dir(dirpath):
tested_piglit_data_dirs.append(dirpath)
return path.exists(path.join(dirpath, 'framework', 'exectest.py'))
return path.exists(path.join(dirpath, 'framework'))
# This script may be in two valid locations:
#
......
......@@ -10,10 +10,9 @@ import subprocess
import sys
from framework.profile import TestProfile
from framework.exectest import PiglitTest
from framework.gleantest import GleanTest
from framework.glsl_parser_test import GLSLParserTest, add_glsl_parser_test, import_glsl_parser_tests
from framework.shader_test import add_shader_test_dir
from framework.test import (PiglitTest, GleanTest,
add_glsl_parser_test, import_glsl_parser_tests,
add_shader_test_dir)
# Path to tests dir, correct even when not running from the top directory.
testsDir = os.path.dirname(__file__)
......
......@@ -10,10 +10,8 @@ import os.path as path
import platform
import glob
from framework.opencv import add_opencv_tests
from framework.profile import TestProfile
from framework.exectest import PiglitTest
from framework.test import PiglitTest
######
# Helper functions
......
......@@ -27,7 +27,7 @@ import sys
from os import path
from glob import glob
from framework.profile import TestProfile
from framework.exectest import Test, TEST_BIN_DIR
from framework.test import Test, TEST_BIN_DIR
__all__ = ['profile']
......
......@@ -3,7 +3,7 @@
# quick.tests minus compiler tests.
from tests.quick import profile
from framework.glsl_parser_test import GLSLParserTest
from framework.test import GLSLParserTest
__all__ = ['profile']
......
......@@ -35,7 +35,7 @@ from datetime import datetime
from os import path
import framework.core
from framework.profile import TestProfile
from framework.exectest import Test
from framework.test import Test
__all__ = ['profile']
......
......@@ -28,7 +28,7 @@ import subprocess
import framework.core
from framework.profile import TestProfile
from framework.exectest import Test
from framework.test import Test
from os import path
__all__ = ['profile']
......
# -*- coding: utf-8 -*-
from framework.gleantest import GleanTest
from framework.test import GleanTest
from tests.all import profile
__all__ = ['profile']
......
......@@ -25,8 +25,7 @@
#
from tests.cl import profile
from framework.oclconform import add_oclconform_tests
from framework.opencv import add_opencv_tests
from framework.test import add_opencv_tests, add_oclconform_tests
add_opencv_tests(profile)
add_oclconform_tests(profile)
......@@ -3,7 +3,7 @@
#
from framework.profile import TestProfile
from framework.gleantest import GleanTest
from framework.test import GleanTest
__all__ = ['profile']
......
......@@ -30,7 +30,7 @@ import subprocess
import itertools
import framework.core
from framework.profile import TestProfile
from framework.exectest import Test
from framework.test import Test
__all__ = ['profile']
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment