Exemplo n.º 1
0
def add_opencv_tests(profile, individual = False):
    if not PIGLIT_CONFIG.has_option('opencv', 'opencv_test_ocl_bindir'):
        return

    opencv_test_ocl = path.join(PIGLIT_CONFIG.get('opencv',
        'opencv_test_ocl_bindir'), 'opencv_test_ocl')
    if not path.isfile(opencv_test_ocl):
        print 'Warning: ', opencv_test_ocl, 'does not exist.\nSkipping OpenCV tests...'
        return
    tests = subprocess.check_output([opencv_test_ocl, '--gtest_list_tests'])
    test_list = tests.splitlines()
    group_name = ''
    full_test_name = ''
    for line in test_list:
        #Test groups names start at the beginning of the line and end with '.'
        m = re.match('([^.]+\.)$', line)
        if m:
            group_name = m.group(1)
            group_desc = group_name[:-1]
            full_test_name = 'opencv/{}'.format(group_desc)
            if not individual:
                profile.tests[full_test_name] = OpenCVTest(opencv_test_ocl,
                    '{}*'.format(group_name))
            continue

        if not individual:
            continue

        # Test names are indent by 2 spaces
        m = re.match('  (.+)', line)
        if m:
            test_name = m.group(1)
            profile.tests['{}/{}'.format(full_test_name,test_name)] = \
                OpenCVTest(opencv_test_ocl, '{}{}'.format(group_name ,test_name))
Exemplo n.º 2
0
def add_opencv_tests(profile, individual = False):
    if not PIGLIT_CONFIG.has_option('opencv', 'opencv_test_ocl_bindir'):
        return

    opencv_test_ocl = path.join(PIGLIT_CONFIG.get('opencv',
        'opencv_test_ocl_bindir'), 'opencv_test_ocl')
    if not path.isfile(opencv_test_ocl):
        print('Warning: {} does not exist.\nSkipping OpenCV '
              'tests...'.format(opencv_test_ocl))
        return
    tests = subprocess.check_output([opencv_test_ocl, '--gtest_list_tests'])
    test_list = tests.splitlines()
    group_name = ''
    full_test_name = ''
    for line in test_list:
        #Test groups names start at the beginning of the line and end with '.'
        m = re.match('([^.]+\.)$', line)
        if m:
            group_name = m.group(1)
            group_desc = group_name[:-1]
            full_test_name = 'opencv/{}'.format(group_desc)
            if not individual:
                profile.tests[full_test_name] = OpenCVTest(opencv_test_ocl,
                    '{}*'.format(group_name))
            continue

        if not individual:
            continue

        # Test names are indent by 2 spaces
        m = re.match('  ([^ ]+)', line)
        if m:
            test_name = m.group(1)
            profile.tests['{}/{}'.format(full_test_name,test_name)] = \
                OpenCVTest(opencv_test_ocl, '{}{}'.format(group_name ,test_name))
Exemplo n.º 3
0
    def __init__(self, dest, junit_suffix='', **options):
        super(JUnitBackend, self).__init__(dest, **options)
        self._test_suffix = junit_suffix

        # make dictionaries of all test names expected to crash/fail
        # for quick lookup when writing results.  Use lower-case to
        # provide case insensitive matches.
        self._expected_failures = {}
        if PIGLIT_CONFIG.has_section("expected-failures"):
            for (fail, _) in PIGLIT_CONFIG.items("expected-failures"):
                self._expected_failures[fail.lower()] = True
        self._expected_crashes = {}
        if PIGLIT_CONFIG.has_section("expected-crashes"):
            for (fail, _) in PIGLIT_CONFIG.items("expected-crashes"):
                self._expected_crashes[fail.lower()] = True
