[Piglit] [PATCH 10/11] framework/test/glsl_parser_test.py: Add requirement based fast skipping
baker.dylan.c at gmail.com
baker.dylan.c at gmail.com
Thu Nov 5 14:16:48 PST 2015
From: Dylan Baker <baker.dylan.c at gmail.com>
Running the glslparser profile this results in a ~50 second reduction in
run time on my HSW
Signed-off-by: Dylan Baker <dylanx.c.baker at intel.com>
---
framework/test/glsl_parser_test.py | 11 ++++++---
framework/tests/glsl_parser_test_tests.py | 41 ++++++++++++++++++++++++++++++-
2 files changed, 48 insertions(+), 4 deletions(-)
diff --git a/framework/test/glsl_parser_test.py b/framework/test/glsl_parser_test.py
index e5cd542..338d229 100644
--- a/framework/test/glsl_parser_test.py
+++ b/framework/test/glsl_parser_test.py
@@ -27,6 +27,7 @@ import re
from framework import exceptions
from .piglit_test import PiglitBaseTest
+from .opengl import FastSkipMixin
__all__ = [
'GLSLParserTest',
@@ -42,7 +43,7 @@ class GLSLParserInternalError(exceptions.PiglitInternalError):
pass
-class GLSLParserTest(PiglitBaseTest):
+class GLSLParserTest(FastSkipMixin, PiglitBaseTest):
""" Read the options in a glsl parser test and create a Test object
Specifically it is necessary to parse a glsl_parser_test to get information
@@ -68,14 +69,18 @@ class GLSLParserTest(PiglitBaseTest):
# section to a StringIO and pass that to ConfigParser
with open(filepath, 'r') as testfile:
try:
- command = self.__get_command(self.__parser(testfile, filepath),
- filepath)
+ config = self.__parser(testfile, filepath)
+ command = self.__get_command(config, filepath)
except GLSLParserInternalError as e:
raise exceptions.PiglitFatalError(
'In file "{}":\n{}'.format(filepath, str(e)))
super(GLSLParserTest, self).__init__(command, run_concurrent=True)
+ req = config.get('require_extensions')
+ if req:
+ self.gl_required = set(req.split())
+
def __get_command(self, config, filepath):
""" Create the command argument to pass to super()
diff --git a/framework/tests/glsl_parser_test_tests.py b/framework/tests/glsl_parser_test_tests.py
index 2bb1211..c954e80 100644
--- a/framework/tests/glsl_parser_test_tests.py
+++ b/framework/tests/glsl_parser_test_tests.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2014 Intel Corporation
+# Copyright (c) 2014, 2015 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
@@ -24,6 +24,7 @@ from __future__ import print_function, absolute_import
import os
import textwrap
+import mock
import nose.tools as nt
from framework import exceptions
@@ -34,6 +35,27 @@ from framework.test import TEST_BIN_DIR
# pylint: disable=line-too-long,invalid-name
+class _Setup(object):
+ def __init__(self):
+ self.__patchers = []
+ self.__patchers.append(mock.patch.dict(
+ 'framework.test.opengl.OPTIONS.env',
+ {'PIGLIT_PLATFORM': 'foo'}))
+
+ def setup(self):
+ for patcher in self.__patchers:
+ patcher.start()
+
+ def teardown(self):
+ for patcher in self.__patchers:
+ patcher.stop()
+
+
+_setup = _Setup()
+setup = _setup.setup
+teardown = _setup.teardown
+
+
def _check_config(content):
""" This is the test that actually checks the glsl config section """
with utils.tempfile(content) as tfile:
@@ -354,3 +376,20 @@ def test_get_glslparsertest_gles2():
for version in ['1.00', '3.00']:
test.description = description.format(version)
yield test, content.format(version)
+
+
+def test_set_gl_required():
+ """test.glsl_parser_test.GLSLParserTest: sets glsl_es_version"""
+ rt = {'require_extensions': 'GL_ARB_foobar GL_EXT_foobar'}
+ with mock.patch.object(glsl.GLSLParserTest, '_GLSLParserTest__parser',
+ mock.Mock(return_value=rt)):
+ with mock.patch.object(glsl.GLSLParserTest,
+ '_GLSLParserTest__get_command'):
+ with mock.patch('framework.test.glsl_parser_test.super',
+ mock.Mock()):
+ with mock.patch('framework.test.glsl_parser_test.open',
+ mock.mock_open()):
+ with mock.patch('framework.test.glsl_parser_test.os.stat',
+ mock.mock_open()):
+ test = glsl.GLSLParserTest('foo')
+ nt.eq_(test.gl_required, set(['GL_ARB_foobar', 'GL_EXT_foobar']))
--
2.6.2
More information about the Piglit
mailing list