[igt-dev] [PATCH v6 6/8] tests/fbdev: Add tests for unaligned writes on framebuffer memory
Thomas Zimmermann
tzimmermann at suse.de
Mon Nov 23 18:57:49 UTC 2020
Hi
Am 23.11.20 um 14:18 schrieb Chris Wilson:
> Quoting Thomas Zimmermann (2020-11-20 10:52:15)
>> The tests for unaligned writes start and stop writing within pages.
>>
>> v6:
>> * remove test from fast-feedback.testlist
>> v4:
>> * replace igt_require() by igt_assert() in "unaligned-write" (Petri)
>> * clarify error message about framebuffer size (Petri)
>> * add unaligned-write test to CI
>> v3:
>> * put igt_describe() before igt_subtest() (Petri)
>>
>> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
>> ---
>> tests/fbdev.c | 29 +++++++++++++++++++++++++++++
>> 1 file changed, 29 insertions(+)
>>
>> diff --git a/tests/fbdev.c b/tests/fbdev.c
>> index 23ff146c..c4cb357f 100644
>> --- a/tests/fbdev.c
>> +++ b/tests/fbdev.c
>> @@ -155,6 +155,35 @@ static void framebuffer_tests(int fd)
>> igt_assert_f(!cmp, "write buffer differs from mapped framebuffer for 0\n");
>> }
>>
>> + igt_describe("Check write operations on unaligned locations in framebuffer memory");
>> + igt_subtest("unaligned-write") {
>> + 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 to test\n");
>> +
>> + /* read at unaligned location and compare */
>> + memset(map, 0xff, fix_info.smem_len);
>> + memset(buf, 0, fix_info.smem_len);
>> + memset(&buf[off], 0x55, len);
>> + ret = pwrite(fd, &buf[off], len, off);
>> + igt_assert_f(ret == (ssize_t)len, "pwrite failed, ret=%zd\n", ret);
>> + pos = memchr(map, 0x55, fix_info.smem_len);
>> + igt_assert_f(pos, "0x55 not found within framebuffer\n");
>> + igt_assert_f(pos == &map[off], "0x55 found at pos %zu, expected %lld\n",
>> + pos - map, (long long)off);
>> + pos = memchr(&map[off], 0xff, fix_info.smem_len - off);
>> + igt_assert_f(pos, "0xff not found within framebuffer\n");
>> + igt_assert_f(pos == &map[off + len], "0xff found at pos %zu, expected %lld\n",
>> + pos - map, (long long)(off + len));
>
>> + pos = memchr(&map[off + len], 0x55, fix_info.smem_len - off + len);
>
> Spotted this typo in the unaligned read/write, should be
> smem_len - (off + len)
>
> Applied some minor whitespace changes, the goal is to follow the kernel
> coding style (so that we don't have to keep on switching styles :), and
> that also allows us to use the same gcc-isms as we expect to find in the
> kernel.
>
> Series is
> Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
> and pushed.
Thanks a lot!
> -Chris
>
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_0x680DC11D530B7A23.asc
Type: application/pgp-keys
Size: 7435 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20201123/98f179f1/attachment.key>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature
Type: application/pgp-signature
Size: 840 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/igt-dev/attachments/20201123/98f179f1/attachment.sig>
More information about the igt-dev
mailing list