summaryrefslogtreecommitdiff
path: root/tests/fbdev.c
diff options
context:
space:
mode:
authorThomas Zimmermann <tzimmermann@suse.de>2020-11-20 11:52:15 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2020-11-23 12:30:17 +0000
commit1bdb714a49676c1cac14784e91950d6356c680c2 (patch)
tree74803b975c9ae96d5a7ff105db690ce80ce4d0c9 /tests/fbdev.c
parentb3b32e10057a05a6e0b0845453179e25228bd018 (diff)
tests/fbdev: Add tests for unaligned writes on framebuffer memory
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@suse.de> Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Diffstat (limited to 'tests/fbdev.c')
-rw-r--r--tests/fbdev.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/tests/fbdev.c b/tests/fbdev.c
index f6e2a091..629e893a 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -160,6 +160,47 @@ static void framebuffer_tests(int fd)
}
}
+ igt_describe("Check write operations on unaligned locations in framebuffer memory");
+ igt_subtest("unaligned-write") {
+ const unsigned char *pos;
+ ssize_t ret;
+ size_t len;
+ off_t off;
+
+ 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));
+ igt_assert_f(pos,
+ "found 0x55 at pos %zu, none expected\n",
+ pos - map);
+ }
+
igt_fixture {
free(buf);
/* don't leave garbage on the screen */