예제 #1
0
 def dump(self):
     from PIL import Image
     outputprefix = path.join(self._output_dir,
                              path.basename(self._trace_path))
     gfxrecon_replay_bin = core.get_option(
         'PIGLIT_REPLAY_GFXRECON_REPLAY_BINARY',
         ('replay', 'gfxrecon-replay_bin'),
         default='gfxrecon-replay')
     self._check_version(gfxrecon_replay_bin)
     if not self._calls:
         self._calls = [str(self._get_last_frame_call())]
     gfxrecon_replay_extra_args = core.get_option(
         'PIGLIT_REPLAY_GFXRECON_REPLAY_EXTRA_ARGS',
         ('replay', 'gfxrecon-replay_extra_args'),
         default='').split()
     cmd = ([gfxrecon_replay_bin] + gfxrecon_replay_extra_args +
            ['--screenshots', ','.join(self._calls),
             '--screenshot-dir', self._output_dir,
             self._trace_path])
     self._run_logged_command(cmd, None)
     for c in self._calls:
         bmp = '{}_frame_{}.bmp'.format(path.join(self._output_dir,
                                                 'screenshot'),
                                       c)
         outputfile = '{}-{}.png'.format(outputprefix, c)
         print('Writing: {} to {}'.format(bmp, outputfile))
         Image.open(bmp).save(outputfile)
         os.remove(bmp)
예제 #2
0
파일: deqp_gles3.py 프로젝트: mesa3d/piglit
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 = core.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 core.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 core.get_option(env_, conf_, **kwargs)
예제 #3
0
 def dump(self):
     from PIL import Image
     outputprefix = path.join(self._output_dir,
                              path.basename(self._trace_path))
     if not self._calls:
         # FIXME: The VK_LAYER_LUNARG_screenshot numbers the calls from 0 to
         # (total-num-calls - 1) while gfxreconstruct does it from 1 to
         # total-num-calls:
         # https://github.com/LunarG/gfxreconstruct/issues/284
         self._calls = [str(max(-1, self._get_last_frame_call() - 1))]
     gfxrecon_replay_bin = core.get_option(
         'PIGLIT_REPLAY_GFXRECON_REPLAY_BINARY',
         ('replay', 'gfxrecon-replay_bin'),
         default='gfxrecon-replay')
     gfxrecon_replay_extra_args = core.get_option(
         'PIGLIT_REPLAY_GFXRECON_REPLAY_EXTRA_ARGS',
         ('replay', 'gfxrecon-replay_extra_args'),
         default='').split()
     cmd = ([gfxrecon_replay_bin] + gfxrecon_replay_extra_args +
            [self._trace_path])
     env = os.environ.copy()
     env['VK_INSTANCE_LAYERS'] = 'VK_LAYER_LUNARG_screenshot'
     env['VK_SCREENSHOT_FRAMES'] = ','.join(self._calls)
     env['VK_SCREENSHOT_DIR'] = self._output_dir
     self._run_logged_command(cmd, env)
     for c in self._calls:
         ppm = '{}.ppm'.format(path.join(self._output_dir, c))
         outputfile = '{}-{}.png'.format(outputprefix, c)
         print('Writing: {} to {}'.format(ppm, outputfile))
         Image.open(ppm).save(outputfile)
         os.remove(ppm)
예제 #4
0
    def test_get_option_required(self, mocker):
        """core.get_option: dies if a required option cannot be retrieved."""
        mocker.patch('framework.core.os.environ', {}, True)

        with pytest.raises(exceptions.PiglitFatalError):
            core.get_option('NOT_REAL', ('fake', 'fake'),
                            default='',
                            required=True)
예제 #5
0
    def test_from_default(self):
        """core.get_option: if env is set it overrides piglit.conf."""
        # The mock means that only the first value matters
        actual = core.get_option('foo', ('foo', 'foo'),
                                 default=mock.sentinel.good)

        assert actual is mock.sentinel.good
예제 #6
0
    def test_from_env(self, env, conf):
        """core.get_option: if env is set it overrides piglit.conf."""
        conf.return_value = mock.sentinel.bad
        env['TEST'] = mock.sentinel.good

        # The mock means that only the first value matters
        actual = core.get_option('TEST', ('foo', 'foo'))

        assert actual is mock.sentinel.good
