[igt-dev] [PATCH v3 6/8] tests/fbdev: Add tests for unaligned writes on framebuffer memory

Thomas Zimmermann tzimmermann at suse.de
Tue Nov 10 07:51:00 UTC 2020


The tests for unaligned writes start and stop writing within pages.

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 02abdede..522da8e2 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -155,6 +155,35 @@ static void framebuffer_tests(int fd)
 		igt_require_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\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_require_f(ret == (ssize_t)len, "pwrite failed, ret=%zd\n", ret);
+		pos = memchr(map, 0x55, fix_info.smem_len);
+		igt_require_f(pos, "0x55 not found within framebuffer\n");
+		igt_require_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_require_f(pos, "0xff not found within framebuffer\n");
+		igt_require_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);
+		igt_require_f(pos, "found 0x55 at pos %zu, none expected\n", pos - map);
+	}
+
 	igt_fixture {
 		free(buf);
 		memset(map, 0, fix_info.smem_len); // don't leave garbage on the screen
-- 
2.29.2



More information about the igt-dev mailing list