Exemplo n.º 4
0
def _deprecated_get(env_, conf_, dep_env=None, dep_conf=('', ''), **kwargs):
    """Attempt to get deprecated values, then modern vaules.

    If a deprecated value is found give the user a warning, this uses
    deqp_get_option internally for both the deprecated and undeprecated paths,
    but prefers the old version and issues a warning if they are encountered.
    The old version is looked up unconditionally, if it is not found then the
    new version will be looked up unconditionally, with the default and
    requires keywords (which the first will not have).
    """
    val = None
    if dep_env is not None and dep_conf is not None:
        val = deqp.get_option(dep_env, dep_conf)

        if dep_env is not None and os.environ.get(dep_env) is not None:
            # see if the old environment variable was set, if it is uses it,
            # and give a deprecation warning
            warnings.warn(
                '{} has been replaced by {} and will be removed. You should '
                'update any scripts using the old environment variable'.format(
                    dep_env, env_))
        elif dep_conf != ('', '') and PIGLIT_CONFIG.has_option(*dep_conf):
            warnings.warn(
                '{} has been replaced by {} and will be removed. You should '
                'update any scripts using the old conf variable'.format(
                    ':'.join(dep_conf), ':'.join(conf_)))

    return val if val is not None else deqp.get_option(env_, conf_, **kwargs)
Exemplo n.º 5
0
def _deprecated_get(env_, conf_, dep_env=None, dep_conf=('', ''), **kwargs):
    """Attempt to get deprecated values, then modern vaules.

    If a deprecated value is found give the user a warning, this uses
    deqp_get_option internally for both the deprecated and undeprecated paths,
    but prefers the old version and issues a warning if they are encountered.
    The old version is looked up unconditionally, if it is not found then the
    new version will be looked up unconditionally, with the default and
    requires keywords (which the first will not have).
    """
    val = None
    if dep_env is not None and dep_conf is not None:
        val = deqp.get_option(dep_env, dep_conf)

        if dep_env is not None and os.environ.get(dep_env) is not None:
            # see if the old environment variable was set, if it is uses it,
            # and give a deprecation warning
            warnings.warn(
                '{} has been replaced by {} and will be removed. You should '
                'update any scripts using the old environment variable'.format(
                    dep_env, env_))
        elif dep_conf != ('', '') and PIGLIT_CONFIG.has_option(*dep_conf):
            warnings.warn(
                '{} has been replaced by {} and will be removed. You should '
                'update any scripts using the old conf variable'.format(
                    ':'.join(dep_conf), ':'.join(conf_)))

    return val if val is not None else deqp.get_option(env_, conf_, **kwargs)
Exemplo n.º 6
0
    def __init__(self, dest, junit_suffix='', junit_subtests=False, **options):
        super(JUnitBackend, self).__init__(dest, **options)

        # make dictionaries of all test names expected to crash/fail
        # for quick lookup when writing results.  Use lower-case to
        # provide case insensitive matches.
        expected_failures = {}
        if PIGLIT_CONFIG.has_section("expected-failures"):
            for fail, _ in PIGLIT_CONFIG.items("expected-failures"):
                expected_failures[fail.lower()] = True
        expected_crashes = {}
        if PIGLIT_CONFIG.has_section("expected-crashes"):
            for fail, _ in PIGLIT_CONFIG.items("expected-crashes"):
                expected_crashes[fail.lower()] = True

        if not junit_subtests:
            self._write = JUnitWriter(junit_suffix, expected_failures,
                                      expected_crashes)
        else:
            self._write = JUnitSubtestWriter(  # pylint: disable=redefined-variable-type
                junit_suffix, expected_failures, expected_crashes)