예제 #7
0
    def test_from_conf(self, conf):
        """core.get_option: if env is not set a value is taken from
        piglit.conf.
        """
        conf.return_value = mock.sentinel

        # The mock means that these values don't actually matter
        actual = core.get_option('foo', ('foo', 'foo'))

        assert actual is mock.sentinel
예제 #8
0
파일: apitrace.py 프로젝트: mesa3d/piglit
 def _get_last_frame_call(self):
     cmd_wrapper = self._retrace_cmd[:-1]
     if cmd_wrapper:
         apitrace_bin = core.get_option(
             'PIGLIT_REPLAY_WINE_APITRACE_BINARY',
             ('replay', 'wine_apitrace_bin'),
             default='apitrace')
     else:
         apitrace_bin = core.get_option('PIGLIT_REPLAY_APITRACE_BINARY',
                                        ('replay', 'apitrace_bin'),
                                        default='apitrace')
     cmd = cmd_wrapper + [
         apitrace_bin, 'dump', '--calls=frame', self._trace_path
     ]
     ret = subprocess.run(cmd, stdout=subprocess.PIPE)
     logoutput = '[dump_trace_images] Running: {}\n'.format(
         ' '.join(cmd)) + ret.stdout.decode(errors='replace')
     print(logoutput)
     for l in reversed(ret.stdout.decode(errors='replace').splitlines()):
         s = l.split(None, 1)
         if s and s[0].isnumeric():
             return int(s[0])
     return -1
예제 #9
0
 def _get_last_frame_call(self):
     gfxrecon_info_bin = core.get_option(
         'PIGLIT_REPLAY_GFXRECON_INFO_BINARY',
         ('replay', 'gfxrecon-info_bin'),
         default='gfxrecon-info')
     cmd = [gfxrecon_info_bin, self._trace_path]
     ret = subprocess.run(cmd, stdout=subprocess.PIPE)
     lines = ret.stdout.decode(errors='replace').splitlines()
     print(ret.stdout.decode(errors='replace'))
     try:
         frames = re.search(_TOTAL_FRAMES_RE, lines[2])
         return int(frames.group(1))
     except:
         return -1
예제 #10
0
 def _get_last_frame_call(self):
     gfxrecon_info_bin = core.get_option(
         'PIGLIT_REPLAY_GFXRECON_INFO_BINARY',
         ('replay', 'gfxrecon-info_bin'),
         default='gfxrecon-info')
     cmd = [gfxrecon_info_bin, self._trace_path]
     ret = subprocess.run(cmd, stdout=subprocess.PIPE)
     lines = ret.stdout.decode(errors='replace').splitlines()
     print(ret.stdout.decode(errors='replace'))
     if lines:
         c = lines[0].split(': ', 1)
         if len(c) > 1 and c[1].isnumeric():
             return int(c[1])
     return -1
예제 #11
0
파일: apitrace.py 프로젝트: mesa3d/piglit
    def __init__(self, trace_path, output_dir=None, calls=None, **kwargs):
        super(APITraceBackend, self).__init__(trace_path, output_dir, calls,
                                              **kwargs)
        extension = path.splitext(self._trace_path)[1]

        if extension == '.trace':
            eglretrace_bin = core.get_option('PIGLIT_REPLAY_EGLRETRACE_BINARY',
                                             ('replay', 'eglretrace_bin'),
                                             default='eglretrace')
            self._retrace_cmd = [eglretrace_bin]
        elif extension == '.trace-dxgi':
            wine_bin = core.get_option('PIGLIT_REPLAY_WINE_BINARY',
                                       ('replay', 'wine_bin'),
                                       default='wine')
            wine_d3dretrace_bin = core.get_option(
                'PIGLIT_REPLAY_WINE_D3DRETRACE_BINARY',
                ('replay', 'wine_d3dretrace_bin'),
                default='d3dretrace')
            self._retrace_cmd = [wine_bin, wine_d3dretrace_bin]
        else:
            raise exceptions.PiglitFatalError(
                'Invalid trace_path: "{}" tried to be dumped '
                'by the APITraceBackend.\n'.format(self._trace_path))
예제 #12
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 = core.get_option('PIGLIT_COMPRESSION', ('core', 'compression'),
                             default=DEFAULT)

    if method not in COMPRESSORS:
        raise UnsupportedCompressor(method)

    return method
예제 #13
0
파일: cts_gl45.py 프로젝트: mesa3d/piglit
Alternatively (or in addition, since environment variables have precedence),
one could set:
PIGLIT_CTS_GL_BIN -- environment equivalent of [cts_gl]:bin
PIGLIT_CTS_GL_EXTRA_ARGS -- environment equivalent of [cts_gl]:extra_args

