[PATCH i-g-t 4/9] tests/fbdev: Add tests for read operations on framebuffer
Chris Wilson
chris at chris-wilson.co.uk
Mon Nov 23 12:34:23 UTC 2020
From: Thomas Zimmermann <tzimmermann at suse.de>
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>
Reviewed-by: Chris Wilson <chris at chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
tests/fbdev.c | 25 ++++++++++++++++++++++++-
tests/intel-ci/fast-feedback.testlist | 1 +
2 files changed, 25 insertions(+), 1 deletion(-)
diff --git a/tests/fbdev.c b/tests/fbdev.c
index eebd2a834..0b208bdab 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>
@@ -62,8 +63,10 @@ static void mode_tests(int fd)
static void framebuffer_tests(int fd)
{
+ const int values[] = { 0, 0x55, 0xaa, 0xff };
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 +76,30 @@ static void framebuffer_tests(int fd)
PROT_WRITE, MAP_SHARED, fd, 0);
igt_assert(map != MAP_FAILED);
- memset(map, 0, fix_info.smem_len);
+ buf = malloc(fix_info.smem_len);
+ igt_require(buf);
+ }
+
+ igt_describe("Check read operations on framebuffer memory");
+ igt_subtest("read") {
+ ssize_t ret;
+
+ /* fill framebuffer and compare */
+ for (int i = 0; i < ARRAY_SIZE(values); i++) {
+ memset(map, values[i], 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);
+ igt_assert_f(!memcmp(map, buf, fix_info.smem_len),
+ "read differs from mapped framebuffer for %x\n",
+ values[i]);
+ }
}
igt_fixture {
+ free(buf);
+ /* don't leave garbage on the screen */
+ memset(map, 0, fix_info.smem_len);
munmap(map, fix_info.smem_len);
}
}
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index cf66b4dac..fc8a605fc 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 Intel-gfx-trybot
mailing list