Patch Detail
Show a patch.
GET /api/1.1/patches/2974/?format=api
{ "id": 2974, "url": "https://patchwork.libcamera.org/api/1.1/patches/2974/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2974/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20200306160002.30549-3-laurent.pinchart@ideasonboard.com>", "date": "2020-03-06T15:59:32", "name": "[libcamera-devel,v2,02/32] test: Add Span test", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "9bdd15635279f668b06c68aef71ecaf5287e2b7f", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2974/mbox/", "series": [ { "id": 703, "url": "https://patchwork.libcamera.org/api/1.1/series/703/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=703", "date": "2020-03-06T15:59:30", "name": "libcamera: Add support for array controls", "version": 2, "mbox": "https://patchwork.libcamera.org/series/703/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2974/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2974/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 1B836627C3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 6 Mar 2020 17:00:12 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B7DAE24B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 6 Mar 2020 17:00:11 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1583510411;\n\tbh=cXCBpWnkjaFxc9D83cak3df0VDZgS7qi/C6fGDl3R9c=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oVrjLPi23SJRozmyruMzy1RxPRaN0SRCFZKi5GUu6QzdI7SiJGlVFszhk7t28w5SF\n\tsk92HmhU377JLq2cduTWbNfzu63Xr36QI94w0VvDjPDHiPkGZyVixjuKcw0jDWJ+aK\n\t5g3fs5MovcsP0xPjcv6QaFd9UiNPB6XZzT9jdW4w=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 6 Mar 2020 17:59:32 +0200", "Message-Id": "<20200306160002.30549-3-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>", "References": "<20200306160002.30549-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 02/32] test: Add Span 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>", "X-List-Received-Date": "Fri, 06 Mar 2020 16:00:12 -0000" }, "content": "Add a compile-only test that exercises the whole Span API, as template\nfunctions are not fully compile-tested when the file is parsed.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n---\nChanges since v1:\n\n- Moved the test to the public libcamera tests\n- Include libcamera/span.h first to ensure the header is self-contained\n---\n test/meson.build | 1 +\n test/span.cpp | 181 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 182 insertions(+)\n create mode 100644 test/span.cpp", "diff": "diff --git a/test/meson.build b/test/meson.build\nindex daaa1aac926d..8ab58ac15a2a 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -17,6 +17,7 @@ public_tests = [\n ['geometry', 'geometry.cpp'],\n ['list-cameras', 'list-cameras.cpp'],\n ['signal', 'signal.cpp'],\n+ ['span', 'span.cpp'],\n ]\n \n internal_tests = [\ndiff --git a/test/span.cpp b/test/span.cpp\nnew file mode 100644\nindex 000000000000..69f0732e8027\n--- /dev/null\n+++ b/test/span.cpp\n@@ -0,0 +1,181 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Google Inc.\n+ *\n+ * span.cpp - Span tests\n+ */\n+\n+/*\n+ * Include first to ensure the header is self-contained, as there's no span.cpp\n+ * in libcamera.\n+ */\n+#include <libcamera/span.h>\n+\n+#include <array>\n+#include <iostream>\n+#include <vector>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class SpanTest : public Test\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tint i[4]{ 1, 2, 3, 4 };\n+\t\tstd::array<int, 4> a{ 1, 2, 3, 4 };\n+\t\tconst std::array<int, 4> ca{ 1, 2, 3, 4 };\n+\t\tstd::vector<int> v{ 1, 2, 3, 4 };\n+\t\tconst std::vector<int> cv{ 1, 2, 3, 4 };\n+\n+\t\t/*\n+\t\t * Compile-test construction and usage of spans with static\n+\t\t * extent. Commented-out tests are expected not to compile, or\n+\t\t * to generate undefined behaviour.\n+\t\t */\n+\n+\t\tSpan<int, 0>{};\n+\t\t/* Span<int, 4>{}; */\n+\n+\t\tSpan<int, 4>{ &i[0], 4 };\n+\t\tSpan<int, 4>{ &i[0], &i[3] };\n+\n+\t\tSpan<int, 4>{ i };\n+\t\t/* Span<float, 4>{ i }; */\n+\t\t/* Span<int, 2>{ i }; */\n+\n+\t\tSpan<int, 4>{ a };\n+\t\tSpan<const int, 4>{ a };\n+\t\t/* Span<float, 4>{ a }; */\n+\t\t/* Span<int, 2>{ a }; */\n+\n+\t\tSpan<const int, 4>{ ca };\n+\t\t/* Span<const int, 2>{ ca }; */\n+\t\t/* Span<const float, 4>{ ca }; */\n+\t\t/* Span<int, 4>{ ca }; */\n+\n+\t\tSpan<int, 4>{ v };\n+\t\tSpan<const int, 4>{ v };\n+\t\t/* Span<float, 4>{ v }; */\n+\n+\t\tSpan<const int, 4>{ v };\n+\t\t/* Span<int, 4>{ v }; */\n+\t\t/* Span<const float, 4>{ v }; */\n+\n+\t\tSpan<int, 4> staticSpan{ i };\n+\t\tSpan<int, 4>{ staticSpan };\n+\t\tSpan<const int, 4>{ staticSpan };\n+\t\t/* Span<const int, 2>{ staticSpan }; */\n+\n+\t\tstaticSpan = Span<int, 4>{ v };\n+\n+\t\tstaticSpan.begin();\n+\t\tstaticSpan.cbegin();\n+\t\tstaticSpan.end();\n+\t\tstaticSpan.cend();\n+\t\tstaticSpan.rbegin();\n+\t\tstaticSpan.crbegin();\n+\t\tstaticSpan.rend();\n+\t\tstaticSpan.crend();\n+\n+\t\tstaticSpan.front();\n+\t\tstaticSpan.back();\n+\t\tstaticSpan[0];\n+\t\tstaticSpan.data();\n+\n+\t\tstaticSpan.size();\n+\t\tstaticSpan.size_bytes();\n+\n+\t\tstaticSpan.empty();\n+\n+\t\tstaticSpan.first<2>();\n+\t\tstaticSpan.first(2);\n+\t\t/* staticSpan.first<6>(); */\n+\t\t/* staticSpan.first(6); */\n+\t\tstaticSpan.last<2>();\n+\t\tstaticSpan.last(2);\n+\t\t/* staticSpan.last<6>(); */\n+\t\t/* staticSpan.last(6); */\n+\t\tstaticSpan.subspan<1>();\n+\t\tstaticSpan.subspan<1, 2>();\n+\t\tstaticSpan.subspan(1);\n+\t\tstaticSpan.subspan(1, 2);\n+\t\t/* staticSpan.subspan(2, 4); */\n+\n+\t\t/*\n+\t\t * Compile-test construction and usage of spans with static\n+\t\t * extent. Commented-out tests are expected not to compile, or\n+\t\t * to generate undefined behaviour.\n+\t\t */\n+\n+\t\tSpan<int>{};\n+\n+\t\tSpan<int>{ &i[0], 4 };\n+\t\tSpan<int>{ &i[0], &i[3] };\n+\n+\t\tSpan<int>{ i };\n+\t\t/* Span<float>{ i }; */\n+\n+\t\tSpan<int>{ a };\n+\t\tSpan<const int>{ a };\n+\t\t/* Span<float>{ a }; */\n+\n+\t\tSpan<const int>{ ca };\n+\t\t/* Span<const float>{ca}; */\n+\t\t/* Span<int>{ca}; */\n+\n+\t\tSpan<int>{ v };\n+\t\tSpan<const int>{ v };\n+\t\t/* Span<float>{ v }; */\n+\n+\t\tSpan<const int>{ v };\n+\t\t/* Span<int>{ v }; */\n+\t\t/* Span<const float>{ v }; */\n+\n+\t\tSpan<int> dynamicSpan{ i };\n+\t\tSpan<int>{ dynamicSpan };\n+\t\tSpan<const int>{ dynamicSpan };\n+\n+\t\tdynamicSpan = Span<int>{ a };\n+\n+\t\tdynamicSpan.begin();\n+\t\tdynamicSpan.cbegin();\n+\t\tdynamicSpan.end();\n+\t\tdynamicSpan.cend();\n+\t\tdynamicSpan.rbegin();\n+\t\tdynamicSpan.crbegin();\n+\t\tdynamicSpan.rend();\n+\t\tdynamicSpan.crend();\n+\n+\t\tdynamicSpan.front();\n+\t\tdynamicSpan.back();\n+\t\tdynamicSpan[0];\n+\t\tdynamicSpan.data();\n+\n+\t\tdynamicSpan.size();\n+\t\tdynamicSpan.size_bytes();\n+\n+\t\tdynamicSpan.empty();\n+\n+\t\tdynamicSpan.first<2>();\n+\t\tdynamicSpan.first(2);\n+\t\t/* dynamicSpan.first<6>(); */\n+\t\t/* dynamicSpan.first(6); */\n+\t\tdynamicSpan.last<2>();\n+\t\tdynamicSpan.last(2);\n+\t\t/* dynamicSpan.last<6>(); */\n+\t\t/* dynamicSpan.last(6); */\n+\t\tdynamicSpan.subspan<1>();\n+\t\tdynamicSpan.subspan<1, 2>();\n+\t\tdynamicSpan.subspan(1);\n+\t\tdynamicSpan.subspan(1, 2);\n+\t\t/* dynamicSpan.subspan(2, 4); */\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+TEST_REGISTER(SpanTest)\n", "prefixes": [ "libcamera-devel", "v2", "02/32" ] }