Exemplo n.º 7
0
    def __init__(self, dest, metadata, **options):
        self._file = open(os.path.join(dest, 'results.xml'), 'w')
        FSyncMixin.__init__(self, **options)

        # make dictionaries of all test names expected to crash/fail
        # for quick lookup when writing results.  Use lower-case to
        # provide case insensitive matches.
        self._expected_failures = {}
        if PIGLIT_CONFIG.has_section("expected-failures"):
            for (fail, _) in PIGLIT_CONFIG.items("expected-failures"):
                self._expected_failures[fail.lower()] = True
        self._expected_crashes = {}
        if PIGLIT_CONFIG.has_section("expected-crashes"):
            for (fail, _) in PIGLIT_CONFIG.items("expected-crashes"):
                self._expected_crashes[fail.lower()] = True

        # Write initial headers and other data that etree cannot write for us
        self._file.write('<?xml version="1.0" encoding="UTF-8" ?>\n')
        self._file.write('<testsuites>\n')
        self._file.write(
            '<testsuite name="piglit" tests="{}">\n'.format(
                metadata['test_count']))
        self._test_suffix = metadata["test_suffix"]
Exemplo n.º 8
0
    def __init__(self, monitoring_enabled):
        """Create a LinuxMonitored instance"""
        # Get the monitoring rules from piglit.conf and store them into a dict.
        self._monitoring_rules = {}

        if monitoring_enabled and PIGLIT_CONFIG.has_section('monitored-errors'):
            for key, _ in PIGLIT_CONFIG.items('monitored-errors'):
                if PIGLIT_CONFIG.has_section(key):
                    type = PIGLIT_CONFIG.required_get(key, 'type')
                    regex = PIGLIT_CONFIG.required_get(key, 'regex')
                    parameters = PIGLIT_CONFIG.required_get(key, 'parameters')

                    self.add_rule(key, type, parameters, regex)
Exemplo n.º 9
0
    def __init__(self, monitoring_enabled):
        """Create a LinuxMonitored instance"""
        # Get the monitoring rules from piglit.conf and store them into a dict.
        self._monitoring_rules = {}

        if monitoring_enabled and PIGLIT_CONFIG.has_section('monitored-errors'):
            for key, _ in PIGLIT_CONFIG.items('monitored-errors'):
                if PIGLIT_CONFIG.has_section(key):
                    type = PIGLIT_CONFIG.required_get(key, 'type')
                    regex = PIGLIT_CONFIG.required_get(key, 'regex')
                    parameters = PIGLIT_CONFIG.required_get(key, 'parameters')

                    self.add_rule(key, type, parameters, regex)
Exemplo n.º 10
0
def get_mode():
    """Return the key value of the correct compressor to use.

    Try the environment variable PIGLIT_COMPRESSION; then check the
    PIGLIT_CONFIG section 'core', option 'compression'; finally fall back to
    DEFAULT.

    This will raise an UnsupportedCompressionError if there isn't a compressor
    for that mode. It is the job of the caller to handle this exceptions

    """
    # This is provided as a function rather than a constant because as a
    # function it can honor changes to the PIGLIT_CONFIG instance, or the
    # PIGLIT_COMPRESSION environment variable.

    method = (os.environ.get('PIGLIT_COMPRESSION')
              or PIGLIT_CONFIG.safe_get('core', 'compression') or DEFAULT)

    if method not in COMPRESSORS:
        raise UnsupportedCompressor(method)

    return method
Exemplo n.º 11
0
def get_mode():
    """Return the key value of the correct compressor to use.

    Try the environment variable PIGLIT_COMPRESSION; then check the
    PIGLIT_CONFIG section 'core', option 'compression'; finally fall back to
    DEFAULT.

    This will raise an UnsupportedCompressionError if there isn't a compressor
    for that mode. It is the job of the caller to handle this exceptions

    """
    # This is provided as a function rather than a constant because as a
    # function it can honor changes to the PIGLIT_CONFIG instance, or the
    # PIGLIT_COMPRESSION environment variable.

    method = (os.environ.get('PIGLIT_COMPRESSION') or
              PIGLIT_CONFIG.safe_get('core', 'compression') or
              DEFAULT)

    if method not in COMPRESSORS:
        raise UnsupportedCompressor(method)

    return method
