Signed-off-by: Tapani Pälli <tapani.pa...@intel.com>
---

I had here also shader compilation, and checks that get and set were
called when same same shader was compiled and linked again but I'm not
sure if that can be required from the driver, driver might just skip
cache if it wants. So, here's just the API tests for getting entrypoint
and different error cases when calling it.


 tests/all.py                   |   1 +
 tests/egl/CMakeLists.gles2.txt |  18 +++++++
 tests/egl/egl-blob-cache.c     | 109 +++++++++++++++++++++++++++++++++++++++++
 3 files changed, 128 insertions(+)
 create mode 100644 tests/egl/CMakeLists.gles2.txt
 create mode 100644 tests/egl/egl-blob-cache.c

diff --git a/tests/all.py b/tests/all.py
index 67e78c58c..3a769e6ab 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -4456,6 +4456,7 @@ with profile.test_list.group_manager(
       run_concurrent=False)
     g(['egl-invalid-attr'])
     g(['egl-context-priority'])
+    g(['egl-blob-cache'])
 
 with profile.test_list.group_manager(
         PiglitGLTest,
diff --git a/tests/egl/CMakeLists.gles2.txt b/tests/egl/CMakeLists.gles2.txt
new file mode 100644
index 000000000..f6e69d9b0
--- /dev/null
+++ b/tests/egl/CMakeLists.gles2.txt
@@ -0,0 +1,18 @@
+
+include_directories(
+       ${GLEXT_INCLUDE_DIR}
+       ${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+       piglitutil_${piglit_target_api}
+       ${EGL_LDFLAGS}
+       ${OPENGL_gl_LIBRARY}
+)
+
+IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+       piglit_add_executable (egl-blob-cache egl-blob-cache.c)
+       target_link_libraries(egl-blob-cache pthread)
+ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
+
+# vim: ft=cmake:
diff --git a/tests/egl/egl-blob-cache.c b/tests/egl/egl-blob-cache.c
new file mode 100644
index 000000000..81af606fe
--- /dev/null
+++ b/tests/egl/egl-blob-cache.c
@@ -0,0 +1,109 @@
+/*
+ * Copyright © 2017 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-egl.h"
+#include "piglit-util-gl.h"
+
+/**
+ * @file egl-blob-cache.c
+ *
+ * EGL API tests for EGL_ANDROID_blob_cache extension:
+ * 
https://www.khronos.org/registry/EGL/extensions/ANDROID/EGL_ANDROID_blob_cache.txt
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+       config.supports_gl_es_version = 20;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+/* dummy */
+enum piglit_result
+piglit_display(void)
+{
+       return PIGLIT_FAIL;
+}
+
+static void
+set_blob(const void* key, EGLsizeiANDROID keySize,
+        const void* value, EGLsizeiANDROID valueSize)
+{
+}
+
+static EGLsizeiANDROID
+get_blob(const void* key, EGLsizeiANDROID keySize, void* value,
+        EGLsizeiANDROID valueSize)
+{
+       return 0;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+       EGLint major, minor;
+       EGLDisplay dpy;
+
+       /* Require EGL_MESA_platform_surfaceless extension. */
+       const char *exts = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
+       if (!strstr(exts, "EGL_MESA_platform_surfaceless"))
+               piglit_report_result(PIGLIT_SKIP);
+
+       dpy = piglit_egl_get_default_display(EGL_PLATFORM_SURFACELESS_MESA);
+
+       if (!eglInitialize(dpy, &major, &minor))
+               piglit_report_result(PIGLIT_FAIL);
+
+       piglit_require_egl_extension(dpy, "EGL_MESA_configless_context");
+       piglit_require_egl_extension(dpy, "EGL_ANDROID_blob_cache");
+
+       PFNEGLSETBLOBCACHEFUNCSANDROIDPROC peglSetBlobCacheFuncs =
+               (PFNEGLSETBLOBCACHEFUNCSANDROIDPROC)
+                       eglGetProcAddress ("eglSetBlobCacheFuncsANDROID");
+
+       if (!peglSetBlobCacheFuncs)
+               piglit_report_result(PIGLIT_FAIL);
+
+#define EXPECT(x) if (!piglit_check_egl_error(x)) 
piglit_report_result(PIGLIT_FAIL);
+
+       /* Check error cases for passing NULL. */
+       peglSetBlobCacheFuncs(dpy, NULL, NULL);
+       EXPECT(EGL_BAD_PARAMETER);
+
+       peglSetBlobCacheFuncs(dpy, set_blob, NULL);
+       EXPECT(EGL_BAD_PARAMETER);
+
+       peglSetBlobCacheFuncs(dpy, NULL, get_blob);
+       EXPECT(EGL_BAD_PARAMETER);
+
+       /* Successful call. */
+       peglSetBlobCacheFuncs(dpy, set_blob, get_blob);
+       EXPECT(EGL_SUCCESS);
+
+       /* Failure, functions already set. */
+       peglSetBlobCacheFuncs(dpy, set_blob, get_blob);
+       EXPECT(EGL_BAD_PARAMETER);
+
+#undef EXPECT
+
+       piglit_report_result(PIGLIT_PASS);
+}
-- 
2.14.3

_______________________________________________
Piglit mailing list
Piglit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to