"""

import itertools

from framework import core
from framework.test import deqp

__all__ = ['profile']

_CTS_BIN = core.get_option('PIGLIT_CTS_GL_BIN', ('cts_gl', 'bin'),
                           required=True)

_EXTRA_ARGS = core.get_option('PIGLIT_CTS_GL_EXTRA_ARGS', ('cts_gl', 'extra_args'),
                              default='').split()


class DEQPCTSTest(deqp.DEQPBaseTest):
    deqp_bin = _CTS_BIN

    @property
    def extra_args(self):
        return super(DEQPCTSTest, self).extra_args + \
            [x for x in _EXTRA_ARGS if not x.startswith('--deqp-case')]

profile = deqp.make_profile(  # pylint: disable=invalid-name
    itertools.chain(
예제 #14
0
import os
import subprocess

from framework import core, grouptools, exceptions
from framework import options
from framework.profile import TestProfile
from framework.test.base import Test, is_crash_returncode, TestRunError

__all__ = [
    'DEQPBaseTest',
    'gen_caselist_txt',
    'iter_deqp_test_cases',
    'make_profile',
]

_EXTRA_ARGS = core.get_option('PIGLIT_DEQP_EXTRA_ARGS', ('deqp', 'extra_args'),
                              default='').split()


def select_source(bin_, filename, mustpass, extra_args):
    """Return either the mustpass list or the generated list."""
    if options.OPTIONS.deqp_mustpass:
        return gen_mustpass_tests(mustpass)
    else:
        return iter_deqp_test_cases(
            gen_caselist_txt(bin_, filename, extra_args))


def make_profile(test_list, test_class):
    """Create a TestProfile instance."""
    profile = TestProfile()
    for testname in test_list:
예제 #15
0
# SOFTWARE.
"""Piglit integrations for the official Khronos Vulkan CTS.

upstream: https://github.com/KhronosGroup/Vulkan-CTS

"""

import re

from framework import core
from framework.test import deqp

__all__ = ['profile']

# Path to the deqp-gles3 executable.
_DEQP_VK_BIN = core.get_option('PIGLIT_DEQP_VK_BIN', ('deqp-vk', 'bin'),
                               required=True)

_EXTRA_ARGS = core.get_option('PIGLIT_DEQP_VK_EXTRA_ARGS',
                              ('deqp-vk', 'extra_args'),
                              default='').split()

_DEQP_ASSERT = re.compile(
    r'deqp-vk: external/vulkancts/.*: Assertion `.*\' failed.')


class DEQPVKTest(deqp.DEQPBaseTest):
    """Test representation for Khronos Vulkan CTS."""
    timeout = 60
    deqp_bin = _DEQP_VK_BIN

    @property
예제 #16
0
Alternatively (or in addition, since environment variables have
precedence), one could set:
PIGLIT_KHR_NOCTX_BIN -- environment equivalent of [khr_noctx]:bin
PIGLIT_KHR_NOCTX_EXTRA_ARGS -- environment equivalent of
[khr_noctx]:extra_args

"""

import itertools

from framework import core
from framework.test import deqp

__all__ = ['profile']

_KHR_BIN = core.get_option('PIGLIT_KHR_NOCTX_BIN', ('khr_noctx', 'bin'),
                           required=True)

_EXTRA_ARGS = core.get_option('PIGLIT_KHR_NOCTX_EXTRA_ARGS',
                              ('khr_noctx', 'extra_args'),
                              default='').split()


class DEQPKHRTest(deqp.DEQPBaseTest):
    deqp_bin = _KHR_BIN

    @property
    def extra_args(self):
        return super(DEQPKHRTest, self).extra_args + \
            [x for x in _EXTRA_ARGS if not x.startswith('--deqp-case')]

예제 #17
0
파일: crucible.py 프로젝트: mesa3d/piglit
import os
import subprocess
import tempfile

try:
    from lxml import etree
except ImportError:
    import xml.etree.ElementTree as etree

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

__all__ = ['profile']

crucible_bin = core.get_option('PIGLIT_CRUCIBLE_BIN', ('crucible', 'bin'),
                               required=True)


