v4l2-compliance: add new mmap tests.
authorHans Verkuil <hans.verkuil@cisco.com>
Sat, 22 Feb 2014 10:12:15 +0000 (11:12 +0100)
committerHans Verkuil <hans.verkuil@cisco.com>
Sat, 22 Feb 2014 10:12:15 +0000 (11:12 +0100)
Check that mmap on a v4l2 node will fail for USERPTR and DMABUF
memory modes.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
utils/v4l2-compliance/v4l2-test-buffers.cpp

index dd5a24b..99d61ae 100644 (file)
@@ -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;