[Piglit] [PATCH 3/3] egl_ext_client_extensions: Add initial tests

Matt Turner mattst88 at gmail.com
Tue Dec 3 19:42:27 PST 2013


On Tue, Nov 26, 2013 at 12:46 PM, Chad Versace
<chad.versace at linux.intel.com> wrote:
> Add tests for the conformance tests listed in the
> EGL_EXT_client_extensions spec.
>
> Signed-off-by: Chad Versace <chad.versace at linux.intel.com>
> ---
>  tests/all.tests                                    |   5 +
>  tests/egl/spec/CMakeLists.txt                      |   1 +
>  .../CMakeLists.no_api.txt                          |   7 +
>  .../spec/egl_ext_client_extensions/CMakeLists.txt  |   1 +
>  .../egl_ext_client_extensions.c                    | 227 +++++++++++++++++++++
>  5 files changed, 241 insertions(+)
>  create mode 100644 tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt
>  create mode 100644 tests/egl/spec/egl_ext_client_extensions/CMakeLists.txt
>  create mode 100644 tests/egl/spec/egl_ext_client_extensions/egl_ext_client_extensions.c
>
> diff --git a/tests/all.tests b/tests/all.tests
> index cdaf1d5..f465fc5 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -3317,6 +3317,11 @@ egl_khr_create_context['verify GL flavor'] = plain_test('egl-create-context-veri
>  for api in ('gl', 'gles1', 'gles2', 'gles3'):
>      egl_khr_create_context['valid debug flag ' + api] = plain_test('egl-create-context-valid-flag-debug ' + api)
>
> +egl_ext_client_extensions = Group()
> +spec['EGL_EXT_client_extensions'] = egl_ext_client_extensions
> +for i in [1, 2, 3]:
> +    egl_ext_client_extensions['conformance test {0}'.format(i)] = concurrent_test('egl_ext_client_extensions {0}'.format(i))
> +
>  gles20 = Group()
>  spec['!OpenGL ES 2.0'] = gles20
>  gles20['glsl-fs-pointcoord'] = concurrent_test('glsl-fs-pointcoord_gles2')
> diff --git a/tests/egl/spec/CMakeLists.txt b/tests/egl/spec/CMakeLists.txt
> index 12bb419..30e9900 100644
> --- a/tests/egl/spec/CMakeLists.txt
> +++ b/tests/egl/spec/CMakeLists.txt
> @@ -1,2 +1,3 @@
>  add_subdirectory (egl-1.4)
> +add_subdirectory (egl_ext_client_extensions)
>  add_subdirectory (egl_khr_create_context)
> diff --git a/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt b/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt
> new file mode 100644
> index 0000000..3c3fe36
> --- /dev/null
> +++ b/tests/egl/spec/egl_ext_client_extensions/CMakeLists.no_api.txt
> @@ -0,0 +1,7 @@
> +link_libraries(
> +       piglitutil
> +)
> +
> +piglit_add_executable(egl_ext_client_extensions egl_ext_client_extensions.c)
> +
> +# vim: ft=cmake:
> diff --git a/tests/egl/spec/egl_ext_client_extensions/CMakeLists.txt b/tests/egl/spec/egl_ext_client_extensions/CMakeLists.txt
> new file mode 100644
> index 0000000..144a306
> --- /dev/null
> +++ b/tests/egl/spec/egl_ext_client_extensions/CMakeLists.txt
> @@ -0,0 +1 @@
> +piglit_include_target_api()
> diff --git a/tests/egl/spec/egl_ext_client_extensions/egl_ext_client_extensions.c b/tests/egl/spec/egl_ext_client_extensions/egl_ext_client_extensions.c
> new file mode 100644
> index 0000000..5702686
> --- /dev/null
> +++ b/tests/egl/spec/egl_ext_client_extensions/egl_ext_client_extensions.c
> @@ -0,0 +1,227 @@
> +/* Copyright 2013 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
> + * \brief Tests for EGL_EXT_client_extensions.
> + */
> +
> +#include "piglit-util-egl.h"
> +
> +static const char *prog_name;
> +
> +static void
> +usage_error(void)
> +{
> +       printf("%s: usage_error\n", prog_name);
> +       printf("usage: %s 1|2|3\n", prog_name);
> +       piglit_report_result(PIGLIT_FAIL);
> +}
> +
> +/**
> + * Conformance test #1 in the EGL_EXT_client_extensions spec:
> + *
> + *     1. Before any call to eglGetDisplay, call `eglQueryString(EGL_NO_DISPLAY,
> + *        EGL_EXTENSIONS)`. Verify that either
> + *
> + *          a. The call returns NULL and generates EGL_BAD_DISPLAY.
> + *          b. The call returns an extension string that contains, at a minimum,
> + *             this extension and generates no error.
> + */
> +static void
> +test_1(void)
> +{
> +       enum piglit_result result = PIGLIT_PASS;
> +       const char *client_extensions;
> +
> +       printf("Making process's first EGL call, "
> +              "eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) ...\n");

Don't the printfs cause piglit summary generation to interpret passes
as warns? Or maybe it's just fprintf to stderr.

> +       client_extensions = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
> +
> +       if (client_extensions == NULL) {
> +               printf("Returned NULL\n");
> +               if (piglit_check_egl_error(EGL_BAD_DISPLAY)) {
> +                       printf("And correctly emitted EGL_BAD_DISPLAY\n");
> +               } else {
> +                       printf("But did not emit EGL_BAD_DISPLAY\n");
> +                       result = PIGLIT_FAIL;
> +               }
> +       } else {
> +               printf("Returned a non-null extension string\n");
> +
> +               if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +                       result = PIGLIT_FAIL;
> +               }
> +
> +               if (!piglit_is_extension_in_string(client_extensions,
> +                                                  "EGL_EXT_client_extensions")) {
> +                       printf("But it does not contain "
> +                              "EGL_EXT_client_extensions\n");
> +                       result = PIGLIT_FAIL;
> +               } else {
> +                       printf("And contains EGL_EXT_client_extensions "
> +                              "as expected\n");
> +               }
> +       }
> +
> +       piglit_report_result(result);
> +}
> +
> +/**
> + * Conformance test #2 in the EGL_EXT_client_extensions spec:
> + *
> + *    2. Obtain a display with eglGetDisplay but do not initialize it. Verity

Verify

> + *       that passing the uninitialized display to `eglQueryString(dpy,
> + *       EGL_EXTENSIONS)` returns NULL and generates EGL_NOT_INITIALIZED.
> + */
> +static void
> +test_2(void)
> +{
> +       enum piglit_result result = PIGLIT_PASS;
> +       EGLDisplay dpy;
> +       const char *display_extensions;
> +
> +       dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
> +       if (!dpy) {
> +               printf("Failed to get default display. Skipping.n");
> +               piglit_report_result(PIGLIT_SKIP);
> +       }
> +
> +       printf("Calling eglQueryString(dpy, EGL_EXTENSIONS) with an "
> +              "uninitialized display...\n");
> +       display_extensions = eglQueryString(dpy, EGL_EXTENSIONS);
> +
> +       if (display_extensions == NULL) {
> +               printf("Correctly returned null extension string\n");
> +       } else {
> +               printf("Did not return null extension string\n");
> +               result = PIGLIT_FAIL;
> +       }
> +
> +       if (!piglit_check_egl_error(EGL_NOT_INITIALIZED)) {
> +               result = PIGLIT_FAIL;
> +       }
> +
> +       piglit_report_result(result);
> +}
> +
> +/**
> + * Conformance test #3 in the EGL_EXT_client_extensions spec:
> + *
> + *  3. Obtain a list of display extensions by calling `eglQueryString(dpy,
> + *     EGL_EXTENSIONS)` on an initialized display. Obtain the list of client
> + *     extensions by calling `eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS)`.
> + *     If both calls succeed, verify the two lists are disjoint.
> + *
> + */
> +static void
> +test_3(void)
> +{
> +       enum piglit_result result = PIGLIT_PASS;
> +       EGLDisplay dpy;
> +       EGLint major_version, minor_version;
> +       const char *display_ext_string;
> +       const char *client_ext_string;
> +       const char **display_ext_array;
> +       const char **client_ext_array;
> +       int i, j;
> +
> +       dpy = eglGetDisplay(EGL_DEFAULT_DISPLAY);
> +       if (!dpy) {
> +               printf("Failed to get default display. Skipping.\n");
> +               piglit_report_result(PIGLIT_SKIP);
> +       }
> +       if (!eglInitialize(dpy, &major_version, &minor_version)) {
> +               printf("Failed to initialize default display\n");
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +
> +       display_ext_string = eglQueryString(dpy, EGL_EXTENSIONS);
> +       if (!piglit_check_egl_error(EGL_SUCCESS)) {
> +               printf("eglQueryString(EGL_EXTENSIONS) failed on default "
> +                      "display\n");
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +       if (!display_ext_string) {
> +               printf("eglQueryString(EGL_EXTENSIONS) returned null for "
> +                      "default display\n");
> +               piglit_report_result(PIGLIT_FAIL);
> +       }
> +
> +       client_ext_string = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
> +       if (!client_ext_string) {
> +               if (piglit_check_egl_error(EGL_BAD_DISPLAY)) {
> +                       printf("eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) "
> +                              "returned null. Skipping.\n");
> +                       piglit_report_result(PIGLIT_SKIP);
> +               } else {
> +                       printf("eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS) "
> +                              "returned null but did not emit "
> +                              "EGL_BAD_DISPLAY\n");
> +                       piglit_report_result(PIGLIT_FAIL);
> +               }
> +
> +               abort();
> +       }
> +
> +       display_ext_array = piglit_split_string_to_array(display_ext_string, " ");
> +       client_ext_array = piglit_split_string_to_array(client_ext_string, " ");
> +
> +       /* Check that the two sets of extensions are disjoint. */
> +       for (i = 0; display_ext_array[i] != NULL; ++i) {
> +               const char *display_ext = display_ext_array[i];
> +               for (j = 0; client_ext_array[j] != NULL; ++j) {
> +                       const char *client_ext = client_ext_array[j];
> +                       if (strcmp(display_ext, client_ext) == 0) {
> +                               printf("%s is listed both as a client and "
> +                                      "display extension\n", display_ext);
> +                               result = PIGLIT_FAIL;
> +                       }
> +               }
> +       }
> +
> +       piglit_report_result(result);
> +}
> +
> +int
> +main(int argc, char **argv)
> +{
> +       prog_name = argv[0];
> +
> +       piglit_strip_arg(&argc, argv, "-auto");
> +       piglit_strip_arg(&argc, argv, "-fbo");
> +
> +       if (argc != 2)
> +               usage_error();
> +
> +       if (strcmp(argv[1], "1") == 0) {
> +               test_1();
> +       } else if (strcmp(argv[1], "2") == 0) {
> +               test_2();
> +       } else if (strcmp(argv[1], "3") == 0) {
> +               test_3();
> +       } else {
> +               usage_error();
> +       }
> +
> +       abort();
> +}
> --
> 1.8.4

All three are

Reviewed-by: Matt Turner <mattst88 at gmail.com>


More information about the Piglit mailing list