[igt-dev] [PATCH v6 3/8] tests/fbdev: Add tests for read operations on framebuffer

Thomas Zimmermann tzimmermann at suse.de
Fri Nov 20 10:52:12 UTC 2020


The read tests check the read buffer against the content of the mapped
framebuffer.

v4:
	* test malloc() success with igt_require()
	* replace igt_require() by igt_assert() in "read" (Petri)
	* add read test to CI
v3:
	* put igt_describe() before igt_subtest() (Petri)

Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
 tests/fbdev.c                         | 25 +++++++++++++++++++++++++
 tests/intel-ci/fast-feedback.testlist |  1 +
 2 files changed, 26 insertions(+)

diff --git a/tests/fbdev.c b/tests/fbdev.c
index eebd2a83..d8c78a5e 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 * volatile map;
+	void * volatile 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_require(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_assert_f(ret == (ssize_t)fix_info.smem_len, "pread failed, ret=%zd\n", ret);
+		cmp = memcmp(map, buf, fix_info.smem_len);
+		igt_assert_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_assert_f(ret == (ssize_t)fix_info.smem_len, "pread failed, ret=%zd\n", ret);
+		cmp = memcmp(map, buf, fix_info.smem_len);
+		igt_assert_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);
 	}
 }
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index cf66b4da..fc8a605f 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -3,6 +3,7 @@
 igt at core_auth@basic-auth
 igt at debugfs_test@read_all_entries
 igt at fbdev@info
+igt at fbdev@read
 igt at gem_basic@bad-close
 igt at gem_basic@create-close
 igt at gem_basic@create-fd-close
-- 
2.29.2



More information about the igt-dev mailing list