All of lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Zimmermann <tzimmermann@suse.de>
To: petri.latvala@intel.com, chris@chris-wilson.co.uk,
	daniel.vetter@ffwll.ch
Cc: igt-dev@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [igt-dev] [PATCH v5 3/8] tests/fbdev: Add tests for read operations on framebuffer
Date: Thu, 19 Nov 2020 14:47:41 +0100	[thread overview]
Message-ID: <20201119134746.28020-4-tzimmermann@suse.de> (raw)
In-Reply-To: <20201119134746.28020-1-tzimmermann@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@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@core_auth@basic-auth
 igt@debugfs_test@read_all_entries
 igt@fbdev@info
+igt@fbdev@read
 igt@gem_basic@bad-close
 igt@gem_basic@create-close
 igt@gem_basic@create-fd-close
-- 
2.29.2

_______________________________________________
igt-dev mailing list
igt-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/igt-dev

  parent reply	other threads:[~2020-11-19 13:47 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-19 13:47 [igt-dev] [PATCH v5 0/8] Test cases for fbdev Thomas Zimmermann
2020-11-19 13:47 ` [igt-dev] [PATCH v5 1/8] tests/fbdev: Move existing tests into separate subgroups Thomas Zimmermann
2020-11-19 13:47 ` [igt-dev] [PATCH v5 2/8] tests/fbdev: Map framebuffer in igt_fixture Thomas Zimmermann
2020-11-19 13:47 ` Thomas Zimmermann [this message]
2020-11-19 13:47 ` [igt-dev] [PATCH v5 4/8] tests/fbdev: Add tests for unaligned reads on framebuffer memory Thomas Zimmermann
2020-11-19 14:13   ` Petri Latvala
2020-11-19 13:47 ` [igt-dev] [PATCH v5 5/8] tests/fbdev: Add tests for write operations on framebuffer Thomas Zimmermann
2020-11-19 13:47 ` [igt-dev] [PATCH v5 6/8] tests/fbdev: Add tests for unaligned writes on framebuffer memory Thomas Zimmermann
2020-11-19 13:47 ` [igt-dev] [PATCH v5 7/8] tests/fbdev: Add tests for accessing framebuffer near EOF Thomas Zimmermann
2020-11-19 13:47 ` [igt-dev] [PATCH v5 8/8] tests/fbdev: Add tests for read/writing with NULL-pointer buffers Thomas Zimmermann
2020-11-19 14:11   ` Petri Latvala
2020-11-20  8:23     ` Thomas Zimmermann
2020-11-19 16:52 ` [igt-dev] ✗ Fi.CI.BAT: failure for Test cases for fbdev Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201119134746.28020-4-tzimmermann@suse.de \
    --to=tzimmermann@suse.de \
    --cc=chris@chris-wilson.co.uk \
    --cc=daniel.vetter@ffwll.ch \
    --cc=igt-dev@lists.freedesktop.org \
    --cc=petri.latvala@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.