[Piglit] Proposal to embed glslparsertest specifications into shader source files

Chad Versace chad at chad-versace.us
Mon Nov 29 16:04:47 PST 2010

Hash: SHA1

(A proposal to make Piglit a little easier to use... Please send me your

The format for glslparsertests is suboptimal; the test specification
(pass/fail, required GLSL version) is not located in the test file
itself. This divorce between test and specification causes frequent
maintenance and testing annoyances (How many times have you opened a
failing glslparsertest shader file, only to discover that the author
neglected to comment whether the test should pass or fail?)

I propose that we embed each test specification into the shader source
file itself as a specially formatted comment block, and cease to
register the specifications in /tests/glslparsertest.tests.

What follows is an overview of the new test file format and of the
proposal's implementation.

As for the work involved, it has already been done. In an experimental
Piglit branch [1] [2], all of the below has been implemented and all
pre-existing glslparertests converted to the new format. No testing
quirks have been introduced; test results are identical between master
and the experimental branch.

=== What's in it for me ;) ===

I will soon be writing many many GLSL 1.30 parser tests, and would like
that task to as sane as possible.

=== Comment Block Format ===

The special comment block is simply a list of option/value pairs that
begins with the line '[config]'.

    /* Test bit-shift on ints.
     * [config]
     * expect_result: pass
     * glsl_version: 130
     * [end config]
     * author: Joe Programmer

    int f() {
        return 1 << 4;

The format is that of ConfigParser.SafeConfigParser in the Python
stdlib. By leveraging a pre-existing class in the stdlib:
    * We avoid the messy task of implementing an adhoc parsing scheme.
    * Adding future support for additional option/value pairs is

=== Test Driver ===

The test driver is a new class GLSLParserTest in
/framework/glsl_parser_test.py. It performs just two tasks:
    1. Extract the test specification from the shader source file
       (and possibly report errors in the special comment block).
    2. Pass the source file and specifications to /bin/glslparsertest
       (which is exactly what Piglit does now).

As a bonus feature, glsl_parser_test.py is executable and
hence can be ran as a stand-alone driver:
    ./glsl_parser_test.py test_file.vert

=== Test Registration ===

Define a new function, add_glsl_parser_test(), which registers
the test by *only* specifying the test file. No longer does one
specify pass/fail and required GLSL version. For example:
    # file: /tests/all.tests
    add_glsl_parser_test(group, test_name, file_name)

=== References ===

[1] http://cgit.freedesktop.org/~chadversary/piglit/log/?h=glsl_parser_test

[2] git://anongit.freedesktop.org/~chadversary/piglit;
    cd piglit;
    git checkout glsl_parser_test

- --
Chad Versace
chad.versace at intel.com

Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/


More information about the Piglit mailing list