From patchwork Fri Nov 25 09:35:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Varad Gautam X-Patchwork-Id: 84084 Delivered-To: patch@linaro.org Received: by 10.140.20.101 with SMTP id 92csp46724qgi; Fri, 25 Nov 2016 01:35:46 -0800 (PST) X-Received: by 10.99.47.7 with SMTP id v7mr12558709pgv.39.1480066546178; Fri, 25 Nov 2016 01:35:46 -0800 (PST) Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id 76si43870892pfo.238.2016.11.25.01.35.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Nov 2016 01:35:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of piglit-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com; spf=pass (google.com: best guess record for domain of piglit-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=piglit-bounces@lists.freedesktop.org; dmarc=fail (p=NONE dis=NONE) header.from=gmail.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B775A6EB84; Fri, 25 Nov 2016 09:35:45 +0000 (UTC) X-Original-To: piglit@lists.freedesktop.org Delivered-To: piglit@lists.freedesktop.org Received: from mail-pg0-x244.google.com (mail-pg0-x244.google.com [IPv6:2607:f8b0:400e:c05::244]) by gabe.freedesktop.org (Postfix) with ESMTPS id BE79A6EB84 for ; Fri, 25 Nov 2016 09:35:43 +0000 (UTC) Received: by mail-pg0-x244.google.com with SMTP id p66so5166048pga.2 for ; Fri, 25 Nov 2016 01:35:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=krbQIi18Uzz00BFzXj59vhqDXVcR4fu3xsFk+YJpnm4=; b=i5Y1WTNoBmzz78NWJGZChFbySNc2mpm/bDeos3uzAFfHQua64niLCLWw7BlQXeI0L5 PLBeiRUnNcxqcSJf+5NwR09ZYD4WPMZZnnAc+csZS7OUexzUBaXpga9kg9TVOeQmax9U Mr1zr2D/E+Z1aA3hPEkfS2Pfeu52mH3k+Uho30F3kMMqFOUfZooQofW/I5IcN6tiDkN0 Wez5ON95hzW+SgeREBH+NsaVB0gFzlkvNsysTwm9ICBp8i94rJW3l/ri4euYtuu9gVo9 Nb5cs8/wd/vCLIcGNrO9rkngP3RUtbI2WwGHf+T2AUmOmErs8osltA7trEN3Ciqrdaut Zn6Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=krbQIi18Uzz00BFzXj59vhqDXVcR4fu3xsFk+YJpnm4=; b=LX6wToXmunjYYGPLxR8wDPVekYxkVHYanS1dwIpE+225+bESfKOY90sxQAYOfE2pOC ICOG6TZ2pMJn0ctWAqJ79/tkF/zLYaaSfgvWl0FCAT5MiqsoWrmb2mTlm2oSrqvlT8Wj ay2ttdVkE8YukVPjc58YtFkro9E4QlSsrd94T7iunWsT+Od4T+29HCnGHicw16gs2CT0 Oz1L0CBKN+/R5uAtGsd9hcIHkgBhUgtnhFjMddpUzZkynmDGbbtdwdPmhpbq+13bx3e2 lXtwn8KqZ3zUOu2GjwcRKTg7A5q4QCWXhwHAVFQlR1/jmf5e5yLB3LEIkUTgBtsKQIjU CC8A== X-Gm-Message-State: AKaTC01MClRswrqpxaPVzLWcEb4dZGQkqfTav+0R5TX4qscQBfUBFAk+lfcd/Aiq9LR6cg== X-Received: by 10.98.97.7 with SMTP id v7mr6740469pfb.39.1480066542866; Fri, 25 Nov 2016 01:35:42 -0800 (PST) Received: from linux-e1tz.suse ([122.168.223.25]) by smtp.googlemail.com with ESMTPSA id y73sm66241752pfa.68.2016.11.25.01.35.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 25 Nov 2016 01:35:42 -0800 (PST) From: Varad Gautam To: piglit@lists.freedesktop.org Date: Fri, 25 Nov 2016 15:05:17 +0530 Message-Id: <1480066519-20283-5-git-send-email-varadgautam@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1480066519-20283-1-git-send-email-varadgautam@gmail.com> References: <1480066519-20283-1-git-send-email-varadgautam@gmail.com> MIME-Version: 1.0 Cc: Varad Gautam Subject: [Piglit] [PATCH 4/6] ext_image_dma_buf_import: test for failure with invalid query parameters X-BeenThere: piglit@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: piglit-bounces@lists.freedesktop.org Sender: "Piglit" From: Varad Gautam test for eglQueryDmaBufFormatsEXT and eglQueryDmaBufModifiersEXT failure conditions. Signed-off-by: Varad Gautam --- 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 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 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 is a positive integer but 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 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 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 is a positive integer but 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 is not one of the formats advertised by + * QueryDmaBufFormatsEXT for the same , 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