[igt-dev] [PATCH v5 8/8] tests/fbdev: Add tests for read/writing with NULL-pointer buffers

Thomas Zimmermann tzimmermann at suse.de
Thu Nov 19 13:47:46 UTC 2020


Trying to read and write with a NULL-pointer buffer should fail and
report EFAULT.

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

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

diff --git a/tests/fbdev.c b/tests/fbdev.c
index 62aa99b4..c6139124 100644
--- a/tests/fbdev.c
+++ b/tests/fbdev.c
@@ -229,6 +229,17 @@ static void framebuffer_tests(int fd)
 		igt_assert_f(ret == 0, "read at EOF, ret=%zd\n", ret);
 	}
 
+	igt_describe("Check framebuffer access with NULL");
+	igt_subtest("nullptr") {
+		ssize_t ret;
+
+		ret = pread(fd, NULL, fix_info.smem_len, 0);
+		igt_require_f((ret == -1) && (errno == EFAULT), "reading into NULL did not return EFAULT, ret=%zd\n", ret);
+
+		ret = pwrite(fd, NULL, fix_info.smem_len, 0);
+		igt_require_f((ret == -1) && (errno == EFAULT), "writing from NULL did not return EFAULT, ret=%zd\n", ret);
+	}
+
 	igt_fixture {
 		free(buf);
 		memset(map, 0, fix_info.smem_len); // don't leave garbage on the screen
diff --git a/tests/intel-ci/fast-feedback.testlist b/tests/intel-ci/fast-feedback.testlist
index 0423de80..71bbd173 100644
--- a/tests/intel-ci/fast-feedback.testlist
+++ b/tests/intel-ci/fast-feedback.testlist
@@ -4,6 +4,7 @@ igt at core_auth@basic-auth
 igt at debugfs_test@read_all_entries
 igt at fbdev@eof
 igt at fbdev@info
+igt at fbdev@nullptr
 igt at fbdev@read
 igt at fbdev@unaligned-read
 igt at fbdev@unaligned-write
-- 
2.29.2



More information about the igt-dev mailing list