All of lore.kernel.org
 help / color / mirror / Atom feed
From: Petri Latvala <petri.latvala@intel.com>
To: Thomas Zimmermann <tzimmermann@suse.de>
Cc: igt-dev@lists.freedesktop.org, chris@chris-wilson.co.uk
Subject: Re: [igt-dev] [PATCH v3 4/8] tests/fbdev: Add tests for unaligned reads on framebuffer memory
Date: Wed, 11 Nov 2020 11:56:35 +0200	[thread overview]
Message-ID: <20201111095635.GD7444@platvala-desk.ger.corp.intel.com> (raw)
In-Reply-To: <20201110075102.5033-5-tzimmermann@suse.de>

On Tue, Nov 10, 2020 at 08:50:58AM +0100, Thomas Zimmermann wrote:
> The tests for unaligned reads start and stop reading within pages.
> 
> v3:
> 	* put igt_describe() before igt_subtest() (Petri)
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
> ---
>  tests/fbdev.c | 40 ++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 38 insertions(+), 2 deletions(-)
> 
> diff --git a/tests/fbdev.c b/tests/fbdev.c
> index 97d66217..a6376c3b 100644
> --- a/tests/fbdev.c
> +++ b/tests/fbdev.c
> @@ -64,10 +64,13 @@ static void mode_tests(int fd)
>  static void framebuffer_tests(int fd)
>  {
>  	struct fb_fix_screeninfo fix_info;
> -	void *map;
> -	void *buf;
> +	unsigned char *map;
> +	unsigned char *buf;
> +	size_t pagesize;
>  
>  	igt_fixture {
> +		long ret;
> +
>  		igt_require(ioctl(fd, FBIOGET_FSCREENINFO, &fix_info) == 0);
>  		igt_require(fix_info.smem_len);
>  
> @@ -77,6 +80,10 @@ static void framebuffer_tests(int fd)
>  
>  		buf = malloc(fix_info.smem_len);
>  		igt_assert(buf);
> +
> +		ret = sysconf(_SC_PAGESIZE);
> +		igt_assert(ret != -1);
> +		pagesize = ret;

igt_require for this.


>  	}
>  
>  	igt_describe("Check read operations on framebuffer memory");
> @@ -99,6 +106,35 @@ static void framebuffer_tests(int fd)
>  		igt_require_f(!cmp, "read buffer differs from mapped framebuffer for 0x55\n");
>  	}
>  
> +	igt_describe("Check read operations on unaligned locations in framebuffer memory");
> +	igt_subtest("unaligned-read") {
> +		off_t off;
> +		size_t len;
> +		ssize_t ret;
> +		const unsigned char *pos;
> +
> +		off = pagesize + (pagesize >> 2); // 1.25 * pagesize
> +		len = (pagesize << 2) + (pagesize >> 1); // 4.5 * pagesize
> +		igt_require_f((off + len) < fix_info.smem_len, "framebuffer too small\n");

Too small to test, or should it always be larger?

> +
> +		/* read at unaligned location and compare */
> +		memset(map, 0, fix_info.smem_len);
> +		memset(&map[off], 0x55, len);
> +		memset(buf, 0xff, fix_info.smem_len);
> +		ret = pread(fd, &buf[off], len, off);
> +		igt_require_f(ret == (ssize_t)len, "pread failed, ret=%zd\n", ret);
> +		pos = memchr(buf, 0x55, fix_info.smem_len);
> +		igt_require_f(pos, "0x55 not found within read buffer\n");
> +		igt_require_f(pos == &buf[off], "0x55 found at pos %zu, expected %lld\n",
> +			     pos - buf, (long long)off);
> +		pos = memchr(&buf[off], 0xff, fix_info.smem_len - off);
> +		igt_require_f(pos, "0xff not found within read buffer\n");
> +		igt_require_f(pos == &buf[off + len], "0xff found at pos %zu, expected %lld\n",
> +			     pos - buf, (long long)(off + len));
> +		pos = memchr(&buf[off + len], 0x55, fix_info.smem_len - off + len);
> +		igt_require_f(pos, "found 0x55 at pos %zu, none expected\n", pos - buf);

These igt_requires should be igt_asserts.


-- 
Petri Latvala


> +	}
> +
>  	igt_fixture {
>  		free(buf);
>  		memset(map, 0, fix_info.smem_len); // don't leave garbage on the screen
> -- 
> 2.29.2
> 
_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  reply	other threads:[~2020-11-11  9:56 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-10  7:50 [igt-dev] [PATCH v3 0/8] Test cases for fbdev Thomas Zimmermann
2020-11-10  7:50 ` [igt-dev] [PATCH v3 1/8] tests/fbdev: Move existing tests into separate subgroups Thomas Zimmermann
2020-11-10  7:50 ` [igt-dev] [PATCH v3 2/8] tests/fbdev: Map framebuffer in igt_fixture Thomas Zimmermann
2020-11-11  9:49   ` Petri Latvala
2020-11-11 10:21     ` Thomas Zimmermann
2020-11-11 10:36       ` Petri Latvala
2020-11-10  7:50 ` [igt-dev] [PATCH v3 3/8] tests/fbdev: Add tests for read operations on framebuffer Thomas Zimmermann
2020-11-11  9:54   ` Petri Latvala
2020-11-10  7:50 ` [igt-dev] [PATCH v3 4/8] tests/fbdev: Add tests for unaligned reads on framebuffer memory Thomas Zimmermann
2020-11-11  9:56   ` Petri Latvala [this message]
2020-11-10  7:50 ` [igt-dev] [PATCH v3 5/8] tests/fbdev: Add tests for write operations on framebuffer Thomas Zimmermann
2020-11-11 10:17   ` Petri Latvala
2020-11-10  7:51 ` [igt-dev] [PATCH v3 6/8] tests/fbdev: Add tests for unaligned writes on framebuffer memory Thomas Zimmermann
2020-11-11 10:18   ` Petri Latvala
2020-11-10  7:51 ` [igt-dev] [PATCH v3 7/8] tests/fbdev: Add tests for accessing framebuffer near EOF Thomas Zimmermann
2020-11-11 10:19   ` Petri Latvala
2020-11-10  7:51 ` [igt-dev] [PATCH v3 8/8] tests/fbdev: Add tests for read/writing with NULL-pointer buffers Thomas Zimmermann
2020-11-11 10:20   ` Petri Latvala
2020-11-10 15:45 ` [igt-dev] ✗ Fi.CI.BAT: failure for Test cases for fbdev Patchwork
2020-11-11  9:11   ` Thomas Zimmermann
2020-11-11 10:22     ` Petri Latvala
2020-11-11 10:59       ` [igt-dev] =?unknown-8bit?b?4pyX?= " Chris Wilson

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=20201111095635.GD7444@platvala-desk.ger.corp.intel.com \
    --to=petri.latvala@intel.com \
    --cc=chris@chris-wilson.co.uk \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=tzimmermann@suse.de \
    /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.