Exemplo n.º 12
0
 def __init__(self, test_prog, testname):
     options = [test_prog, '--gtest_filter=' + testname, '--gtest_color=no']
     if PIGLIT_CONFIG.has_option('opencv', 'workdir'):
         options.append('-w {}'.format(PIGLIT_CONFIG.get('opencv', 'workdir')))
     GTest.__init__(self, options)
Exemplo n.º 13
0
def add_oclconform_tests(profile):
    section_name = 'oclconform'
    if not PIGLIT_CONFIG.has_section(section_name):
        return

    bindir = PIGLIT_CONFIG.get(section_name, 'bindir')
    options = PIGLIT_CONFIG.options(section_name)

    tests = (o for o in options if PIGLIT_CONFIG.get(section_name, o) is None)

    for test in tests:
        test_section_name = get_test_section_name(test)
        if not PIGLIT_CONFIG.has_section(test_section_name):
            print("Warning: no section defined for {}".format(test), file=stderr)
            continue

        test_name = PIGLIT_CONFIG.get(test_section_name, 'test_name')
        should_run_concurrent = PIGLIT_CONFIG.has_option(test_section_name, 'concurrent')
        if PIGLIT_CONFIG.has_option(test_section_name, 'list_subtests'):
            # Test with subtests
            list_tests = PIGLIT_CONFIG.get(test_section_name, 'list_subtests')
            subtest_regex = PIGLIT_CONFIG.get(test_section_name, 'subtest_regex')
            subtest_regex.encode('string_escape')
            run_subtests = PIGLIT_CONFIG.get(test_section_name, 'run_subtest')
            list_tests =list_tests.split()

            subtests = subprocess.check_output(args=list_tests, cwd=bindir).split('\n')
            for subtest in subtests:
                m = re.match(subtest_regex, subtest)
                if not m:
                    continue
                subtest = m.group(1)
                subtest_command = join(bindir, run_subtests.replace('<subtest>', subtest))
                add_sub_test(profile, test_name, subtest,
		             OCLConform(command=subtest_command,
			                run_concurrent=should_run_concurrent))
        else:
            run_test = PIGLIT_CONFIG.get(test_section_name, 'run_test')
            add_test(profile, test_name, OCLConform(command=run_test,
	                                            run_concurrent=should_run_concurrent))
Exemplo n.º 14
0
 def __init__(self, test_prog, testname):
     options = [test_prog, '--gtest_filter=' + testname, '--gtest_color=no']
     if PIGLIT_CONFIG.has_option('opencv', 'workdir'):
         options.append('-w {}'.format(
             PIGLIT_CONFIG.get('opencv', 'workdir')))
     GTest.__init__(self, options)
Exemplo n.º 15
0
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
import os
import six
import subprocess

from framework import grouptools, backends, exceptions
from framework.core import PIGLIT_CONFIG
from framework.profile import TestProfile, Test

__all__ = ['profile']

crucible_bin = os.environ.get('PIGLIT_CRUCIBLE_BIN', None)
if crucible_bin is None:
    crucible_bin = PIGLIT_CONFIG.safe_get(('crucible', 'bin'), True)

if crucible_bin is None:
    raise exceptions.PiglitFatalError(
        'Cannot get "PIGLIT_CRUCIBLE_BIN" or conf value "crucible:bin"')


class CrucibleTest(Test):
    """Test representation for Crucible"""
    def __init__(self, case_name):
        command = [crucible_bin, 'run', '--junit-xml=crucible.xml', case_name]
        self._case = case_name
        super(CrucibleTest, self).__init__(command)

    def interpret_result(self):
        test = backends.junit.REGISTRY.load('crucible.xml', 'none')
