[Piglit] [PATCH 2/4] program_interface_query: add tests for getprograminterfaceiv

Martin Peres martin.peres at linux.intel.com
Thu Mar 26 04:06:52 PDT 2015


On 26/03/15 11:01, Tapani Pälli wrote:
> Also with this test we could have the NULL input test, to trigger bad 
> things I think it needs to have non-empty shaders though, something like:
>
> glGetProgramInterfaceiv(prog, GL_PROGRAM_OUTPUT, GL_MAX_NAME_LENGTH, 
> NULL);
>
> (some legal query that triggers driver to iterate resources and try to 
> write to NULL)
>
> Otherwise all the errors mentioned in the spec are tested, with null 
> test addition;

I disagree with this one. The spec really is undefined for this and 
crashing is an acceptable
behaviour. I am fine with mesa testing for it, but we should not force 
every driver to
not crash.

>
> Reviewed-by: Tapani Pälli <tapani.palli at intel.com>

As discussed IRL, I will keep your R-b :)

>
>
> On 03/25/2015 06:01 PM, Martin Peres wrote:
>> This test exercises the error codepaths of getprograminterfaceiv.
>>
>> Signed-off-by: Martin Peres <martin.peres at linux.intel.com>
>> ---
>>   tests/all.py                                       |   1 +
>>   .../arb_program_interface_query/CMakeLists.gl.txt  |   1 +
>>   tests/spec/arb_program_interface_query/common.h    |  10 +
>>   .../getprograminterfaceiv.c                        | 202 
>> +++++++++++++++++++++
>>   4 files changed, 214 insertions(+)
>>   create mode 100755 
>> tests/spec/arb_program_interface_query/getprograminterfaceiv.c
>>
>> diff --git a/tests/all.py b/tests/all.py
>> index f47e198..86f2369 100755
>> --- a/tests/all.py
>> +++ b/tests/all.py
>> @@ -2275,6 +2275,7 @@ with profile.group_manager(
>>       g(['arb_program_interface_query-resource-location'], 
>> run_concurrent=False)
>>       g(['arb_program_interface_query-resource-index'], 
>> run_concurrent=False)
>>       g(['arb_program_interface_query-resource-query'], 
>> run_concurrent=False)
>> +    g(['arb_program_interface_query-getprograminterfaceiv'], 
>> run_concurrent=False)
>>
>>   # Group ARB_explicit_uniform_location
>>   with profile.group_manager(
>> diff --git a/tests/spec/arb_program_interface_query/CMakeLists.gl.txt 
>> b/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
>> index 9535798..91ace72 100755
>> --- a/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
>> +++ b/tests/spec/arb_program_interface_query/CMakeLists.gl.txt
>> @@ -12,3 +12,4 @@ link_libraries (
>>   piglit_add_executable 
>> (arb_program_interface_query-resource-location resource-location.c)
>>   piglit_add_executable (arb_program_interface_query-resource-index 
>> resource-index.c)
>>   piglit_add_executable (arb_program_interface_query-resource-query 
>> resource-query.c)
>> +piglit_add_executable 
>> (arb_program_interface_query-getprograminterfaceiv 
>> getprograminterfaceiv.c)
>> diff --git a/tests/spec/arb_program_interface_query/common.h 
>> b/tests/spec/arb_program_interface_query/common.h
>> index 4e5ff01..cc0b2bd 100755
>> --- a/tests/spec/arb_program_interface_query/common.h
>> +++ b/tests/spec/arb_program_interface_query/common.h
>> @@ -25,6 +25,16 @@
>>   #ifndef __COMMON_H__
>>   #define __COMMON_H__
>>
>> +static const char vs_empty[] =
>> +    "#version 150\n"
>> +    "void main() {\n"
>> +    "}";
>> +
>> +static const char fs_empty[] =
>> +    "#version 150\n"
>> +    "void main() {\n"
>> +    "}";
>> +
>>   static const char vs_std[] =
>>       "#version 150\n"
>>       "struct vs_struct {\n"
>> diff --git 
>> a/tests/spec/arb_program_interface_query/getprograminterfaceiv.c 
>> b/tests/spec/arb_program_interface_query/getprograminterfaceiv.c
>> new file mode 100755
>> index 0000000..1d2ca08
>> --- /dev/null
>> +++ b/tests/spec/arb_program_interface_query/getprograminterfaceiv.c
>> @@ -0,0 +1,202 @@
>> +/*
>> + * Copyright © 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 in the Software without restriction, including without 
>> limitation
>> + * the rights to use, copy, modify, merge, publish, distribute, 
>> sublicense,
>> + * and/or sell copies of the Software, and to permit persons to whom 
>> the
>> + * Software is furnished to do so, subject to the following conditions:
>> + *
>> + * The above copyright notice and this permission notice (including 
>> the next
>> + * paragraph) shall be included in all copies or substantial 
>> portions of the
>> + * Software.
>> + *
>> + * 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.
>> + */
>> +
>> +/**
>> + * \file getprograminterfaceiv.c
>> + *
>> + * Tests the error cases of the GetProgramInterfaceiv interface.
>> + *
>> + * From the GL_ARB_program_interface_query spec:
>> + *      "The command
>> + *
>> + *      void GetProgramInterfaceiv(uint program, enum programInterface,
>> + *                                 enum pname, int *params);
>> + *
>> + *      queries a property of the interface <programInterface> in 
>> program
>> + *      <program>, returning its value in <params>.  The property to 
>> return is
>> + *      specified by <pname>.
>> + *
>> + *      If <pname> is ACTIVE_RESOURCES, the value returned is the 
>> number of
>> + *      resources in the active resource list for 
>> <programInterface>. If the
>> + *      list of active resources for <programInterface> is empty, 
>> zero is
>> + *      returned.
>> + *
>> + *      If <pname> is MAX_NAME_LENGTH, the value returned is the 
>> length of the
>> + *      longest active name string for an active resource in 
>> <programInterface>.
>> + *      This length includes an extra character for the null 
>> terminator. If
>> + *      the list of active resources for <programInterface> is 
>> empty, zero is
>> + *      returned.  The error INVALID_OPERATION is generated if
>> + *      <programInterface> is ATOMIC_COUNTER_BUFFER, since active 
>> atomic counter
>> + *      buffer resources are not assigned name strings.
>> + *
>> + *      If <pname> is MAX_NUM_ACTIVE_VARIABLES, the value returned 
>> is the number
>> + *      of active variables belonging to the interface block or 
>> atomic counter
>> + *      buffer resource in <programInterface> with the most active 
>> variables.
>> + *      If the list of active resources for <programInterface> is 
>> empty, zero is
>> + *      returned.  The error INVALID_OPERATION is generated if
>> + *      <programInterface> is not UNIFORM_BLOCK, 
>> ATOMIC_COUNTER_BUFFER, or
>> + *      SHADER_STORAGE_BLOCK.
>> + *
>> + *      If <pname> is MAX_NUM_COMPATIBLE_SUBROUTINES, the value 
>> returned is the
>> + *      number of compatible subroutines belonging to the active 
>> subroutine
>> + *      uniform in <programInterface> with the most compatible 
>> subroutines. If
>> + *      the list of active resources for <programInterface> is 
>> empty, zero is
>> + *      returned.  The error INVALID_OPERATION is generated unless
>> + *      <programInterface> is VERTEX_SUBROUTINE_UNIFORM,
>> + *      TESS_CONTROL_SUBROUTINE_UNIFORM, 
>> TESS_EVALUATION_SUBROUTINE_UNIFORM,
>> + *      GEOMETRY_SUBROUTINE_UNIFORM, FRAGMENT_SUBROUTINE_UNIFORM, or
>> + *      COMPUTE_SUBROUTINE_UNIFORM.
>> + *
>> + *      [...]
>> + *
>> + *      An INVALID_VALUE error is generated by GetProgramInterfaceiv,
>> + *      GetProgramResourceIndex, GetProgramResourceName, 
>> GetProgramResourceiv,
>> + *      GetProgramResourceLocation, and 
>> GetProgramResourceLocationIndex if
>> + *      <program> is not the name of either a shader or program object.
>> + *
>> + *      An INVALID_OPERATION error is generated by 
>> GetProgramInterfaceiv,
>> + *      GetProgramResourceIndex, GetProgramResourceName, 
>> GetProgramResourceiv,
>> + *      GetProgramResourceLocation, and 
>> GetProgramResourceLocationIndex if
>> + *      <program> is the name of a shader object.
>> + *
>> + *      INVALID_OPERATION is generated by GetProgramInterfaceiv if 
>> the parameter
>> + *     <pname> is not supported for the interface <programInterface>."
>> + */
>> +
>> +#include "piglit-util-gl.h"
>> +#include "common.h"
>> +
>> +PIGLIT_GL_TEST_CONFIG_BEGIN
>> +
>> +    config.supports_gl_core_version = 32;
>> +
>> +PIGLIT_GL_TEST_CONFIG_END
>> +
>> +struct subtest_t {
>> +    GLenum programInterface;
>> +    GLenum pname;
>> +    GLenum expected_error;
>> +
>> +
>> +    const char *programInterface_str;
>> +    const char *pname_str;
>> +    const char *error_str;
>> +};
>> +
>> +#define ST(programInterface, pname, error) { \
>> +    (programInterface), (pname), (error), #programInterface, #pname, 
>> #error \
>> +}
>> +
>> +static const struct subtest_t programInterface_subtests[] = {
>> + ST(GL_TRUE, GL_MAX_NAME_LENGTH, GL_INVALID_OPERATION),
>> + ST(GL_UNIFORM, GL_TRUE, GL_INVALID_OPERATION),
>> + ST(GL_ATOMIC_COUNTER_BUFFER, GL_MAX_NAME_LENGTH, 
>> GL_INVALID_OPERATION),
>> + ST(GL_UNIFORM, GL_MAX_NUM_ACTIVE_VARIABLES, GL_INVALID_OPERATION),
>> + ST(GL_PROGRAM_OUTPUT, GL_MAX_NUM_COMPATIBLE_SUBROUTINES, 
>> GL_INVALID_OPERATION),
>> +};
>> +
>> +static bool
>> +check_extensions(const struct subtest_t st)
>> +{
>> +    if (st.programInterface == GL_ATOMIC_COUNTER_BUFFER &&
>> + !piglit_is_extension_supported("GL_ARB_shader_atomic_counters")) {
>> +        return false;
>> +    }
>> +
>> +    return true;
>> +}
>> +
>> +static void
>> +run_subtest(const struct subtest_t st, GLuint prog, bool *pass)
>> +{
>> +    enum piglit_result result;
>> +    bool local_pass = true;
>> +    int value;
>> +
>> +    if (!check_extensions(st)) {
>> +        result = PIGLIT_SKIP;
>> +        goto report_result;
>> +    }
>> +
>> +    glGetProgramInterfaceiv(prog, st.programInterface, st.pname, 
>> &value);
>> +    if (!piglit_check_gl_error(st.expected_error)) {
>> +        printf("    Call was glGetProgramInterfaceiv(prog, %s, "
>> +               "%s, ...)\n", st.programInterface_str, st.pname_str);
>> +        local_pass = false;
>> +    }
>> +
>> +    *pass = *pass && local_pass;
>> +    result = local_pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +
>> +report_result:
>> +    piglit_report_subtest_result(result, "%s on %s", st.pname_str,
>> +                     st.programInterface_str);
>> +}
>> +
>> +void
>> +piglit_init(int argc, char **argv)
>> +{
>> +    piglit_require_extension("GL_ARB_program_interface_query");
>> +}
>> +
>> +enum piglit_result
>> +piglit_display(void)
>> +{
>> +    GLuint prog, shader, test_cnt;
>> +    bool pass = true, prg_tst;
>> +    int i;
>> +
>> +    /* test using an unexisting program ID */
>> +    glGetProgramInterfaceiv(1337, GL_UNIFORM, 
>> GL_MAX_NUM_ACTIVE_VARIABLES,
>> +                &i);
>> +    prg_tst = piglit_check_gl_error(GL_INVALID_VALUE);
>> +    pass = pass && prg_tst;
>> +    piglit_report_subtest_result(prg_tst ? PIGLIT_PASS : PIGLIT_FAIL,
>> +                     "Invalid program (undefined ID)");
>> +
>> +    /* test using a shader ID */
>> +    shader = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_empty);
>> +    glGetProgramInterfaceiv(shader, GL_UNIFORM, 
>> GL_MAX_NUM_ACTIVE_VARIABLES,
>> +                &i);
>> +    prg_tst = piglit_check_gl_error(GL_INVALID_OPERATION);
>> +    pass = pass && prg_tst;
>> +    piglit_report_subtest_result(prg_tst ? PIGLIT_PASS : PIGLIT_FAIL,
>> +                     "Invalid program (call on shader)");
>> +
>> +    /* build a valid program that will be used to run the other 
>> tests */
>> +    prog = piglit_build_simple_program(vs_empty, fs_empty);
>> +    if (!piglit_link_check_status(prog)) {
>> +        glDeleteProgram(prog);
>> +        return PIGLIT_FAIL;
>> +    }
>> +
>> +    /* run all the getprograminterfaceiv tests */
>> +    test_cnt = sizeof(programInterface_subtests) / sizeof(struct 
>> subtest_t);
>> +    for (i = 0; i < test_cnt; i++) {
>> +        run_subtest(programInterface_subtests[i], prog, &pass);
>> +    }
>> +
>> +    glDeleteProgram(prog);
>> +
>> +    return pass ? PIGLIT_PASS : PIGLIT_FAIL;
>> +}
>>



More information about the Piglit mailing list