[Piglit] [PATCH] KHR_debug: test PushDebugGroup() and PopDebugGroup()

Ian Romanick idr at freedesktop.org
Tue Feb 18 15:44:25 PST 2014


On 02/16/2014 06:44 PM, Timothy Arceri wrote:
> Pass: Intel i965 Mesa
> 
> Fail: AMD Radeon HD 6670 - Catalyst 13.251
> Catalyst doesnt seem to pop ids correctly and also push doesnt accept a -1 pararmeter when it should
> 
> Signed-off-by: Timothy Arceri <t_arceri at yahoo.com.au>
> ---
>  tests/all.py                                |   1 +
>  tests/spec/khr_debug/CMakeLists.gl.txt      |   1 +
>  tests/spec/khr_debug/debug-push-pop-group.c | 280 ++++++++++++++++++++++++++++
>  3 files changed, 282 insertions(+)
>  create mode 100644 tests/spec/khr_debug/debug-push-pop-group.c
> 
> diff --git a/tests/all.py b/tests/all.py
> index ba34543..4c373a0 100644
> --- a/tests/all.py
> +++ b/tests/all.py
> @@ -1820,6 +1820,7 @@ add_plain_test(arb_debug_output, 'arb_debug_output-api_error')
>  khr_debug = Group()
>  spec['KHR_debug'] = khr_debug
>  khr_debug['object-label'] = concurrent_test('khr_debug-object-label')
> +khr_debug['push-pop-group'] = concurrent_test('khr_debug-push-pop-group')
>  
>  # Group ARB_occlusion_query2
>  arb_occlusion_query2 = Group()
> diff --git a/tests/spec/khr_debug/CMakeLists.gl.txt b/tests/spec/khr_debug/CMakeLists.gl.txt
> index b0079df..f7b32bd 100644
> --- a/tests/spec/khr_debug/CMakeLists.gl.txt
> +++ b/tests/spec/khr_debug/CMakeLists.gl.txt
> @@ -10,5 +10,6 @@ link_libraries (
>  )
>  
>  piglit_add_executable (khr_debug-object-label debug-object-label.c)
> +piglit_add_executable (khr_debug-push-pop-group debug-push-pop-group.c)
>  
>  # vim: ft=cmake:
> diff --git a/tests/spec/khr_debug/debug-push-pop-group.c b/tests/spec/khr_debug/debug-push-pop-group.c
> new file mode 100644
> index 0000000..818511e
> --- /dev/null
> +++ b/tests/spec/khr_debug/debug-push-pop-group.c
> @@ -0,0 +1,280 @@
> +/*
> + * Copyright (c) 2013 Timothy Arceri <t_arceri at yahoo.com.au>
> + *
> + * 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
> + * on the rights to use, copy, modify, merge, publish, distribute, sub
> + * license, 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
> + * NON-INFRINGEMENT.  IN NO EVENT SHALL AUTHORS AND/OR THEIR SUPPLIERS
> + * 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.
> + */
> +
> +#include "piglit-util-gl-common.h"
> +
> +static const char *TestMessage1 = "Piglit Message 1";
> +static const char *TestMessage2 = "Piglit Message 2";
> +static const char *TestMessage3 = "Piglit Message 3";
> +static const char *TestMessage4 = "Piglit Message 4";
> +
> +static const int MessageId1 = 101;
> +static const int MessageId2 = 202;
> +static const int MessageId3 = 303;
> +static const int MessageId4 = 404;
> +
> +PIGLIT_GL_TEST_CONFIG_BEGIN
> +
> +	config.supports_gl_compat_version = 11;
> +	config.require_debug_context = true;
> +
> +	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
> +
> +PIGLIT_GL_TEST_CONFIG_END
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +	return PIGLIT_PASS;
> +}

At Paul's suggestion, we started putting the empty piglit_display
functions at the end of the file... that way you can get to the meaty
bits quicker.

