From: Hans Verkuil Date: Sat, 22 Feb 2014 10:12:15 +0000 (+0100) Subject: v4l2-compliance: add new mmap tests. X-Git-Tag: v4l-utils-1.2.0~193 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9286393ecc3f64f68116f86c8e9daafa826faa82;p=platform%2Fupstream%2Fv4l-utils.git v4l2-compliance: add new mmap tests. Check that mmap on a v4l2 node will fail for USERPTR and DMABUF memory modes. Signed-off-by: Hans Verkuil --- diff --git a/utils/v4l2-compliance/v4l2-test-buffers.cpp b/utils/v4l2-compliance/v4l2-test-buffers.cpp index dd5a24b..99d61ae 100644 --- a/utils/v4l2-compliance/v4l2-test-buffers.cpp +++ b/utils/v4l2-compliance/v4l2-test-buffers.cpp @@ -759,6 +759,13 @@ static int setupUserPtr(struct node *node, struct v4l2_requestbuffers &bufs) unsigned num_planes = process_buf(buf, planes); for (unsigned p = 0; p < num_planes; p++) { + // This should not work! + ptrs[i][p] = test_mmap(NULL, planes[p].length, + PROT_READ | PROT_WRITE, MAP_SHARED, node->fd, 0); + fail_on_test(ptrs[i][p] != MAP_FAILED); + } + + for (unsigned p = 0; p < num_planes; p++) { ptrs[i][p] = malloc(planes[p].length); fail_on_test(ptrs[i][p] == NULL); } @@ -946,6 +953,13 @@ static int setupDmaBuf(struct node *expbuf_node, struct node *node, fail_on_test(expbuf_planes[p].length < planes[p].length); for (unsigned p = 0; p < num_planes; p++) { + // This should not work! + ptrs[i][p] = test_mmap(NULL, planes[p].length, + PROT_READ | PROT_WRITE, MAP_SHARED, node->fd, 0); + fail_on_test(ptrs[i][p] != MAP_FAILED); + } + + for (unsigned p = 0; p < num_planes; p++) { memset(&expbuf, 0, sizeof(expbuf)); expbuf.type = expbuf_bufs.type; expbuf.index = i;