[Piglit] [PATCH 4/6] ext_image_dma_buf_import: test for failure with invalid query parameters
Varad Gautam
varadgautam at gmail.com
Fri Nov 25 09:35:17 UTC 2016
From: Varad Gautam <varad.gautam at collabora.com>
test for eglQueryDmaBufFormatsEXT and eglQueryDmaBufModifiersEXT failure
conditions.
Signed-off-by: Varad Gautam <varad.gautam at collabora.com>
---
tests/all.py | 1 +
.../ext_image_dma_buf_import/CMakeLists.gles2.txt | 1 +
.../invalid_query_params.c | 124 +++++++++++++++++++++
3 files changed, 126 insertions(+)
create mode 100644 tests/spec/ext_image_dma_buf_import/invalid_query_params.c
diff --git a/tests/all.py b/tests/all.py
index 30df61c..da84d34 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -3111,6 +3111,7 @@ with profile.test_list.group_manager(
g:
g(['ext_image_dma_buf_import-invalid_hints'], run_concurrent=False)
g(['ext_image_dma_buf_import-invalid_attributes'], run_concurrent=False)
+ g(['ext_image_dma_buf_import-invalid_query_params'], run_concurrent=False)
g(['ext_image_dma_buf_import-missing_attributes'], run_concurrent=False)
g(['ext_image_dma_buf_import-ownership_transfer'], run_concurrent=False)
g(['ext_image_dma_buf_import-intel_unsupported_format'],
diff --git a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
index 93f43fa..a3729fb 100644
--- a/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
+++ b/tests/spec/ext_image_dma_buf_import/CMakeLists.gles2.txt
@@ -21,6 +21,7 @@ if(PIGLIT_BUILD_DMA_BUF_TESTS)
piglit_add_executable(ext_image_dma_buf_import-sample_rgb sample_rgb.c sample_common.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-intel_external_sampler_with_dma_only intel_external_sampler_with_dma_only.c image_common.c)
piglit_add_executable(ext_image_dma_buf_import-transcode-nv12-as-r8-gr88 transcode-nv12-as-r8-gr88.c image_common.c)
+ piglit_add_executable(ext_image_dma_buf_import-invalid_query_params invalid_query_params.c sample_common.c image_common.c)
endif()
# vim: ft=cmake:
diff --git a/tests/spec/ext_image_dma_buf_import/invalid_query_params.c b/tests/spec/ext_image_dma_buf_import/invalid_query_params.c
new file mode 100644
index 0000000..2cd8d58
--- /dev/null
+++ b/tests/spec/ext_image_dma_buf_import/invalid_query_params.c
@@ -0,0 +1,124 @@
+/*
+ * Copyright © 2016 Collabora, Ltd.
+ *
+ * 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 "sample_common.h"
+#include "image_common.h"
+
+/*
+ * @file invalid_query_params.c
+ *
+ * test for error when invalid parameters are passed to
+ * eglQueryDmaBufFormatsEXT and eglQueryDmaBufModifiersEXT.
+ */
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_es_version = 20;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static bool
+test_invalid_params(EGLint valid_format)
+{
+ EGLDisplay egl_dpy = eglGetCurrentDisplay();
+ EGLBoolean ret = EGL_TRUE;
+ EGLint formats[1];
+ EGLuint64KHR modifiers[1];
+ EGLint num_formats, num_modifiers;
+
+ /* If <dpy> is not the handle of a valid EGLDisplay object, the
+ * error EGL_BAD_DISPLAY is generated. */
+ ret = eglQueryDmaBufFormatsEXT(NULL, 1, formats, &num_formats);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_DISPLAY))
+ return false;
+
+ /* If <max_formats> has a negative value, the error EGL_BAD_PARAMETER
+ * is generated. */
+ ret = eglQueryDmaBufFormatsEXT(egl_dpy, -1, formats, &num_formats);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_PARAMETER))
+ return false;
+
+ /* If <max_formats> is a positive integer but <formats> is NULL,
+ * the error EGL_BAD_PARAMETER is generated. */
+ ret = eglQueryDmaBufFormatsEXT(egl_dpy, 1, NULL, &num_formats);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_PARAMETER))
+ return false;
+
+ /* If <dpy> is not the handle of a valid EGLDisplay object, the
+ * error EGL_BAD_DISPLAY is generated. */
+ ret = eglQueryDmaBufModifiersEXT(NULL, valid_format, 1, modifiers,
+ NULL, &num_modifiers);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_DISPLAY))
+ return false;
+
+ /* If <max_modifiers> has a negative value, the error
+ * EGL_BAD_PARAMETER is generated.*/
+ ret = eglQueryDmaBufModifiersEXT(egl_dpy, valid_format, -1, modifiers,
+ NULL, &num_modifiers);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_PARAMETER))
+ return false;
+
+ /* If <max_modifiers> is a positive integer but <modifiers> is NULL,
+ * the error EGL_BAD_PARAMETER is generated. */
+ ret = eglQueryDmaBufModifiersEXT(egl_dpy, valid_format, 1, NULL,
+ NULL, &num_modifiers);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_PARAMETER))
+ return false;
+
+ /* If <format> is not one of the formats advertised by
+ * QueryDmaBufFormatsEXT for the same <dpy>, the error
+ * EGL_BAD_PARAMETER is generated. */
+ ret = eglQueryDmaBufModifiersEXT(egl_dpy, -1, 1, NULL, NULL,
+ &num_modifiers);
+ if (ret != EGL_FALSE || !piglit_check_egl_error(EGL_BAD_PARAMETER))
+ return false;
+
+ return true;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ EGLDisplay egl_dpy = eglGetCurrentDisplay();
+ EGLint num_formats;
+ EGLint valid_format;
+ bool pass = true;
+
+ pass &= eglQueryDmaBufFormatsEXT(egl_dpy, 1, &valid_format,
+ &num_formats);
+ if(!pass)
+ goto cleanup;
+
+ if (num_formats > 0 && !test_invalid_params(valid_format))
+ pass = false;
+
+cleanup:
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ EGLDisplay egl_dpy = eglGetCurrentDisplay();
+ piglit_require_egl_extension(egl_dpy, "EGL_EXT_image_dma_buf_import_modifiers");
+}
\ No newline at end of file
--
2.6.2
More information about the Piglit
mailing list