> +
> +static void clear_message_log()
> +{
> +	char log[4096];
> +	while(!!glGetDebugMessageLog(1, 4096, NULL, NULL, NULL, NULL, NULL, log));

Empty loop bodies like that always look weird to me, and they're often
easy to mistake as bugs... "Did he mean for that ; to be there?"  I
usually like to format them like

    while (...)
        /* empty */ ;

so the author's intention is obvious.

> +}
> +
> +static bool check_inheritance_messages(int expectedCount, GLuint* expectedIds)
> +{
> +	bool pass = true;
> +	int max_messages = 5;
> +	int bufSize = 1280;
> +	int i;
> +	GLuint count;
> +	GLuint ids[max_messages];
> +	GLchar messageLog[bufSize];
> +
> +	count = glGetDebugMessageLog(max_messages,
> +				     bufSize,
> +				     NULL,
> +				     NULL,
> +				     ids,
> +				     NULL,
> +				     NULL,
> +				     messageLog);
> +
> +	if (count != expectedCount) {
> +		fprintf(stderr, "Expected message count: %i Actual message count: %i\n",
> +		        expectedCount, count);
> +		pass = false;
> +	} else {
> +		for (i = 0; i < expectedCount; i++) {
> +			if (expectedIds[i] != ids[i]) {
> +				fprintf(stderr, "Expected id: %i Actual id: %i\n",
> +				        expectedIds[i], ids[i]);
> +				pass = false;
> +			}
> +		}
> +	}
> +
> +	return pass;
> +}
> +
> +static void insert_inheritance_messages()
> +{
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage1);
> +
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId2,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage2);
> +
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId3,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage3);
> +
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId4,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage4);
> +}
> +
> +/*
> + * Test inheritance of group filtering (nesting)
> + */
> +static bool test_push_pop_group_inheritance()
> +{
> +	bool pass = true;
> +	GLuint allowedIds1[] = {MessageId1};
> +	GLuint allowedIds2[] = {MessageId2};
> +	GLuint allowedIds3[] = {MessageId3};
> +
> +	GLuint expectedIds1[] = {MessageId1};
> +	GLuint expectedIds2[] = {MessageId1, MessageId2};
> +	GLuint expectedIds3[] = {MessageId1, MessageId2, MessageId3};
> +
> +	puts("Testing Push debug group inheritance");
> +
> +	/* Setup of the default active debug group: Filter everything out */
> +	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE,
> +			      GL_DONT_CARE, 0, NULL, GL_FALSE);
> +
> +	/* Push debug group 1 and allow messages with the id 101*/
> +	glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Push_Pop 1");
> +	glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER,
> +			      GL_DONT_CARE, 1, allowedIds1, GL_TRUE);
> +	insert_inheritance_messages();
> +	pass = check_inheritance_messages(1, expectedIds1);
> +
> +	/* Push debug group 1 and allow messages with the id 101 and 202*/
> +	glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Push_Pop 2");
> +	glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER,
> +			      GL_DONT_CARE, 1, allowedIds2, GL_TRUE);
> +	insert_inheritance_messages();
> +	pass = check_inheritance_messages(2, expectedIds2) && pass;
> +
> +	/* Push debug group 1 and allow messages with the id 101, 202 and 303*/
> +	glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, "Push_Pop 3");
> +	glDebugMessageControl(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER,
> +			      GL_DONT_CARE, 1, allowedIds3, GL_TRUE);
> +	insert_inheritance_messages();
> +	pass = check_inheritance_messages(3, expectedIds3) && pass;
> +
> +	puts("Testing Pop debug group inheritance");
> +
> +	/* Pop debug group 3 */
> +	glPopDebugGroup();
> +	insert_inheritance_messages();
> +	pass = check_inheritance_messages(2, expectedIds2) && pass;
> +
> +	/* Pop debug group 2 */
> +	glPopDebugGroup();
> +	insert_inheritance_messages();
> +	pass = check_inheritance_messages(1, expectedIds1) && pass;
> +
> +	/* Pop group 1, restore the volume control of the default debug group. */
> +	glPopDebugGroup();
> +	insert_inheritance_messages();
> +
> +	return pass;
> +}
> +
> +/*
> + * Test Push/Pop Debug Group
> + */
> +static bool test_push_pop_debug_group()
> +{
> +	bool pass = true;
> +	int max_messages = 5;
> +	int bufSize = 1280;
> +	int i, nextMessage = 0;
> +	GLuint count;
> +
> +	GLsizei lengths[max_messages];
> +	GLchar messageLog[bufSize];
> +
> +	puts("Testing Push Pop debug message group");
> +
> +	/* Setup of the default active debug group: Filter everything in */
> +	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
> +			      0, NULL, GL_TRUE);
> +
> +	/* Generate a debug marker debug output message */
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage1);
> +
> +	/* Push debug group 1 */
> +	glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 1, -1, TestMessage2);
> +
> +	/* Setup of the debug group 1: Filter everything out */
> +	glDebugMessageControl(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE,
> +			      0, NULL, GL_FALSE);
> +
> +	/* This message shouldn't appear in the debug output log */
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage3);
> +
> +	/* Pop group 1, restore the volume control of the default debug group. */
> +	glPopDebugGroup();
> +
> +	/* Generate a debug marker debug output message */
> +	glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, MessageId1,
> +			     GL_DEBUG_SEVERITY_NOTIFICATION, -1, TestMessage4);
> +
> +	/* Check that message log has done correct filtering */
> +	count = glGetDebugMessageLog(max_messages,
> +				     bufSize,
> +				     NULL,
> +				     NULL,
> +				     NULL,
> +				     NULL,
> +				     lengths,
> +				     messageLog);
> +
> +	if (count != 4) {
> +		fprintf(stderr, "The message log should contain 4 messages not %i messages\n", count);
> +		nextMessage = 0;
> +		for (i = 0; i < count; i++) {
> +			fprintf(stderr, "%s\n", messageLog+nextMessage);
> +			nextMessage += lengths[i];
> +		}
> +		pass = false;
> +	}
> +
> +	if (pass) {
> +		/* the thrid message should contain TestMessage2 from glPopDebugGroup() */
> +		nextMessage = lengths[0] + lengths[1];
> +		if (strstr(messageLog+nextMessage, TestMessage2) == NULL) {
> +			fprintf(stderr, "Expected: %s Message: %s\n", TestMessage2, messageLog+nextMessage);
> +			pass = false;
> +		}
> +
> +		/* double check that TestMessage3 didnt sneak into the log */
> +		nextMessage = 0;
> +		for (i = 0; i < count; i++) {
> +			if (strstr(messageLog+nextMessage, TestMessage3) != NULL) {
> +				fprintf(stderr, "The log should not contain the message: %s",
> +					messageLog+nextMessage);
> +				pass = false;
> +			}
> +			nextMessage += lengths[i];
> +		}

Are the individual messages in the log NUL terminated?  Does lengths[i]
include the terminator?

> +
> +		/* the forth message should contain TestMessage4 */
> +		nextMessage = lengths[0] + lengths[1] + lengths[2];
> +		if (strstr(messageLog+nextMessage, TestMessage4) == NULL) {
> +			fprintf(stderr, "Expected: %s Message: %s\n", TestMessage4, messageLog+nextMessage);
> +			pass = false;
> +		}
> +	}
> +
> +	return pass;
> +}
> +
> +void piglit_init(int argc, char **argv)
> +{
> +	bool pass = true;
> +
> +	piglit_require_extension("GL_KHR_debug");
> +
> +	glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
> +	glEnable(GL_DEBUG_OUTPUT);
> +
> +	if (!piglit_check_gl_error(GL_NO_ERROR))
> +		piglit_report_result(PIGLIT_FAIL);
> +
> +	clear_message_log();
> +
> +	/* test message control and debug groups */
> +	pass = test_push_pop_debug_group();
> +	pass = test_push_pop_group_inheritance() && pass;
> +
> +	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
> +}
> 



More information about the Piglit mailing list