Test Reporting: Use JSON as interchange format for piglit tests

It just so happens that the plain text representation of a python
dictionary is a superset of a JSON dictionary. The only real difference
is that python allows ' and " to be used interchangeably while JSON only
accepts ". It also just so happens that JSON is a really nice format for
sending data between two programs, and that python has a very fast
implementation of JSON available, which piglit already supports
(simplejson) as well as a native (but slower) version.

This patch removes the use of eval(), which is considered slow, and
allows for arbitrary code execution. By moving to JSON as our
interchange format between compiled tests and python we gain
standardization, easier maintenance, and less python code required.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Test Reporting: simplify subtest reporting

Since we're using json to decode our results, we can simplify the way we
pass information between C/C++ tests and the python framework. This
replaces the PIGLIT:subtest {"<name>": "<status>"} syntax with
PIGLIT: {"subtest": {"<name>": "<status>"}}.

This is a very clean solution, and eliminates the need for several if
branches and loop iterations in the python framework.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
profile: fix typo Test.Opts -> Test.OPTS

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Tested-by: Kenneth Graunke <kenneth@whitecape.org>
util/wfl: remove log prints in success paths

Commit 04c9e870 introduced some debugging prints on success that make it
clearer what's going on. However having these output for ever test seems
unnecessary. Hide them behind compilation guards.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
util/log: Add function piglit_logd()

The function logs a debug message if environment variable
PIGLIT_DEBUG is "1" or "true".

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
util/wfl: Re-enable GL 3.1 log messages in debug paths

Commit 1fdb953 removed some noisy debug messages with preprocessor
guards. This patch re-enables them, but only if the environment variable
PIGLIT_DEBUG is "1" or "true".

Fixes some unused variable warnings.

Signed-off-by: Chad Versace <chad.versace@linux.intel.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
arb_uniform_buffer_object/maxuniformblocksize: fix printf message

So the usage/help info agrees with the actual command line argument.
Trivial.
framework: Remove she-bang from non executable python files

Nothing in framework/ or generated_tests/ is called directly using the
./syntax, instead it is called from cmake using python explicitly. With
that in mind none of them need a she-bang

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
python: Remove executable bit from generators

Test generators are not called using the ./ syntax, so no need have the
executable bit set.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
egl-create-surface: Remove unused variable.

Fix clang unused-const-variable warning.

egl-create-surface.c:40:21: warning: unused variable 'pixmap_attribs' [-Wunused-const-variable]
static const EGLint pixmap_attribs[] = {
                    ^

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
arb_uniform_buffer_object: add a test that uses persistent buffers

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
exectest_test.py: Add test for PiglitTest.interpret_result() clobbering

This test demonstrates a bug in which PiglitTest clobbers subtest
results.

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
results.py: Add recursive_update method to TestResult

This method is used during PiglitTest.interpret_result() to update
subtest entries safely. I chose this approach since it is robust,
reusable, and it felt more natural as a part of TestResult than putting
it in PiglitTest.interpret_result()

v2: - Fix commit message
    - be more pythonic with dicts

Signed-off-by: Dylan Baker <baker.dylan.c@gmail.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
cl: Add __attribute__(work_group_size_hint(..)) test

Currently, this test triggers an llvm error on r600g/radeonsi.

Signed-off-by: Aaron Watry <awatry@gmail.com>
CC: Tom Stellard <thomas.stellard@amd.com>
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=76223
amd_vertex_shader_viewport_index: add render test

This is a copy of the render_viewport ARB_viewport_array test. I didn't
think that it was worth it to copy the scissor/depth tests, since they
basically test the same thing but making sure that scissor/depth are
applied correctly. If that works for ARB_viewport_array, it really
should work here too.

Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Chris Forbes <chrisf@ijw.co.nz>
cl-api-get-platform-ids: Initialize variable.

Fix clang sometimes-uninitialized warning.

get-platform-ids.c:62:5: warning: variable 'platforms' is used uninitialized whenever 'if' condition is true [-Wsometimes-uninitialized]
        if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
get-platform-ids.c:93:30: note: uninitialized use occurs here
        errNo = clGetPlatformIDs(0, platforms, NULL);
                                    ^~~~~~~~~
get-platform-ids.c:62:2: note: remove the 'if' if its condition is always false
        if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
get-platform-ids.c:56:27: note: initialize the variable 'platforms' to silence this warning
        cl_platform_id* platforms;
                                 ^
                                  = NULL

Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
cl: Fix out-of-bounds write in get-num-groups

Reviewed-by: Tom Stellard <thomas.stellard@amd.com>
util/gl: Fix piglit_is_gles to return true for "OpenGL ES-CM 1.1 ..."

Piglit looked for a GL_VERSION starting with "OpenGL ES ", which did not
match "OpenGL ES-CM 1.1 Mesa 10.2.1".  Stop requiring the trailing
space.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
util/gl: Unify piglit_num_components between GL and GLES

The unified implementation handles all the GLenum values expected by
either.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>
util/gl: Move piglit_get_luminance_intensity_bits to GL common code

This doesn't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Reviewed-by: Chad Versace <chad.versace@linux.intel.com>