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

Petri Latvala petri.latvala at intel.com
Wed Nov 11 10:20:30 UTC 2020


On Tue, Nov 10, 2020 at 08:51:02AM +0100, Thomas Zimmermann wrote:
> Trying to read and write with a NULL-pointer buffer should fail and
> report EFAULT.
> 
> v3:
> 	* put igt_describe() before igt_subtest() (Petri)
> 
> Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
> ---
>  tests/fbdev.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tests/fbdev.c b/tests/fbdev.c
> index 8fd920be..814188b5 100644
> --- a/tests/fbdev.c
> +++ b/tests/fbdev.c
> @@ -229,6 +229,17 @@ static void framebuffer_tests(int fd)
>  		igt_require_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_asserts instead of igt_requires.

-- 
Petri Latvala


> +	}
> +
>  	igt_fixture {
>  		free(buf);
>  		memset(map, 0, fix_info.smem_len); // don't leave garbage on the screen
> -- 
> 2.29.2
> 


More information about the igt-dev mailing list