Ejemplo n.º 1
0
def test_get_glslparsertest_gles2(version, has_bin, forced, tmpdir, mocker):
    """Tests for assigning the correct binary for GLES tests.

    Tests with and without the gles binary and with and without the force
    desktop mode.
    """
    if not has_bin or forced:
        expected = 'glslparsertest'
    else:
        expected = 'glslparsertest_gles2'

    mocker.patch('framework.test.glsl_parser_test._HAS_GLES_BIN', has_bin)
    mocker.patch('framework.test.glsl_parser_test._FORCE_DESKTOP_VERSION',
                 forced)

    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        /* [config]
         * expect_result: pass
         * glsl_version: {}
         * [end config]
         */""".format(version)))
    inst = glsl.GLSLParserTest(six.text_type(p))

    assert os.path.basename(inst.command[0]) == expected
Ejemplo n.º 2
0
def test_no_config_end(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: exception is raised if [end
    config] section is missing."""
    p = tmpdir.join('test.frag')
    p.write('// [config]')

    with pytest.raises(exceptions.PiglitFatalError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 3
0
def test_config_to_command(config, expected, tmpdir):
    """Test that config blocks are converted into the expected commands."""
    p = tmpdir.join('test.frag')
    p.write(config)
    test = glsl.GLSLParserTest(six.text_type(p))
    # add the filename, which isn't known util now
    expected.insert(1, six.text_type(p))

    assert test.command == expected
Ejemplo n.º 4
0
def test_bad_section_name():
    """test.glsl_parser_test.GLSLParserTest: A section name not in the _CONFIG_KEYS name raises an error"""
    content = ('// [config]\n'
               '// expect_result: pass\n'
               '// glsl_version: 1.10\n'
               '// new_awesome_key: foo\n'
               '// [end config]\n')

    with utils.tempfile(content) as tfile:
        glsl.GLSLParserTest(tfile)
Ejemplo n.º 5
0
def test_no_glsl_version(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: exception is raised if
    "glsl_version" key is missing."""
    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        // [config]
        // expect_result: pass
        // [end config]"""))

    with pytest.raises(exceptions.PiglitFatalError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 6
0
def test_find_config_start(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: successfully finds [config]
    section."""
    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""
        // [config]
        // expect_result: pass
        // glsl_version: 1.10"""))

    with pytest.raises(exceptions.PiglitFatalError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 7
0
def test_no_config_start(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: exception is raised if [config]
    section is missing."""
    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""
        // expect_result: pass
        // glsl_version: 1.10
        // [end config]"""))

    with pytest.raises(glsl.GLSLParserNoConfigError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 8
0
def test_glslparser_initializer():
    """test.glsl_parser_test.GLSLParserTest: clas initializes correctly"""
    content = textwrap.dedent("""\
        /*
         * [config]
         * expect_result: pass
         * glsl_version: 1.10
         * [end config]
         */
        """)

    with utils.tempfile(content) as f:
        glsl.GLSLParserTest(f)
Ejemplo n.º 9
0
def test_cpp_comments(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: parses C++ style comments ('//').
    """
    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        // [config]
        // expect_result: pass
        // glsl_version: 1.10
        // [end config]"""))
    test = glsl.GLSLParserTest(six.text_type(p))

    assert test.command == [os.path.join(_TEST_BIN_DIR, 'glslparsertest'),
                            six.text_type(p), 'pass', '1.10']