Exemplo n.º 16
0
def add_oclconform_tests(profile):
    section_name = 'oclconform'
    if not PIGLIT_CONFIG.has_section(section_name):
        return

    bindir = PIGLIT_CONFIG.get(section_name, 'bindir')
    options = PIGLIT_CONFIG.options(section_name)

    tests = (o for o in options if PIGLIT_CONFIG.get(section_name, o) is None)

    for test in tests:
        test_section_name = get_test_section_name(test)
        if not PIGLIT_CONFIG.has_section(test_section_name):
            print("Warning: no section defined for {}".format(test),
                  file=stderr)
            continue

        test_name = PIGLIT_CONFIG.get(test_section_name, 'test_name')
        should_run_concurrent = PIGLIT_CONFIG.has_option(
            test_section_name, 'concurrent')
        if PIGLIT_CONFIG.has_option(test_section_name, 'list_subtests'):
            list_tests = PIGLIT_CONFIG.get(test_section_name, 'list_subtests')
            subtest_regex = PIGLIT_CONFIG.get(test_section_name,
                                              'subtest_regex')
            subtest_regex.encode('unicode_escape')
            run_subtests = PIGLIT_CONFIG.get(test_section_name, 'run_subtest')
            list_tests = list_tests.split()

            subtests = subprocess.check_output(
                args=list_tests, cwd=bindir).decode('utf-8').split('\n')
            for subtest in subtests:
                m = re.match(subtest_regex, subtest)
                if not m:
                    continue
                subtest = m.group(1)
                subtest_command = join(
                    bindir, run_subtests.replace('<subtest>', subtest))
                add_sub_test(
                    profile, test_name, subtest,
                    OCLConform(command=subtest_command.split(),
                               run_concurrent=should_run_concurrent))
        else:
            run_test = PIGLIT_CONFIG.get(test_section_name, 'run_test')
            add_test(
                profile, test_name,
                OCLConform(command=run_test.split(),
                           run_concurrent=should_run_concurrent))
Exemplo n.º 17
0
 def __init__(self, state, state_lock):
     super(HTTPLogServer, self).__init__()
     port = int(PIGLIT_CONFIG.safe_get("http", "port", fallback=8080))
     self._httpd = HTTPServer(("", port), HTTPLogServer.RequestHandler)
     self._httpd.state = state
     self._httpd.state_lock = state_lock
Exemplo n.º 18
0
 def __init__(self, state, state_lock):
     super(HTTPLogServer, self).__init__()
     port = int(PIGLIT_CONFIG.safe_get("http", "port", fallback=8080))
     self._httpd = HTTPServer(("", port), HTTPLogServer.RequestHandler)
     self._httpd.state = state
     self._httpd.state_lock = state_lock
Exemplo n.º 19
0
def test_get_option_conf_no_section():
    """deqp.get_option: if a no_section error is raised and env is unset None is return
    """
    assert not PIGLIT_CONFIG.has_section('deqp_test')
    nt.eq_(deqp.get_option('_PIGLIT_TEST_ENV', ('deqp_test', 'test_env')), None)
Exemplo n.º 20
0
from __future__ import (
    absolute_import, division, print_function, unicode_literals
)
import os
import six
import subprocess

from framework import grouptools, backends, exceptions
from framework.core import PIGLIT_CONFIG
from framework.profile import TestProfile, Test

__all__ = ['profile']

crucible_bin = os.environ.get('PIGLIT_CRUCIBLE_BIN', None)
if crucible_bin is None:
    crucible_bin = PIGLIT_CONFIG.safe_get(('crucible', 'bin'), True)

if crucible_bin is None:
    raise exceptions.PiglitFatalError(
        'Cannot get "PIGLIT_CRUCIBLE_BIN" or conf value "crucible:bin"')


class CrucibleTest(Test):
    """Test representation for Crucible"""
    def __init__(self, case_name):
        command = [crucible_bin, 'run', '--junit-xml=crucible.xml', case_name]
        self._case = case_name
        super(CrucibleTest, self).__init__(command)

    def interpret_result(self):
        test = backends.junit.REGISTRY.load('crucible.xml', 'none')