{"id":9231,"url":"https://patchwork.libcamera.org/api/patches/9231/?format=json","web_url":"https://patchwork.libcamera.org/patch/9231/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200805151507.227503-5-kieran.bingham@ideasonboard.com>","date":"2020-08-05T15:14:58","name":"[libcamera-devel,v4,04/13] test: mapped-buffers: Provide MappedBuffer test","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"008ef4d94c5fa8cb45ca0d58d10806702f6f6f2c","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/?format=json","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/9231/mbox/","series":[{"id":1198,"url":"https://patchwork.libcamera.org/api/series/1198/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1198","date":"2020-08-05T15:14:54","name":"android: JPEG support","version":4,"mbox":"https://patchwork.libcamera.org/series/1198/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/9231/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/9231/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 93A25BD87B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed,  5 Aug 2020 15:15:15 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 609C0607E7;\n\tWed,  5 Aug 2020 17:15:15 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 8192C60599\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed,  5 Aug 2020 17:15:12 +0200 (CEST)","from Q.local (cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net\n\t[86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 03952D2F;\n\tWed,  5 Aug 2020 17:15:11 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"q1cFixOz\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1596640512;\n\tbh=gOM+OtUXdmlLUx5AKttWr5qtbwqqt0qdbGiYKpylbXs=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=q1cFixOzfdgvrfVe0WDHHni7Gj/MhFoElpf+XlVVWxvfJZ36WgrsrYTn/Xau77A7R\n\tOtgySu0uiyYkdgUNyeMIHA86kjyVqCoJakiaBguMehBkzibtSgjNBwDvZvtcfPIPLE\n\t/mRh+jF5H1Dyr1vfPpj2CJbaj2iFsF6qIBIYQdFU=","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","To":"libcamera devel <libcamera-devel@lists.libcamera.org>","Date":"Wed,  5 Aug 2020 16:14:58 +0100","Message-Id":"<20200805151507.227503-5-kieran.bingham@ideasonboard.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20200805151507.227503-1-kieran.bingham@ideasonboard.com>","References":"<20200805151507.227503-1-kieran.bingham@ideasonboard.com>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v4 04/13] test: mapped-buffers: Provide\n\tMappedBuffer test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","Content-Type":"text/plain; charset=\"us-ascii\"","Content-Transfer-Encoding":"7bit","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Provide initial testing framework for the MappedBuffer component.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nSigned-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\n test/mapped-buffer.cpp | 114 +++++++++++++++++++++++++++++++++++++++++\n test/meson.build       |   1 +\n 2 files changed, 115 insertions(+)\n create mode 100644 test/mapped-buffer.cpp","diff":"diff --git a/test/mapped-buffer.cpp b/test/mapped-buffer.cpp\nnew file mode 100644\nindex 000000000000..b1c13ad03e62\n--- /dev/null\n+++ b/test/mapped-buffer.cpp\n@@ -0,0 +1,114 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * libcamera internal MappedBuffer tests\n+ */\n+\n+#include <iostream>\n+\n+#include \"libcamera/internal/buffer.h\"\n+\n+#include \"camera_test.h\"\n+#include \"test.h\"\n+\n+using namespace std;\n+\n+namespace {\n+\n+class MappedBufferTest : public CameraTest, public Test\n+{\n+public:\n+\tMappedBufferTest()\n+\t\t: CameraTest(\"VIMC Sensor B\")\n+\t{\n+\t}\n+\n+protected:\n+\tint init() override\n+\t{\n+\t\tif (status_ != TestPass)\n+\t\t\treturn status_;\n+\n+\t\tconfig_ = camera_->generateConfiguration({ StreamRole::VideoRecording });\n+\t\tif (!config_ || config_->size() != 1) {\n+\t\t\tcout << \"Failed to generate default configuration\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tallocator_ = new FrameBufferAllocator(camera_);\n+\n+\t\tStreamConfiguration &cfg = config_->at(0);\n+\n+\t\tif (camera_->acquire()) {\n+\t\t\tcout << \"Failed to acquire the camera\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (camera_->configure(config_.get())) {\n+\t\t\tcout << \"Failed to set default configuration\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tstream_ = cfg.stream();\n+\n+\t\tint ret = allocator_->allocate(stream_);\n+\t\tif (ret < 0)\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup() override\n+\t{\n+\t\tdelete allocator_;\n+\t}\n+\n+\tint run() override\n+\t{\n+\t\tconst std::unique_ptr<FrameBuffer> &buffer = allocator_->buffers(stream_).front();\n+\t\tstd::vector<MappedBuffer> maps;\n+\n+\t\tMappedFrameBuffer map(buffer.get(), PROT_READ);\n+\t\tif (!map.isValid()) {\n+\t\t\tcout << \"Failed to successfully map buffer\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Make sure we can move it. */\n+\t\tmaps.emplace_back(std::move(map));\n+\n+\t\t/* But copying is prevented, it would cause double-unmap. */\n+\t\t// MappedFrameBuffer map_copy = map;\n+\n+\t\t/* Local map should be invalid (after move). */\n+\t\tif (map.isValid()) {\n+\t\t\tcout << \"Post-move map should not be valid\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test for multiple successful maps on the same buffer. */\n+\t\tMappedFrameBuffer write_map(buffer.get(), PROT_WRITE);\n+\t\tif (!write_map.isValid()) {\n+\t\t\tcout << \"Failed to map write buffer\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tMappedFrameBuffer rw_map(buffer.get(), PROT_READ | PROT_WRITE);\n+\t\tif (!rw_map.isValid()) {\n+\t\t\tcout << \"Failed to map RW buffer\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+private:\n+\tstd::unique_ptr<CameraConfiguration> config_;\n+\tFrameBufferAllocator *allocator_;\n+\tStream *stream_;\n+};\n+\n+} /* namespace */\n+\n+TEST_REGISTER(MappedBufferTest);\ndiff --git a/test/meson.build b/test/meson.build\nindex 775187159dec..0a1d434e3996 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -31,6 +31,7 @@ internal_tests = [\n     ['file',                            'file.cpp'],\n     ['file-descriptor',                 'file-descriptor.cpp'],\n     ['hotplug-cameras',                 'hotplug-cameras.cpp'],\n+    ['mapped-buffer',                   'mapped-buffer.cpp'],\n     ['message',                         'message.cpp'],\n     ['object',                          'object.cpp'],\n     ['object-delete',                   'object-delete.cpp'],\n","prefixes":["libcamera-devel","v4","04/13"]}