Ejemplo n.º 10
0
def test_bad_section_name(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: Unknown config keys cause an
    error."""
    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        // [config]
        // expect_result: pass
        // glsl_version: 1.10
        // new_awesome_key: foo
        // [end config]"""))

    with pytest.raises(exceptions.PiglitFatalError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 11
0
def test_no_config_start():
    """test.glsl_parser_test.GLSLParserTest: exception is raised if [config] section is missing
    """
    content = ('// expect_result: pass\n'
               '// glsl_version: 1.10\n'
               '// [end config]\n')
    with utils.tempfile(content) as tfile:
        with nt.assert_raises(glsl.GLSLParserNoConfigError) as exc:
            glsl.GLSLParserTest(tfile)
            nt.assert_equal(
                exc.exception,
                'No [config] section found!',
                msg="No config section was found and no exception raised")
Ejemplo n.º 12
0
def test_duplicate_entry(extra, tmpdir):
    """Test that duplicate entries are an error."""
    p = tmpdir.join('test.vert')
    p.write(textwrap.dedent("""\
        // [config]
        // expect_result: pass
        // glsl_version: 1.10
        // require_extensions: ARB_foobar
        // check_link: True
        // {}
        // [end config]""".format(extra)))

    with pytest.raises(exceptions.PiglitFatalError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 13
0
def test_invalid_extensions_separator(separator, tmpdir):
    """Test that invalid extension separators are rejected."""
    p = tmpdir.join('test.vert')
    p.write(textwrap.dedent("""\
        // [config]
        // expect_result: pass
        // glsl_version: 1.10
        // require_extensions: ARB_foobar
        // check_link: True
        // require_extensions: {}
        // [end config]""".format(separator)))

    with pytest.raises(exceptions.PiglitFatalError):
        glsl.GLSLParserTest(six.text_type(p))
Ejemplo n.º 14
0
def test_valid_extensions(ext, tmpdir):
    """Test that invalid extension separators are rejected."""
    p = tmpdir.join('test.vert')
    p.write(textwrap.dedent("""\
        // [config]
        // expect_result: pass
        // glsl_version: 1.10
        // require_extensions: {}
        // [end config]""".format(ext)))

    expected = ext.split(' ')
    test = glsl.GLSLParserTest(six.text_type(p))

    assert test.command[-len(expected):] == expected
Ejemplo n.º 15
0
def test_binary_skip():
    """test.glsl_parser_test.GLSLParserTest.is_skip: skips OpenGL tests when not built with desktop support"""
    content = textwrap.dedent("""\
        /*
         * [config]
         * expect_result: pass
         * glsl_version: 1.10
         * [end config]
         */
        """)

    with utils.tempfile(content) as f:
        test = glsl.GLSLParserTest(f)
        test.is_skip()
Ejemplo n.º 16
0
def test_set_glsl_es_version():
    """test.glsl_parser_test.GLSLParserTest: sets glsl_es_version"""
    rt = {'glsl_version': '3.00 es'}
    with mock.patch.object(glsl.GLSLParserTest, '_GLSLParserTest__parser',
                           mock.Mock(return_value=rt)):
        with mock.patch.object(glsl.GLSLParserTest,
                               '_GLSLParserTest__get_command',
                               return_value=['foo']):
            with mock.patch('framework.test.glsl_parser_test.open',
                            mock.mock_open(),
                            create=True):
                with mock.patch('framework.test.glsl_parser_test.os.stat',
                                mock.mock_open()):
                    test = glsl.GLSLParserTest('foo')
    nt.eq_(test.glsl_es_version, 3.0)
Ejemplo n.º 17
0
def test_set_gl_required():
    """test.glsl_parser_test.GLSLParserTest: sets gl_required"""
    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',
                               return_value=['foo']):
            with mock.patch('framework.test.glsl_parser_test.open',
                            mock.mock_open(),
                            create=True):
                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']))
Ejemplo n.º 18
0
def test_empty_in_config_c(tmpdir):
    """test.glsl_parser_test.GLSLParserTest: C style comments can have blank
    commented lines."""
    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        /* [config]
         *
         * expect_result: pass
         * glsl_version: 1.10
         * [end config]
         */"""))
    test = glsl.GLSLParserTest(six.text_type(p))

    assert test.command == [os.path.join(_TEST_BIN_DIR, 'glslparsertest'),
                            six.text_type(p), 'pass', '1.10']
Ejemplo n.º 19
0
def test_skip_desktop_without_binary(tmpdir, mocker):
    """There is no way to run desktop tests with only GLES compiled make sure
    we don't try.
    """
    mocker.patch('framework.test.glsl_parser_test._HAS_GL_BIN', False)

    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        /* [config]
         * expect_result: pass
         * glsl_version: 1.10
         * [end config]
         */"""))
    test = glsl.GLSLParserTest(six.text_type(p))

    with pytest.raises(_TestIsSkip):
        test.is_skip()
Ejemplo n.º 20
0
def test_add_compatibility_requirement_fastskip(version, extension, tmpdir,
                                                mocker):
    """When running GLES tests using the GL binary ensure that the proper
    ARB_ES<ver> compatibility extension is added to the requirements.

    This test checks the fast skipping variable
    """
    mocker.patch('framework.test.glsl_parser_test._HAS_GLES_BIN', False)

    p = tmpdir.join('test.frag')
    p.write(textwrap.dedent("""\
        /* [config]
         * expect_result: pass
         * glsl_version: {}
         * require_extensions: GL_ARB_ham_sandwhich
         * [end config]
         */""".format(version)))
    test = glsl.GLSLParserTest(six.text_type(p))

    # The arb_compat extension was added to the fast skipping arguments
    assert extension in test.gl_required
Ejemplo n.º 21
0
 def check_bad_character(tfile):
     """ Check for bad characters """
     glsl.GLSLParserTest(tfile)
Ejemplo n.º 22
0
 def test_exclude_not_added_to_gl_required(self, tmpdir):
     p = tmpdir.join('test.frag')
     self.write_config(p, extra="require_extensions: GL_ARB_foo !GL_ARB_bar")
     assert glsl.GLSLParserTest(six.text_type(p)).gl_required == \
         {'GL_ARB_foo'}
Ejemplo n.º 23
0
 def test(ver, expected):
     with utils.tempfile(content.format(ver)) as f:
         test = glsl.GLSLParserTest(f)
     nt.assert_in(expected, test.gl_required)
Ejemplo n.º 24
0
 def test_glsl_es_version(self, tmpdir):
     p = tmpdir.join('test.frag')
     self.write_config(p, version='3.0')
     assert glsl.GLSLParserTest(six.text_type(p)).glsl_es_version == 3.0
Ejemplo n.º 25
0
 def check_no_duplicates(content):
     """ Ensure that duplicate entries raise an error """
     with utils.tempfile(content) as tfile:
         glsl.GLSLParserTest(tfile)
Ejemplo n.º 26
0
def _check_config(content):
    """ This is the test that actually checks the glsl config section """
    with utils.tempfile(content) as tfile:
        return glsl.GLSLParserTest(tfile), tfile
Ejemplo n.º 27
0
def test_find_config_start():
    """test.glsl_parser_test.GLSLParserTest: successfully finds [config] section
    """
    content = ('// [config]\n' '// glsl_version: 1.10\n' '//\n')
    with utils.tempfile(content) as tfile:
        glsl.GLSLParserTest(tfile)
Ejemplo n.º 28
0
 def check_good_extension(file_):
     """ A good extension should not raise a GLSLParserException """
     glsl.GLSLParserTest(file_)
Ejemplo n.º 29
0
def test_no_glsl_version():
    """test.glsl_parser_test.GLSLParserTest: exception is raised if "glsl_version" key is missing
    """
    content = ('// [config]\n' '// expect_result: pass\n' '// [end config]\n')
    with utils.tempfile(content) as tfile:
        glsl.GLSLParserTest(tfile)
Ejemplo n.º 30
0
 def test(content, expected):
     with utils.tempfile(content) as f:
         t = glsl.GLSLParserTest(f)
         nt.eq_(os.path.basename(t.command[0]), expected)