[igt-dev] [PATCH v2 3/8] tests/fbdev: Add tests for read operations on framebuffer
Thomas Zimmermann
tzimmermann at suse.de
Fri Nov 6 08:29:50 UTC 2020
The read tests check the read buffer against the content of the mapped
framebuffer.
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
tests/fbdev.c | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/tests/fbdev.c b/tests/fbdev.c
index 078aa880..e060e3c3 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -25,6 +25,7 @@
#include "igt.h"
+#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <sys/ioctl.h>
@@ -65,6 +66,7 @@ static void framebuffer_tests(int fd)
{
struct fb_fix_screeninfo fix_info;
void *map;
+ void *buf;
igt_fixture {
igt_require(ioctl(fd, FBIOGET_FSCREENINFO, &fix_info) == 0);
@@ -74,10 +76,34 @@ static void framebuffer_tests(int fd)
PROT_WRITE, MAP_SHARED, fd, 0);
igt_assert(map != MAP_FAILED);
+ buf = malloc(fix_info.smem_len);
+ igt_assert(buf);
+ }
+
+ igt_subtest("read") {
+ ssize_t ret;
+ int cmp;
+
+ igt_describe("Check read operations on framebuffer memory");
+
+ /* fill framebuffer with 0 and compare */
memset(map, 0, fix_info.smem_len);
+ ret = pread(fd, buf, fix_info.smem_len, 0);
+ igt_require_f(ret == (ssize_t)fix_info.smem_len, "pread failed, ret=%zd\n", ret);
+ cmp = memcmp(map, buf, fix_info.smem_len);
+ igt_require_f(!cmp, "read buffer differs from mapped framebuffer for 0\n");
+
+ /* fill framebuffer with 0x55 and compare */
+ memset(map, 0x55, fix_info.smem_len);
+ ret = pread(fd, buf, fix_info.smem_len, 0);
+ igt_require_f(ret == (ssize_t)fix_info.smem_len, "pread failed, ret=%zd\n", ret);
+ cmp = memcmp(map, buf, fix_info.smem_len);
+ igt_require_f(!cmp, "read buffer differs from mapped framebuffer for 0x55\n");
}
igt_fixture {
+ free(buf);
+ memset(map, 0, fix_info.smem_len); // don't leave garbage on the screen
munmap(map, fix_info.smem_len);
}
}
--
2.29.0
More information about the igt-dev
mailing list