1 /* Copyright © 2013 Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a
4 * copy of this software and associated documentation files (the "Software"),
5 * to deal in the Software without restriction, including without limitation
6 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
7 * and/or sell copies of the Software, and to permit persons to whom the
8 * Software is furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice (including the next
11 * paragraph) shall be included in all copies or substantial portions of the
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * This test makes current a context, terminates the context's display, then
27 * unbinds the context. According to the EGL 1.4 spec (2011.04.06), Section
28 * 3.2 Initialization, no error should occur.
30 * EGLBoolean eglTerminate(EGLDisplay dpy);
32 * Termination marks all EGL-specific resources, such as contexts and
33 * surfaces, associated with the specified display for deletion. Handles
34 * to all such resources are invalid as soon as eglTerminate returns, but
35 * the dpy handle itself remains valid. [...] Applications should not try
36 * to perform useful work with such resources following eglTerminate; only
37 * eglMakeCurrent or eglReleaseThread should be called, to complete
38 * deletion of these resources.
40 * If contexts or surfaces created with respect to dpy are current (see
41 * section 3.7.3) to any thread, then they are not actually destroyed
42 * while they remain current. Such contexts and surfaces will be destroyed
43 * as soon as eglReleaseThread is called from the thread they are bound
44 * to, or eglMakeCurrent is called from that thread with the current
45 * rendering API (see section 3.7) set such that the current context is
52 #include "piglit-util-egl.h"
56 fprintf(stderr, "error: %s:%d: %s failed\n", __func__, __LINE__, msg); \
57 piglit_report_result(PIGLIT_FAIL); \
61 main(int argc
, char **argv
)
67 EGLint num_configs
= 0;
71 dpy
= eglGetDisplay(EGL_DEFAULT_DISPLAY
);
73 fail("eglGetDisplay(EGL_DEFAULT_DISPLAY) failed");
75 ok
= eglInitialize(dpy
, &major_version
, &minor_version
);
77 fail("eglInitialize() failed");
79 /* This test tries to be window-system independent, and so avoids
80 * creating any EGLSurface. To call eglMakeCurrent() without a surface
81 * requires EGL_KHR_surfaceless_context.
83 piglit_require_egl_extension(dpy
, "EGL_KHR_surfaceless_context");
85 ok
= eglChooseConfig(dpy
, NULL
, &config
, 1, &num_configs
);
87 fail("eglChooseConfig() failed");
89 fail("eglChooseConfig() returned no configs\n");
91 ctx
= eglCreateContext(dpy
, config
, EGL_NO_CONTEXT
, NULL
);
93 fail("eglCreateContext() failed");
95 ok
= eglMakeCurrent(dpy
, NULL
, NULL
, ctx
);
97 fail("eglMakeCurrent()");
99 ok
= eglTerminate(dpy
);
101 fail("eglTerminate()");
103 /* Unbind the context. */
104 ok
= eglMakeCurrent(dpy
, NULL
, NULL
, NULL
);
106 fail("eglMakeCurrent(ctx=NULL)");
108 piglit_report_result(PIGLIT_PASS
);