[Piglit] [PATCH 06/11] egl_khr_create_context: Verify that the attributes list can be empty

Ian Romanick idr at freedesktop.org
Wed Aug 1 10:18:49 PDT 2012


On 07/31/2012 06:38 PM, Matt Turner wrote:
> ---
>   tests/all_egl.tests                                |    1 +
>   .../spec/egl_khr_create_context/CMakeLists.gl.txt  |    1 +
>   .../egl_khr_create_context/valid-attribute-empty.c |   81 ++++++++++++++++++++
>   3 files changed, 83 insertions(+), 0 deletions(-)
>   create mode 100644 tests/egl/spec/egl_khr_create_context/valid-attribute-empty.c
>
> diff --git a/tests/all_egl.tests b/tests/all_egl.tests
> index 57d41eb..064ffcb 100644
> --- a/tests/all_egl.tests
> +++ b/tests/all_egl.tests
> @@ -22,3 +22,4 @@ create_context = Group();
>   egl['EGL_KHR_create_context'] = create_context
>   create_context['default major version'] = plain_test(['egl-create-context-default-major-version'])
>   create_context['default minor version'] = plain_test(['egl-create-context-default-minor-version'])
> +create_context['valid attribute empty'] = plain_test(['egl-create-context-valid-attribute-empty'])
> diff --git a/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt b/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
> index 0b81894..fe299eb 100644
> --- a/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
> +++ b/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
> @@ -13,5 +13,6 @@ link_libraries (
>
>   piglit_add_executable (egl-create-context-default-major-version default-major-version.c common.c)
>   piglit_add_executable (egl-create-context-default-minor-version default-minor-version.c common.c)
> +piglit_add_executable (egl-create-context-valid-attribute-empty valid-attribute-empty.c common.c)
>
>   # vim: ft=cmake:
> diff --git a/tests/egl/spec/egl_khr_create_context/valid-attribute-empty.c b/tests/egl/spec/egl_khr_create_context/valid-attribute-empty.c
> new file mode 100644
> index 0000000..1fd7a8f
> --- /dev/null
> +++ b/tests/egl/spec/egl_khr_create_context/valid-attribute-empty.c
> @@ -0,0 +1,81 @@
> +/* Copyright © 2012 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.
> + */
> +#include "piglit-util-gl-common.h"
> +#include "common.h"
> +
> +int main(int argc, char **argv)
> +{
> +	static const EGLint attribs[] = {
> +		EGL_NONE
> +	};
> +	const char *version_string;
> +	int major;
> +	int minor;
> +
> +	EGL_KHR_create_context_setup();
> +
> +	/* The EGL 1.4 spec says:
> +	 *
> +	 *     "attrib list may be NULL or empty (first attribute is EGL_NONE),
> +	 *     in which case all the attributes assume their default values"
> +	 *
> +	 * Specify an empty attrib_list and expect to receive an ES 1.x context.
> +	 */
> +	ctx = eglCreateContext(egl_dpy, cfg, EGL_NO_CONTEXT, attribs);
> +	if (ctx == EGL_NO_CONTEXT) {
> +		fprintf(stderr, "eglCreateContext() failed\n");
> +		piglit_report_result(PIGLIT_FAIL);

This will incorrectly fail if the implementation doesn't support ES 1.x. 
  This is improbable, but not impossible.  I think there should be a 
duplicate test that tries to create a desktop OpenGL 1.x context in this 
way.

Same comment applies to the next test in the series.

> +	}
> +
> +	if (!eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, ctx)) {
> +		fprintf(stderr, "eglMakeCurrent() failed\n");
> +		piglit_report_result(PIGLIT_FAIL);
> +	}
> +
> +	piglit_dispatch_default_init();
> +
> +	version_string = (char *) glGetString(GL_VERSION);
> +
> +	if (!parse_version_string(version_string, &major, &minor)) {
> +		fprintf(stderr,
> +			"Unable to parse GL version string: %s\n",
> +			version_string);
> +		piglit_report_result(PIGLIT_FAIL);
> +	}
> +
> +	if (major != 1 || (minor != 0 && minor != 1)) {
> +		fprintf(stderr,
> +			"Unexpected GLES version: %s\n"
> +			"Expected ES 1.0 or ES 1.1.\n",
> +			version_string);
> +		piglit_report_result(PIGLIT_FAIL);
> +	}
> +
> +	eglMakeCurrent(egl_dpy, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
> +	eglDestroyContext(egl_dpy, ctx);
> +
> +	EGL_KHR_create_context_teardown();
> +
> +	piglit_report_result(PIGLIT_PASS);
> +
> +	return EXIT_SUCCESS;
> +}
>




More information about the Piglit mailing list