[igt-dev] [PATCH v3 3/8] tests/fbdev: Add tests for read operations on framebuffer
Thomas Zimmermann
tzimmermann at suse.de
Tue Nov 10 07:50:57 UTC 2020
The read tests check the read buffer against the content of the mapped
framebuffer.
v3:
* put igt_describe() before igt_subtest() (Petri)
Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
tests/fbdev.c | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/tests/fbdev.c b/tests/fbdev.c
index fc66210a..97d66217 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>
@@ -64,6 +65,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);
@@ -73,10 +75,33 @@ 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_describe("Check read operations on framebuffer memory");
+ igt_subtest("read") {
+ ssize_t ret;
+ int cmp;
+
+ /* 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.2
More information about the igt-dev
mailing list