class CrucibleTest(Test):
    """Test representation for Crucible"""
    def __init__(self, case_name):
        self.__out_xml = tempfile.NamedTemporaryFile(delete=True).name
        command = [
            crucible_bin, 'run', '--junit-xml={}'.format(self.__out_xml),
            case_name
        ]
        self._case = case_name
        super(CrucibleTest, self).__init__(command)

    def interpret_result(self):
        try:
예제 #18
0
Alternatively (or in addition, since environment variables have precedence),
one could set:
PIGLIT_KHR_GL_BIN -- environment equivalent of [khr_gl45]:bin
PIGLIT_KHR_GL_EXTRA_ARGS -- environment equivalent of [khr_gl45]:extra_args

"""

import itertools

from framework import core
from framework.test import deqp
from framework.options import OPTIONS

__all__ = ['profile']

_KHR_BIN = core.get_option('PIGLIT_KHR_GL_BIN', ('khr_gl45', 'bin'),
                           required=True)

_KHR_MUSTPASS = core.get_option('PIGLIT_KHRGL45_MUSTPASS',
                                 ('khr_gl45', 'mustpasslist'),
                                 required=OPTIONS.deqp_mustpass)

_EXTRA_ARGS = core.get_option('PIGLIT_KHR_GL_EXTRA_ARGS', ('khr_gl45', 'extra_args'),
                              default='').split()


class DEQPKHRTest(deqp.DEQPBaseTest):
    deqp_bin = _KHR_BIN

    @property
    def extra_args(self):
        return super(DEQPKHRTest, self).extra_args + \
예제 #19
0
파일: gtf_gles.py 프로젝트: mesa3d/piglit
Alternatively (or in addition, since environment variables have
precedence), one could set:
PIGLIT_GTF_GLES_BIN -- environment equivalent of [gtf_gles]:bin
PIGLIT_GTF_GLES_EXTRA_ARGS -- environment equivalent of
[gtf_gles]:extra_args

"""

import itertools

from framework import core
from framework.test import deqp

__all__ = ['profile']

_GTF_BIN = core.get_option('PIGLIT_GTF_GLES_BIN', ('gtf_gles', 'bin'),
                           required=True)

_EXTRA_ARGS = core.get_option('PIGLIT_GTF_GLES_EXTRA_ARGS', ('gtf_gles', 'extra_args'),
                              default='').split()


class DEQPGTFTest(deqp.DEQPBaseTest):
    deqp_bin = _GTF_BIN

    @property
    def extra_args(self):
        return super(DEQPGTFTest, self).extra_args + \
            [x for x in _EXTRA_ARGS if not x.startswith('--deqp-case')]


# Add all of the suites by default, users can use filters to remove them.
예제 #20
0
파일: replay.py 프로젝트: mesa3d/piglit
"""

import collections

from os import path

from framework import core, exceptions, grouptools, profile, status
from framework.replay import query_traces_yaml as qty
from framework.test.base import DummyTest
from framework.test.piglit_test import PiglitReplayerTest

__all__ = ['profile']

_DESCRIPTION_FILE = core.get_option('PIGLIT_REPLAY_DESCRIPTION_FILE',
                                    ('replay', 'description_file'),
                                    required=True)

_DEVICE_NAME = core.get_option('PIGLIT_REPLAY_DEVICE_NAME',
                               ('replay', 'device_name'),
                               required=True)

_EXTRA_ARGS = core.get_option('PIGLIT_REPLAY_EXTRA_ARGS',
                              ('replay', 'extra_args'),
                              default='').split()


class ReplayProfile(object):
    def __init__(self, filename, device_name):
        try:
            with open(filename, 'r') as f:
예제 #21
0
# 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.
"""Piglit integrations for dEQP EGL tests."""

from framework import core
from framework.test import deqp
from framework.options import OPTIONS

__all__ = ['profile']

_EGL_BIN = core.get_option('PIGLIT_DEQP_EGL_BIN', ('deqp-egl', 'bin'),
                           required=True)

_DEQP_MUSTPASS = core.get_option('PIGLIT_DEQP_EGL_MUSTPASS',
                                 ('deqp-egl', 'mustpasslist'),
                                 required=OPTIONS.deqp_mustpass)

_EXTRA_ARGS = core.get_option('PIGLIT_DEQP_EGL_EXTRA_ARGS',
                              ('deqp-egl', 'extra_args'),
                              default='').split()


class DEQPEGLTest(deqp.DEQPBaseTest):
    deqp_bin = _EGL_BIN

    @property
    def extra_args(self):