Patch Detail
Show a patch.
GET /api/patches/10699/?format=api
{ "id": 10699, "url": "https://patchwork.libcamera.org/api/patches/10699/?format=api", "web_url": "https://patchwork.libcamera.org/patch/10699/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/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": "<20201223121055.14178-3-sebastian.fricke.linux@gmail.com>", "date": "2020-12-23T12:10:55", "name": "[libcamera-devel,2/2] test: Add unit tests for the BayerFormat class", "commit_ref": null, "pull_url": null, "state": "changes-requested", "archived": false, "hash": "1d2aba28aef5f419d8a43acccc8916f091c67dd7", "submitter": { "id": 73, "url": "https://patchwork.libcamera.org/api/people/73/?format=api", "name": "Sebastian Fricke", "email": "sebastian.fricke.linux@gmail.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/10699/mbox/", "series": [ { "id": 1542, "url": "https://patchwork.libcamera.org/api/series/1542/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=1542", "date": "2020-12-23T12:10:53", "name": "Improve BayerFormat class", "version": 1, "mbox": "https://patchwork.libcamera.org/series/1542/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/10699/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/10699/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 0AB5DC0F1A\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 23 Dec 2020 12:11:19 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id C9A1A615D2;\n\tWed, 23 Dec 2020 13:11:18 +0100 (CET)", "from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com\n\t[IPv6:2a00:1450:4864:20::42a])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 17F8F60527\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Dec 2020 13:11:18 +0100 (CET)", "by mail-wr1-x42a.google.com with SMTP id y17so18399732wrr.10\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 23 Dec 2020 04:11:18 -0800 (PST)", "from basti.fritz.box\n\t(p200300d1ff2be200e1a8f8b471c12212.dip0.t-ipconnect.de.\n\t[2003:d1:ff2b:e200:e1a8:f8b4:71c1:2212])\n\tby smtp.gmail.com with ESMTPSA id\n\tu6sm36787733wrm.90.2020.12.23.04.11.17\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tWed, 23 Dec 2020 04:11:17 -0800 (PST)" ], "Authentication-Results": "lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=gmail.com header.i=@gmail.com\n\theader.b=\"ojRcBXpa\"; dkim-atps=neutral", "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=Qg0t00pVXRsV+cmgeCBaO1VXuxMMdE09WxMARf1DwwU=;\n\tb=ojRcBXpa8RM+JhC4d44S65X2iWxP95sUsnjyLWFvgzweBGp3HpIfwvZxrJezjkfVE2\n\t06+TachmrHYyXAVYe84lL5uxLiTQ8GtACsoDllCu++Q2LYW0QH9/weubZ7Ebust/vh4n\n\t7RDs5YvB1esJg0qynWkmp5JfvjzU4bQoMl/cdMkEsVB+AksnUyju3sL//XMIofhC2Sqk\n\tB1YGmsPgeS3amnncEZPOu9wiq2lrZ+g0nJ6ktIP9ljF9AeZD4NX9zeiOq+EOI3a8jWci\n\tpqrFlw/2CZsd0KWw6m2CzuLOiGXYmtVASe5mKWCNSqiNPLMxRV0dBARI1oN59IzBoI6z\n\ttetg==", "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=Qg0t00pVXRsV+cmgeCBaO1VXuxMMdE09WxMARf1DwwU=;\n\tb=Wy+tf7XJg0DGiUKyCvAX83khwyTuR/nNs0s6upt4/0Idx72fLAQSUIxAy2tVneokpm\n\tC0S/CUrnwxgP1KJ1tZaILsWR7PS1Tyu5rcnRb9Sz2Kr+k9ik9VuMgdkp7tznaJJxOCnn\n\t8lYlL7Owl+3r6uNPS6mIQzfgFQYM4Fzs/nWElZUK6IW2kGyYEgCC4qz7FpZagPsiEHjW\n\tik3DHFvh0Au/y32qQWQTnZpFnXB0MUemrma55N7nVU9shdpYbVLHaEiyHWwy4SBHwa1l\n\tmLQrw7hhvbwalHpN9aODpl1AzwcYkFgrikA/hjio2z5zRzRWbD7rMT/qacumMIM/y9if\n\tWwcA==", "X-Gm-Message-State": "AOAM531iPHHG85sgMlCcqFsyhz3mCVY2V2ur4x20WhIp9ODUw650vJOA\n\ttuYAkvVuFRgmNMZLGnGWf+gFHl2F6549xQ==", "X-Google-Smtp-Source": "ABdhPJywjHGXpSOEjNX5bwNgGXrukB9TkqnKJUz9zDAtrD8+pNsuRiarKcmwW/GPbOd9WrruG15dZw==", "X-Received": "by 2002:adf:e54a:: with SMTP id z10mr29462944wrm.1.1608725477848;\n\tWed, 23 Dec 2020 04:11:17 -0800 (PST)", "From": "Sebastian Fricke <sebastian.fricke.linux@gmail.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Wed, 23 Dec 2020 13:10:55 +0100", "Message-Id": "<20201223121055.14178-3-sebastian.fricke.linux@gmail.com>", "X-Mailer": "git-send-email 2.29.2", "In-Reply-To": "<20201223121055.14178-1-sebastian.fricke.linux@gmail.com>", "References": "<20201223121055.14178-1-sebastian.fricke.linux@gmail.com>", "MIME-Version": "1.0", "Subject": "[libcamera-devel] [PATCH 2/2] test: Add unit tests for the\n\tBayerFormat class", "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": "Test all of the present methods including the newly implemented\n`fromV4L2PixelFormat`.\n\nSigned-off-by: Sebastian Fricke <sebastian.fricke.linux@gmail.com>\n---\n test/bayer_format.cpp | 154 ++++++++++++++++++++++++++++++++++++++++++\n test/meson.build | 1 +\n 2 files changed, 155 insertions(+)\n create mode 100644 test/bayer_format.cpp", "diff": "diff --git a/test/bayer_format.cpp b/test/bayer_format.cpp\nnew file mode 100644\nindex 00000000..4d7c7ca1\n--- /dev/null\n+++ b/test/bayer_format.cpp\n@@ -0,0 +1,154 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2020, Sebastian Fricke\n+ *\n+ * bayer_format.cpp - BayerFormat class tests\n+ */\n+#include <iostream>\n+#include <libcamera/internal/bayer_format.h>\n+#include <libcamera/transform.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class BayerFormatTest : public Test\n+{\n+protected:\n+ int run()\n+ {\n+ /*\n+ * TEST 1: A empty bayer format has to be invalid.\n+ */\n+ BayerFormat bay_fmt = BayerFormat();\n+ if (bay_fmt.isValid()) {\n+ cout << \"TEST 1: FAIL: An empty bayer format \"\n+ << \"has to be invalid.\" << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 2: A correct bayer format has to be valid.\n+ */\n+ bay_fmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+ if (!bay_fmt.isValid()) {\n+ cout << \"TEST 2: FAIL: A correct bayer format \"\n+ << \"has to be valid.\" << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 3: Create a bayer format with a V4L2PixelFormat and\n+ * check if we get the same format after converting\n+ * back to the V4L2 Format.\n+ */\n+ V4L2PixelFormat pix_fmt = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n+ bay_fmt = BayerFormat(pix_fmt);\n+ V4L2PixelFormat found_pix_fmt = bay_fmt.toV4L2PixelFormat();\n+ if (found_pix_fmt != pix_fmt) {\n+ cout << \"TEST 3: FAIL: expected: \"\n+ << pix_fmt.toString() << \" got: \"\n+ << found_pix_fmt.toString() << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 4: Check if we get the expected bayer format BGGR8\n+ * when we convert the V4L2PixelFormat\n+ * (V4L2_PIX_FMT_SBGGR8) to a bayer format.\n+ */\n+ BayerFormat exp_bay_fmt = BayerFormat(BayerFormat::BGGR, 8,\n+ BayerFormat::None);\n+ BayerFormat found_bay_fmt = bay_fmt.fromV4L2PixelFormat(\n+ pix_fmt);\n+ if (found_bay_fmt.order != exp_bay_fmt.order ||\n+ found_bay_fmt.bitDepth != exp_bay_fmt.bitDepth ||\n+ found_bay_fmt.packing != exp_bay_fmt.packing) {\n+ cout << \"TEST 4: FAIL: Expected bayer format 'BGGR8',\"\n+ << \"got: \" << found_bay_fmt.toString() << endl;\n+ return TestFail;\n+ }\n+\n+ /* TEST 5: Confirm that a V4L2PixelFormat that is not found in\n+ * the conversion table, doesn't yield a bayer format.\n+ */\n+ exp_bay_fmt = BayerFormat();\n+ found_bay_fmt = BayerFormat();\n+ V4L2PixelFormat unknownn_pix_fmt = V4L2PixelFormat(\n+ V4L2_PIX_FMT_BGRA444);\n+ found_bay_fmt = bay_fmt.fromV4L2PixelFormat(unknownn_pix_fmt);\n+ if (found_bay_fmt.order != exp_bay_fmt.order ||\n+ found_bay_fmt.bitDepth != exp_bay_fmt.bitDepth ||\n+ found_bay_fmt.packing != exp_bay_fmt.packing) {\n+ cout << \"TEST 5: FAIL: expected empty bayer format got: \"\n+ << found_bay_fmt.toString() << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 6: Test if a valid bayer format can be converted to a\n+ * string representation.\n+ */\n+ if (bay_fmt.toString() != \"BGGR-8\") {\n+ cout << \"TEST 6: FAIL: String representation != 'BGGR8' (is: \"\n+ << bay_fmt.toString() << \" ) \" << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 7: Determine if an empty bayer format results in no\n+ * string representation.\n+ */\n+ bay_fmt = BayerFormat();\n+ if (bay_fmt.toString() != \"INVALID\") {\n+ cout << \"TEST 7: FAIL: String representation != 'INVALID' (is: \"\n+ << bay_fmt.toString() << \" ) \" << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 8: Perform a horizontal Flip and make sure that the\n+ * order is adjusted accordingly.\n+ */\n+ bay_fmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+ BayerFormat h_flip_fmt = bay_fmt.transform(Transform::HFlip);\n+ if (h_flip_fmt.toString() != \"GBRG-8\") {\n+ cout << \"TEST 8: FAIL: horizontal flip of 'BGGR-8' \"\n+ << \"should result in 'GBRG-8', got: \"\n+ << h_flip_fmt.toString() << endl;\n+ return TestFail;\n+ }\n+\n+\n+ /*\n+ * TEST 9: Perform a horizontal Flip and make sure that the\n+ * order is adjusted accordingly.\n+ */\n+ bay_fmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+ BayerFormat v_flip_fmt = bay_fmt.transform(Transform::VFlip);\n+ if (v_flip_fmt.toString() != \"GRBG-8\") {\n+ cout << \"TEST 9: FAIL: vertical flip of 'BGGR-8' should \"\n+ << \"result in 'GRBG-8', got: \"\n+ << v_flip_fmt.toString() << endl;\n+ return TestFail;\n+ }\n+\n+ /*\n+ * TEST 10: Perform a transposition and make sure that\n+ * nothing changes.\n+ */\n+ bay_fmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n+ BayerFormat t_fmt = bay_fmt.transform(Transform::Transpose);\n+ if (t_fmt.toString() != \"BGGR-8\") {\n+ cout << \"TEST 10: FAIL: transposition not supported \"\n+ << \"format should be 'BGGR-8', got: \"\n+ << t_fmt.toString() << endl;\n+ return TestFail;\n+ }\n+\n+ return TestPass;\n+ }\n+};\n+\n+TEST_REGISTER(BayerFormatTest);\ndiff --git a/test/meson.build b/test/meson.build\nindex 0a1d434e..e985b0a0 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -23,6 +23,7 @@ public_tests = [\n ]\n \n internal_tests = [\n+ ['bayer-format', 'bayer_format.cpp'],\n ['byte-stream-buffer', 'byte-stream-buffer.cpp'],\n ['camera-sensor', 'camera-sensor.cpp'],\n ['event', 'event.cpp'],\n", "prefixes": [ "libcamera-devel", "2/2" ] }