[cairo] [PATCH] test: Add test oversized egl surfaces
RAVI NANJUNDAPPA
nravi.n at samsung.com
Wed Sep 17 21:40:37 PDT 2014
Thank you Bryce for the review comments.
PFA the new version of the patch incorporated with the review comments.
Thanks and Best Regards,
N Ravi
PS: Since the patch is still in the utf8 format, am sending the patch as an
attachment.
> -----Original Message-----
> From: Bryce Harrington [mailto:bryce at osg.samsung.com]
> Sent: Thursday, September 18, 2014 2:36 AM
> To: RAVI NANJUNDAPPA
> Cc: cairo at cairographics.org
> Subject: Re: [cairo] [PATCH] test: Add test oversized egl surfaces
>
> On Tue, Sep 16, 2014 at 12:33:00PM +0530, RAVI NANJUNDAPPA wrote:
> > Hi,
> >
> > Am facing some problem with UTF while sending the patch inline. I
> > guess that's one of the reason why that patch was not be displayed in
> > the mailing list as well.
> > So attaching the patch here for better clarity.
>
> One thing I've learned doing egl tests is that the error handling can
> sometimes hang EGL if the test isn't aggressive enough in letting go of
> everything.
>
> So one thing I'd suggest is everywhere that you are returning early in
> preamble(), to instead do 'goto CLEANUP;' and then at the end of the
routine
> have it go through all of the cleanup logic. Here's what I arrived at
doing for
> caskbench:
>
>
> void destroyEGLContextAndWindow (egl_state_t *state) {
> {
> if (state->egl_display) {
> eglMakeCurrent (state->egl_display, EGL_NO_SURFACE,
> EGL_NO_SURFACE, EGL_NO_CONTEXT);
> eglDestroyContext (state->egl_display, state->egl_context);
> eglDestroySurface (state->egl_display, state->egl_surface);
> state->egl_context = EGL_NO_CONTEXT;
> state->egl_surface = EGL_NO_SURFACE;
> eglTerminate (state->egl_display);
> }
>
> if (state->dpy) {
> XUnmapWindow (state->dpy, state->window);
> XDestroyWindow (state->dpy, state->window);
> XCloseDisplay (state->dpy);
> }
> }
>
> You have local variables rather than tracking things in a state struct,
> so you can simplify this down further.
>
> (If we add more EGL testing in the future, it might be useful to use
> separate create/destroy routines with a state structure, as those
> routines can then be shared across tests.)
>
> Aside from the cleanup logic, the patch looks good to me.
>
> Bryce
>
> > > -----Original Message-----
> > > From: cairo [mailto:cairo-bounces at cairographics.org] On Behalf Of RAVI
> > > NANJUNDAPPA
> > > Sent: Tuesday, September 16, 2014 12:00 PM
> > > To: cairo at cairographics.org
> > > Subject: Re: [cairo] [PATCH] test: Add test oversized egl surfaces
> > >
> > > Hi,
> > >
> > > I've referred test/gl-oversized-surface.c file and wrote this new
> > test/egl-
> > > oversized-surface.c to handle the egl surfaces.
> > > Please let me know if the banner needs to modified.
> > >
> > > Thanks and Best Regards,
> > > N Ravi
> > >
> > > > -----Original Message-----
> > > > From: Ravi Nanjundappa [mailto:nravi.n at samsung.com]
> > > > Sent: Tuesday, September 16, 2014 11:52 AM
> > > > To: cairo at cairographics.org
> > > > Cc: Ravi Nanjundappa
> > > > Subject: [PATCH] test: Add test oversized egl surfaces
> > > >
> > > > This test exercises error scenario when creating over sized egl
> > > > surface
> > > that is
> > > > larger than maximum framebuffer or texture dimensions of the context
> > > >
> > > > Signed-off-by: Ravi Nanjundappa <nravi.n at samsung.com>
> > > > ---
> > > > test/Makefile.am | 4 ++
> > > > test/Makefile.sources | 3 ++
> > > > test/egl-oversized-surface.c | 112
> > > > ++++++++++++++++++++++++++++++++++++++++++
> > > > 3 files changed, 119 insertions(+)
> > > > create mode 100644 test/egl-oversized-surface.c
> > > >
> > > > diff --git a/test/Makefile.am b/test/Makefile.am index
> > > > 81c50e6..950629b
> > > > 100644
> > > > --- a/test/Makefile.am
> > > > +++ b/test/Makefile.am
> > > > @@ -20,6 +20,10 @@ if CAIRO_HAS_GL_SURFACE test_sources +=
> > > > $(gl_surface_test_sources) endif
> > > >
> > > > +if CAIRO_HAS_EGL_FUNCTIONS
> > > > +test_sources += $(egl_surface_test_sources) endif
> > > > +
> > > > # Need to add quartz-surface-source
> > > > if CAIRO_HAS_QUARTZ_SURFACE
> > > > test_sources += $(quartz_surface_test_sources) diff --git
> > > > a/test/Makefile.sources b/test/Makefile.sources index
> 916d91a..689645c
> > > > 100644
> > > > --- a/test/Makefile.sources
> > > > +++ b/test/Makefile.sources
> > > > @@ -401,6 +401,9 @@ gl_surface_test_sources = \
> > > > gl-oversized-surface.c \
> > > > gl-surface-source.c
> > > >
> > > > +egl_surface_test_sources = \
> > > > + egl-oversized-surface.c
> > > > +
> > > > quartz_surface_test_sources = quartz-surface-source.c
> > > >
> > > > pdf_surface_test_sources = \
> > > > diff --git a/test/egl-oversized-surface.c
> > > > b/test/egl-oversized-surface.c
> > > new
> > > > file mode 100644 index 0000000..f946da6
> > > > --- /dev/null
> > > > +++ b/test/egl-oversized-surface.c
> > > > @@ -0,0 +1,112 @@
> > > > +/*
> > > > + * Copyright © 2014 Samsung Electronics
> > > > + *
> > > > + * 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 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.
> > > > + *
> > > > + * Author: Ravi Nanjundappa <nravi.n at samsung.com> */
> > > > +
> > > > +/*
> > > > + * This test exercises error scenario for over sized egl surface
> > > > + *
> > > > + */
> > > > +
> > > > +#include "cairo-test.h"
> > > > +#include <cairo-gl.h>
> > > > +#include <assert.h>
> > > > +#include <limits.h>
> > > > +
> > > > +static cairo_test_status_t
> > > > +preamble (cairo_test_context_t *test_ctx) {
> > > > + EGLint rgba_attribs[] = {
> > > > + EGL_RED_SIZE, 8,
> > > > + EGL_GREEN_SIZE, 8,
> > > > + EGL_BLUE_SIZE, 8,
> > > > + EGL_ALPHA_SIZE, 8,
> > > > + EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,
> > > > +#if CAIRO_HAS_GL_SURFACE
> > > > + EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, #elif
> > > CAIRO_HAS_GLESV2_SURFACE
> > > > + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, #endif
> > > > + EGL_NONE
> > > > + };
> > > > + const EGLint ctx_attribs[] = {
> > > > +#if CAIRO_HAS_GLESV2_SURFACE
> > > > + EGL_CONTEXT_CLIENT_VERSION, 2,
> > > > +#endif
> > > > + EGL_NONE
> > > > + };
> > > > +
> > > > + EGLDisplay dpy;
> > > > + EGLContext ctx;
> > > > + EGLConfig config;
> > > > + EGLint numConfigs;
> > > > + int major, minor;
> > > > + cairo_device_t *device;
> > > > + cairo_surface_t *oversized_surface;
> > > > + cairo_test_status_t test_status = CAIRO_TEST_SUCCESS;
> > > > +
> > > > + dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);
> > > > + if (! eglInitialize (dpy, &major, &minor)) {
> > > > + return CAIRO_TEST_UNTESTED;
> > > > + }
> > > > +
> > > > + eglChooseConfig (dpy, rgba_attribs, &config, 1, &numConfigs);
> > > > + if (numConfigs == 0) {
> > > > + return CAIRO_TEST_UNTESTED;
> > > > + }
> > > > +
> > > > +#if CAIRO_HAS_GL_SURFACE
> > > > + eglBindAPI (EGL_OPENGL_API);
> > > > +#elif CAIRO_HAS_GLESV2_SURFACE
> > > > + eglBindAPI (EGL_OPENGL_ES_API);
> > > > +#endif
> > > > +
> > > > + ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT,
> > > > + ctx_attribs);
> > > > + if (ctx == EGL_NO_CONTEXT) {
> > > > + eglTerminate (dpy);
> > > > + return CAIRO_TEST_UNTESTED;
> > > > + }
> > > > +
> > > > + device = cairo_egl_device_create (dpy, ctx);
> > > > +
> > > > + oversized_surface = cairo_gl_surface_create (device,
> > > > CAIRO_CONTENT_COLOR_ALPHA, INT_MAX, INT_MAX);
> > > > + if (cairo_surface_status (oversized_surface) !=
> > > > CAIRO_STATUS_INVALID_SIZE)
> > > > + test_status = CAIRO_TEST_FAILURE;
> > > > +
> > > > + cairo_device_destroy (device);
> > > > +
> > > > + eglDestroyContext (dpy, ctx);
> > > > + eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
> > > > EGL_NO_CONTEXT);
> > > > + eglTerminate (dpy);
> > > > +
> > > > + return test_status;
> > > > +}
> > > > +
> > > > +CAIRO_TEST (egl_oversized_surface,
> > > > + "Test that creating a surface beyond texture limits
results in
> > > an
> > > > error surface",
> > > > + "egl", /* keywords */
> > > > + NULL, /* requirements */
> > > > + 0, 0,
> > > > + preamble, NULL)
> > > > --
> > > > 1.7.9.5
> > >
> > > --
> > > cairo mailing list
> > > cairo at cairographics.org
> > > http://lists.cairographics.org/mailman/listinfo/cairo
>
> > [0;0m>From 2387f10a09086ca292781e2c43649a4ef162cafe Mon Sep 17
> 00:00:00 2001[0;0m
> > [0;0mFrom: Ravi Nanjundappa <nravi.n at samsung.com>[0;0m
> > [0;0mDate: Tue, 16 Sep 2014 10:18:02 +0530[0;0m
> > [0;0mSubject: [PATCH] test: Add test oversized egl surfaces[0;0m
> > [0;0m[0;0m
> > [0;0mThis test exercises error scenario when creating over sized egl
> surface[0;0m
> > [0;0mthat is larger than maximum framebuffer or texture dimensions of
> the[0;0m
> > [0;0mcontext[0;0m
> > [0;0m[0;0m
> > [0;0mSigned-off-by: Ravi Nanjundappa <nravi.n at samsung.com>[0;0m
> > [0;32m---[0;0m
> > [0;0m test/Makefile.am | 4 ++[0;0m
> > [0;0m test/Makefile.sources | 3 ++[0;0m
> > [0;0m test/egl-oversized-surface.c | 112
> ++++++++++++++++++++++++++++++++++++++++++[0;0m
> > [0;0m 3 files changed, 119 insertions(+)[0;0m
> > [0;0m create mode 100644 test/egl-oversized-surface.c[0;0m
> > [0;0m[0;0m
> > [0;34mdiff --git a/test/Makefile.am b/test/Makefile.am[0;0m
> > [0;0mindex 81c50e6..950629b 100644[0;0m
> > [0;32m--- a/test/Makefile.am[0;0m
> > [1;32m+++ b/test/Makefile.am[0;0m
> > [1;34m@@ -20,6 +20,10 @@ if CAIRO_HAS_GL_SURFACE[0;0m
> > [0;0m test_sources += $(gl_surface_test_sources)[0;0m
> > [0;0m endif[0;0m
> > [0;0m [0;0m
> > [1;32m+if CAIRO_HAS_EGL_FUNCTIONS[0;0m
> > [1;32m+test_sources += $(egl_surface_test_sources)[0;0m
> > [1;32m+endif[0;0m
> > [1;32m+[0;0m
> > [0;0m # Need to add quartz-surface-source[0;0m
> > [0;0m if CAIRO_HAS_QUARTZ_SURFACE[0;0m
> > [0;0m test_sources += $(quartz_surface_test_sources)[0;0m
> > [0;34mdiff --git a/test/Makefile.sources b/test/Makefile.sources[0;0m
> > [0;0mindex 916d91a..689645c 100644[0;0m
> > [0;32m--- a/test/Makefile.sources[0;0m
> > [1;32m+++ b/test/Makefile.sources[0;0m
> > [1;34m@@ -401,6 +401,9 @@ gl_surface_test_sources = \[0;0m
> > [0;0m gl-oversized-surface.c \[0;0m
> > [0;0m gl-surface-source.c[0;0m
> > [0;0m [0;0m
> > [1;32m+egl_surface_test_sources = \[0;0m
> > [1;32m+ egl-oversized-surface.c[0;0m
> > [1;32m+[0;0m
> > [0;0m quartz_surface_test_sources = quartz-surface-source.c[0;0m
> > [0;0m [0;0m
> > [0;0m pdf_surface_test_sources = \[0;0m
> > [0;34mdiff --git a/test/egl-oversized-surface.c b/test/egl-oversized-
> surface.c[0;0m
> > [0;0mnew file mode 100644[0;0m
> > [0;0mindex 0000000..f946da6[0;0m
> > [0;32m--- /dev/null[0;0m
> > [1;32m+++ b/test/egl-oversized-surface.c[0;0m
> > [1;34m@@ -0,0 +1,112 @@[0;0m
> > [1;32m+/*[0;0m
> > [1;32m+ * Copyright © 2014 Samsung Electronics[0;0m
> > [1;32m+ *[0;0m
> > [1;32m+ * Permission is hereby granted, free of charge, to any
> person[0;0m
> > [1;32m+ * obtaining a copy of this software and associated
> documentation[0;0m
> > [1;32m+ * files (the "Software"), to deal in the Software without[0;0m
> > [1;32m+ * restriction, including without limitation the rights to use,
> copy,[0;0m
> > [1;32m+ * modify, merge, publish, distribute, sublicense, and/or sell
> copies[0;0m
> > [1;32m+ * of the Software, and to permit persons to whom the Software
> is[0;0m
> > [1;32m+ * furnished to do so, subject to the following
conditions:[0;0m
> > [1;32m+ *[0;0m
> > [1;32m+ * The above copyright notice and this permission notice shall
> be[0;0m
> > [1;32m+ * included in all copies or substantial portions of the
> Software.[0;0m
> > [1;32m+ *[0;0m
> > [1;32m+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
> ANY KIND,[0;0m
> > [1;32m+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
> WARRANTIES OF[0;0m
> > [1;32m+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
> AND[0;0m
> > [1;32m+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
> COPYRIGHT HOLDERS[0;0m
> > [1;32m+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
> WHETHER IN AN[0;0m
> > [1;32m+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN[0;0m
> > [1;32m+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
> DEALINGS IN THE[0;0m
> > [1;32m+ * SOFTWARE.[0;0m
> > [1;32m+ *[0;0m
> > [1;32m+ * Author: Ravi Nanjundappa <nravi.n at samsung.com>[0;0m
> > [1;32m+ */[0;0m
> > [1;32m+[0;0m
> > [1;32m+/*[0;0m
> > [1;32m+ * This test exercises error scenario for over sized egl
> surface[0;0m
> > [1;32m+ *[0;0m
> > [1;32m+ */[0;0m
> > [1;32m+[0;0m
> > [1;32m+#include "cairo-test.h"[0;0m
> > [1;32m+#include <cairo-gl.h>[0;0m
> > [1;32m+#include <assert.h>[0;0m
> > [1;32m+#include <limits.h>[0;0m
> > [1;32m+[0;0m
> > [1;32m+static cairo_test_status_t[0;0m
> > [1;32m+preamble (cairo_test_context_t *test_ctx)[0;0m
> > [1;32m+{[0;0m
> > [1;32m+ EGLint rgba_attribs[] = {[0;0m
> > [1;32m+ EGL_RED_SIZE, 8,[0;0m
> > [1;32m+ EGL_GREEN_SIZE, 8,[0;0m
> > [1;32m+ EGL_BLUE_SIZE, 8,[0;0m
> > [1;32m+ EGL_ALPHA_SIZE, 8,[0;0m
> > [1;32m+ EGL_SURFACE_TYPE, EGL_PBUFFER_BIT,[0;0m
> > [1;32m+#if CAIRO_HAS_GL_SURFACE[0;0m
> > [1;32m+ EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT,[0;0m
> > [1;32m+#elif CAIRO_HAS_GLESV2_SURFACE[0;0m
> > [1;32m+ EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT,[0;0m
> > [1;32m+#endif[0;0m
> > [1;32m+ EGL_NONE[0;0m
> > [1;32m+ };[0;0m
> > [1;32m+ const EGLint ctx_attribs[] = {[0;0m
> > [1;32m+#if CAIRO_HAS_GLESV2_SURFACE[0;0m
> > [1;32m+ EGL_CONTEXT_CLIENT_VERSION, 2,[0;0m
> > [1;32m+#endif[0;0m
> > [1;32m+ EGL_NONE[0;0m
> > [1;32m+ };[0;0m
> > [1;32m+[0;0m
> > [1;32m+ EGLDisplay dpy;[0;0m
> > [1;32m+ EGLContext ctx;[0;0m
> > [1;32m+ EGLConfig config;[0;0m
> > [1;32m+ EGLint numConfigs;[0;0m
> > [1;32m+ int major, minor;[0;0m
> > [1;32m+ cairo_device_t *device;[0;0m
> > [1;32m+ cairo_surface_t *oversized_surface;[0;0m
> > [1;32m+ cairo_test_status_t test_status = CAIRO_TEST_SUCCESS;[0;0m
> > [1;32m+[0;0m
> > [1;32m+ dpy = eglGetDisplay (EGL_DEFAULT_DISPLAY);[0;0m
> > [1;32m+ if (! eglInitialize (dpy, &major, &minor)) {[0;0m
> > [1;32m+ return CAIRO_TEST_UNTESTED;[0;0m
> > [1;32m+ }[0;0m
> > [1;32m+[0;0m
> > [1;32m+ eglChooseConfig (dpy, rgba_attribs, &config, 1,
> &numConfigs);[0;0m
> > [1;32m+ if (numConfigs == 0) {[0;0m
> > [1;32m+ return CAIRO_TEST_UNTESTED;[0;0m
> > [1;32m+ }[0;0m
> > [1;32m+[0;0m
> > [1;32m+#if CAIRO_HAS_GL_SURFACE[0;0m
> > [1;32m+ eglBindAPI (EGL_OPENGL_API);[0;0m
> > [1;32m+#elif CAIRO_HAS_GLESV2_SURFACE[0;0m
> > [1;32m+ eglBindAPI (EGL_OPENGL_ES_API);[0;0m
> > [1;32m+#endif[0;0m
> > [1;32m+[0;0m
> > [1;32m+ ctx = eglCreateContext (dpy, config, EGL_NO_CONTEXT,[0;0m
> > [1;32m+ ctx_attribs);[0;0m
> > [1;32m+ if (ctx == EGL_NO_CONTEXT) {[0;0m
> > [1;32m+ eglTerminate (dpy);[0;0m
> > [1;32m+ return CAIRO_TEST_UNTESTED;[0;0m
> > [1;32m+ }[0;0m
> > [1;32m+[0;0m
> > [1;32m+ device = cairo_egl_device_create (dpy, ctx);[0;0m
> > [1;32m+[0;0m
> > [1;32m+ oversized_surface = cairo_gl_surface_create (device,
> CAIRO_CONTENT_COLOR_ALPHA, INT_MAX, INT_MAX);[0;0m
> > [1;32m+ if (cairo_surface_status (oversized_surface) !=
> CAIRO_STATUS_INVALID_SIZE)[0;0m
> > [1;32m+ test_status = CAIRO_TEST_FAILURE;[0;0m
> > [1;32m+[0;0m
> > [1;32m+ cairo_device_destroy (device);[0;0m
> > [1;32m+[0;0m
> > [1;32m+ eglDestroyContext (dpy, ctx);[0;0m
> > [1;32m+ eglMakeCurrent (dpy, EGL_NO_SURFACE, EGL_NO_SURFACE,
> EGL_NO_CONTEXT);[0;0m
> > [1;32m+ eglTerminate (dpy);[0;0m
> > [1;32m+[0;0m
> > [1;32m+ return test_status;[0;0m
> > [1;32m+}[0;0m
> > [1;32m+[0;0m
> > [1;32m+CAIRO_TEST (egl_oversized_surface,[0;0m
> > [1;32m+ "Test that creating a surface beyond texture limits
results in
> an error surface",[0;0m
> > [1;32m+ "egl", /* keywords */[0;0m
> > [1;32m+ NULL, /* requirements */[0;0m
> > [1;32m+ 0, 0,[0;0m
> > [1;32m+ preamble, NULL)[0;0m
> > [0;32m-- [0;0m
> > [0;0m1.7.9.5[0;0m
> > [0;0m[0;0m
>
> > --
> > cairo mailing list
> > cairo at cairographics.org
> > http://lists.cairographics.org/mailman/listinfo/cairo
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-test-Add-test-oversized-egl-surfaces.patch
Type: application/octet-stream
Size: 5190 bytes
Desc: not available
URL: <http://lists.cairographics.org/archives/cairo/attachments/20140918/423b1e0f/attachment-0001.obj>
More information about the cairo
mailing list