aboutsummaryrefslogtreecommitdiff
path: root/tests/egl
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2012-08-15 15:43:51 -0700
committerMatt Turner <mattst88@gmail.com>2012-08-24 16:25:40 -0700
commita8818618f606e615674f976fd99cdc3dfa35d890 (patch)
treec71f7c8e6b9d11d7b6c045c71f13927aae16bc1e /tests/egl
parent165735b89d099f4ea4b635fc13b49c36e00bac6d (diff)
egl_khr_create_context: Verify that the attributes list can be empty for Desktop GL
Diffstat (limited to 'tests/egl')
-rw-r--r--tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt1
-rw-r--r--tests/egl/spec/egl_khr_create_context/valid-attribute-empty-gl.c88
2 files changed, 89 insertions, 0 deletions
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 3a815db9..18484faa 100644
--- a/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
+++ b/tests/egl/spec/egl_khr_create_context/CMakeLists.gl.txt
@@ -14,6 +14,7 @@ link_libraries (
piglit_add_executable (egl-create-context-default-major-version-gles default-major-version-gles.c common.c)
piglit_add_executable (egl-create-context-default-minor-version-gles default-minor-version-gles.c common.c)
piglit_add_executable (egl-create-context-valid-attribute-empty-gles valid-attribute-empty-gles.c common.c)
+piglit_add_executable (egl-create-context-valid-attribute-empty-gl valid-attribute-empty-gl.c common.c)
piglit_add_executable (egl-create-context-valid-attribute-null-gles valid-attribute-null-gles.c common.c)
piglit_add_executable (egl-create-context-invalid-gl-version invalid-gl-version.c common.c)
piglit_add_executable (egl-create-context-invalid-attribute-gl invalid-attribute-gl.c common.c)
diff --git a/tests/egl/spec/egl_khr_create_context/valid-attribute-empty-gl.c b/tests/egl/spec/egl_khr_create_context/valid-attribute-empty-gl.c
new file mode 100644
index 00000000..fafb01aa
--- /dev/null
+++ b/tests/egl/spec/egl_khr_create_context/valid-attribute-empty-gl.c
@@ -0,0 +1,88 @@
+/* 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;
+
+ if (!EGL_KHR_create_context_setup(EGL_OPENGL_BIT)) {
+ fprintf(stderr, "Desktop GL not available.\n");
+ piglit_report_result(PIGLIT_SKIP);
+ }
+ eglBindAPI(EGL_OPENGL_API);
+
+ /* 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);
+ }
+
+ 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 || major > 3) ||
+ (major == 1 && (minor < 2 || minor > 5)) ||
+ (major == 2 && (minor < 0 || minor > 1)) ||
+ (major == 3 && minor != 0)) {
+ fprintf(stderr,
+ "Unexpected Desktop GL version: %s\n"
+ "Expected GL 1.2-1.5, 2.0, 2.1, or 3.0.\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;
+}