From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Daniel Stone <daniels@collabora.com>
Cc: igt-dev@lists.freedesktop.org
Subject: Re: [igt-dev] [PATCH i-g-t] tests/kms_getfb: Add test for getfb
Date: Wed, 21 Mar 2018 14:41:07 +0200 [thread overview]
Message-ID: <20180321124107.GX5453@intel.com> (raw)
In-Reply-To: <20180321121606.30979-1-daniels@collabora.com>
On Wed, Mar 21, 2018 at 12:16:06PM +0000, Daniel Stone wrote:
> Add a new test exercising the GetFB API, specifically including its
> behaviour of always returning new handles even if the client already has
> a handle to the GEM buffer.
>
> Signed-off-by: Daniel Stone <daniels@collabora.com>
> ---
> tests/Makefile.sources | 1 +
> tests/kms_getfb.c | 158 +++++++++++++++++++++++++++++++++++++++++++++++++
> tests/meson.build | 1 +
> 3 files changed, 160 insertions(+)
> create mode 100644 tests/kms_getfb.c
>
> diff --git a/tests/Makefile.sources b/tests/Makefile.sources
> index 4e6f5319..791e4f83 100644
> --- a/tests/Makefile.sources
> +++ b/tests/Makefile.sources
> @@ -189,6 +189,7 @@ TESTS_progs = \
> kms_flip_tiling \
> kms_force_connector_basic \
> kms_frontbuffer_tracking \
> + kms_getfb \
> kms_hdmi_inject \
> kms_invalid_dotclock \
> kms_legacy_colorkey \
> diff --git a/tests/kms_getfb.c b/tests/kms_getfb.c
> new file mode 100644
> index 00000000..00b5dfcf
> --- /dev/null
> +++ b/tests/kms_getfb.c
> @@ -0,0 +1,158 @@
> +/*
> + * Copyright © 2013 Intel Corporation
> + * Copyright © 2018 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.
> + *
> + * Authors:
> + * Daniel Vetter <daniel.vetter@ffwll.ch>
> + * Daniel Stone <daniels@collabora.com>
> + *
> + */
> +
> +#include "igt.h"
> +#include <unistd.h>
> +#include <stdlib.h>
> +#include <stdio.h>
> +#include <string.h>
> +#include <fcntl.h>
> +#include <inttypes.h>
> +#include <errno.h>
> +#include <sys/stat.h>
> +#include <sys/ioctl.h>
> +#include "drm.h"
> +#include "drm_fourcc.h"
> +
> +static void test_handle_input(int fd)
> +{
> + struct drm_mode_fb_cmd2 add = {};
> +
> + igt_fixture {
> + add.width = 1024;
> + add.height = 1024;
> + add.pixel_format = DRM_FORMAT_XRGB8888;
> + add.pitches[0] = 1024*4;
> + add.handles[0] = igt_create_bo_with_dimensions(fd, 1024, 1024,
> + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
> + igt_assert(add.handles[0]);
> + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &add);
> + }
> +
> + igt_subtest("getfb-handle-zero") {
> + struct drm_mode_fb_cmd get = { .fb_id = 0 };
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, &get, ENOENT);
I wonder if the kernel should actually return -EINVAL for that one. Oh
well, probably not much point in trying to change it now and risk
something breaking.
Hmm. Actually the kernel now does
radix_tree_lookup(&idr->idr_rt, id - idr->idr_base);
which looks a bit suspicious for the id < idr_base case. I don't think
we use idr_base for kms stuff yet though, but we do for gem.
Anyways test looks all right to me
Reviewed-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> + }
> +
> + igt_subtest("getfb-handle-valid") {
> + struct drm_mode_fb_cmd get = { .fb_id = add.fb_id };
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB, &get);
> + igt_assert_neq_u32(get.handle, 0);
> + igt_assert_eq_u32(get.width, add.width);
> + igt_assert_eq_u32(get.height, add.height);
> + igt_assert_eq_u32(get.pitch, add.pitches[0]);
> + igt_assert_eq_u32(get.depth, 24);
> + igt_assert_eq_u32(get.bpp, 32);
> + gem_close(fd, get.handle);
> + }
> +
> + igt_subtest("getfb-handle-closed") {
> + struct drm_mode_fb_cmd get = { .fb_id = add.fb_id };
> + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id);
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, &get, ENOENT);
> + }
> +
> + igt_subtest("getfb-handle-not-fb") {
> + struct drm_mode_fb_cmd get = { };
> + uint32_t prop_id = 0;
> + igt_display_t display;
> +
> + /* Find a valid property ID to use. */
> + igt_display_init(&display, fd);
> + for (int i = 0; i < display.n_outputs; i++) {
> + igt_output_t *output = &display.outputs[i];
> +
> + if (output->props[IGT_CONNECTOR_DPMS] != 0) {
> + prop_id = output->props[IGT_CONNECTOR_DPMS];
> + break;
> + }
> + }
> + igt_require(prop_id > 0);
> +
> + get.fb_id = prop_id;
> + do_ioctl_err(fd, DRM_IOCTL_MODE_GETFB, &get, ENOENT);
> + }
> +}
> +
> +static void test_duplicate_handles(int fd)
> +{
> + struct drm_mode_fb_cmd2 add = {};
> +
> + igt_fixture {
> + add.width = 1024;
> + add.height = 1024;
> + add.pixel_format = DRM_FORMAT_XRGB8888;
> + add.pitches[0] = 1024*4;
> + add.handles[0] = igt_create_bo_with_dimensions(fd, 1024, 1024,
> + DRM_FORMAT_XRGB8888, 0, 0, NULL, NULL, NULL);
> + igt_assert(add.handles[0]);
> + do_ioctl(fd, DRM_IOCTL_MODE_ADDFB2, &add);
> + }
> +
> + igt_subtest("getfb-addfb-different-handles") {
> + struct drm_mode_fb_cmd get = { .fb_id = add.fb_id };
> +
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB, &get);
> + igt_assert_neq_u32(get.handle, add.handles[0]);
> + gem_close(fd, get.handle);
> + }
> +
> + igt_subtest("getfb-repeated-different-handles") {
> + struct drm_mode_fb_cmd get1 = { .fb_id = add.fb_id };
> + struct drm_mode_fb_cmd get2 = { .fb_id = add.fb_id };
> +
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB, &get1);
> + do_ioctl(fd, DRM_IOCTL_MODE_GETFB, &get2);
> + igt_assert_neq_u32(get1.handle, get2.handle);
> +
> + gem_close(fd, get1.handle);
> + gem_close(fd, get2.handle);
> + }
> +
> + igt_fixture {
> + do_ioctl(fd, DRM_IOCTL_MODE_RMFB, &add.fb_id);
> + gem_close(fd, add.handles[0]);
> + }
> +
> +}
> +
> +igt_main
> +{
> + int fd;
> +
> + igt_fixture
> + fd = drm_open_driver_master(DRIVER_ANY);
> +
> + test_handle_input(fd);
> +
> + test_duplicate_handles(fd);
> +
> + igt_fixture
> + close(fd);
> +}
> diff --git a/tests/meson.build b/tests/meson.build
> index 1176463c..122aefab 100644
> --- a/tests/meson.build
> +++ b/tests/meson.build
> @@ -166,6 +166,7 @@ test_progs = [
> 'kms_flip_tiling',
> 'kms_force_connector_basic',
> 'kms_frontbuffer_tracking',
> + 'kms_getfb',
> 'kms_hdmi_inject',
> 'kms_invalid_dotclock',
> 'kms_legacy_colorkey',
> --
> 2.16.2
>
> _______________________________________________
> igt-dev mailing list
> igt-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/igt-dev
--
Ville Syrjälä
Intel OTC
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev
next prev parent reply other threads:[~2018-03-21 12:41 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-03-21 12:16 [igt-dev] [PATCH i-g-t] tests/kms_getfb: Add test for getfb Daniel Stone
2018-03-21 12:41 ` Ville Syrjälä [this message]
2018-03-21 13:07 ` [igt-dev] ✓ Fi.CI.BAT: success for " Patchwork
2018-03-21 16:53 ` [igt-dev] ✗ Fi.CI.IGT: warning " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180321124107.GX5453@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=daniels@collabora.com \
--cc=igt-dev@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.