[{"id":14802,"web_url":"https://patchwork.libcamera.org/comment/14802/","msgid":"<YBCh99qHEmpEl0l7@pendragon.ideasonboard.com>","date":"2021-01-26T23:12:55","subject":"Re: [libcamera-devel] [PATCH v3 5/5] test: Add unit tests for the\n\tBayerFormat class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Sebastian,\n\nThank you for the patch.\n\nOn Tue, Jan 26, 2021 at 07:48:54PM +0100, Sebastian Fricke wrote:\n> Test all of the present methods including the newly implemented\n> `fromV4L2PixelFormat`, as well as the new operators `==/!=`.\n> \n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>\n> ---\n>  test/bayer_format.cpp | 210 ++++++++++++++++++++++++++++++++++++++++++\n>  test/meson.build      |   1 +\n>  2 files changed, 211 insertions(+)\n>  create mode 100644 test/bayer_format.cpp\n> \n> diff --git a/test/bayer_format.cpp b/test/bayer_format.cpp\n> new file mode 100644\n> index 00000000..f763500f\n> --- /dev/null\n> +++ b/test/bayer_format.cpp\n> @@ -0,0 +1,210 @@\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> +\n> +#include <iostream>\n> +\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> +\tint run()\n> +\t{\n> +\t\t/* An empty Bayer format has to be invalid. */\n> +\t\tBayerFormat bayerFmt;\n> +\t\tif (bayerFmt.isValid()) {\n> +\t\t\tcerr << \"An empty BayerFormat has to be invalid.\"\n> +\t\t\t     << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/* A correct Bayer format has to be valid. */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tif (!bayerFmt.isValid()) {\n> +\t\t\tcerr << \"A correct BayerFormat has to be valid.\"\n> +\t\t\t     << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Two bayer formats created with the same order and bit depth\n> +\t\t * have to be equal.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tBayerFormat bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,\n> +\t\t\t\t\t\t\t BayerFormat::None);\n> +\t\tif (bayerFmt != bayerFmtExpect) {\n> +\t\t\tcerr << \"Comparison of identical formats failed.\"\n> +\t\t\t     << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Two Bayer formats created with the same order but with a\n> +\t\t * different bitDepth are not equal.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tbayerFmtExpect = BayerFormat(BayerFormat::BGGR, 12,\n> +\t\t\t\t\t     BayerFormat::None);\n> +\t\tif (bayerFmt == bayerFmtExpect) {\n> +\t\t\tcerr << \"Comparison of divergent formats failed.\"\n\ns/divergent/different/\n\n> +\t\t\t     << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Create a Bayer format with a V4L2PixelFormat and check if we\n> +\t\t * get the same format after converting back to the V4L2 Format.\n> +\t\t */\n> +\t\tV4L2PixelFormat v4l2FmtExpect = V4L2PixelFormat(\n> +\t\t\tV4L2_PIX_FMT_SBGGR8);\n> +\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtExpect);\n> +\t\tV4L2PixelFormat v4l2Fmt = bayerFmt.toV4L2PixelFormat();\n> +\t\tif (v4l2Fmt != v4l2FmtExpect) {\n> +\t\t\tcerr << \"Expected: '\" << v4l2FmtExpect.toString()\n> +\t\t\t     << \"' got: '\" << v4l2Fmt.toString() << \"'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Use an empty Bayer format and verify that no matching\n> +\t\t * V4L2PixelFormat is found.\n> +\t\t */\n> +\t\tv4l2FmtExpect = V4L2PixelFormat();\n> +\t\tbayerFmt = BayerFormat();\n> +\t\tv4l2Fmt = bayerFmt.toV4L2PixelFormat();\n> +\t\tif (v4l2Fmt != v4l2FmtExpect) {\n> +\t\t\tcerr << \"Expected: empty V4L2PixelFormat got: '\"\n> +\t\t\t     << v4l2Fmt.toString() << \"'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Check if we get the expected Bayer format BGGR8\n> +\t\t * when we convert the V4L2PixelFormat (V4L2_PIX_FMT_SBGGR8)\n> +\t\t * to a Bayer format.\n> +\t\t */\n> +\t\tbayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,\n> +\t\t\t\t\t     BayerFormat::None);\n> +\t\tv4l2Fmt = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n> +\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt);\n> +\t\tif (bayerFmt != bayerFmtExpect) {\n> +\t\t\tcerr << \"Expected BayerFormat '\"\n> +\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n> +\t\t\t     << bayerFmt.toString() << \"'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Confirm that a V4L2PixelFormat that is not found in\n> +\t\t * the conversion table, doesn't yield a Bayer format.\n> +\t\t */\n> +\t\tV4L2PixelFormat v4l2FmtUnknown = V4L2PixelFormat(\n> +\t\t\tV4L2_PIX_FMT_BGRA444);\n> +\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtUnknown);\n> +\t\tif (bayerFmt.isValid()) {\n> +\t\t\tcerr << \"Expected empty BayerFormat got: '\"\n> +\t\t\t     << bayerFmt.toString() << \"'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Test if a valid Bayer format can be converted to a\n> +\t\t * string representation.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tif (bayerFmt.toString() != \"BGGR-8\") {\n> +\t\t\tcerr << \"String representation != 'BGGR-8' (got: '\"\n> +\t\t\t     << bayerFmt.toString() << \"' ) \" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Determine if an empty Bayer format results in no\n> +\t\t * string representation.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat();\n> +\t\tif (bayerFmt.toString() != \"INVALID\") {\n> +\t\t\tcerr << \"String representation != 'INVALID' (got: '\"\n> +\t\t\t     << bayerFmt.toString() << \"' ) \" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Perform a horizontal Flip and make sure that the\n> +\t\t * order is adjusted accordingly.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tbayerFmtExpect = BayerFormat(BayerFormat::GBRG, 8,\n> +\t\t\t\t\t     BayerFormat::None);\n> +\t\tBayerFormat hFlipFmt = bayerFmt.transform(Transform::HFlip);\n> +\t\tif (hFlipFmt != bayerFmtExpect) {\n> +\t\t\tcerr << \"Horizontal flip of 'BGGR-8' should result in '\"\n> +\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n> +\t\t\t     << hFlipFmt.toString() << \"'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Perform a vertical Flip and make sure that\n> +\t\t * the order is adjusted accordingly.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tbayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8,\n> +\t\t\t\t\t     BayerFormat::None);\n> +\t\tBayerFormat vFlipFmt = bayerFmt.transform(Transform::VFlip);\n> +\t\tif (vFlipFmt != bayerFmtExpect) {\n> +\t\t\tcerr << \"Vertical flip of 'BGGR-8' should result in '\"\n> +\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n> +\t\t\t     << vFlipFmt.toString() << \"'\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Perform a transposition on a pixel order with both green\n> +\t\t * pixels on the bottom left to top right diagonal and make\n> +\t\t * sure, that it doesn't change.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> +\t\tBayerFormat transposeFmt = bayerFmt.transform(\n> +\t\t\tTransform::Transpose);\n> +\t\tif (transposeFmt != bayerFmt) {\n> +\t\t\tcerr << \"Transpose with both green pixels on the \"\n> +\t\t\t     << \"antidiagonal, should not change the order \"\n\ns/antidiagonal,/antidiagonal/\n\n> +\t\t\t     << \" result: '\" << transposeFmt.toString() << \"'\"\n> +\t\t\t     << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Perform a transposition on an pixel order with red and blue\n> +\t\t * on the bottom left to top right diagonal and make sure\n> +\t\t * that their positions are switched.\n> +\t\t */\n> +\t\tbayerFmt = BayerFormat(BayerFormat::GBRG, 8, BayerFormat::None);\n> +\t\tbayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8,\n> +\t\t\t\t\t     BayerFormat::None);\n> +\t\ttransposeFmt = bayerFmt.transform(Transform::Transpose);\n> +\t\tif (transposeFmt != bayerFmtExpect) {\n> +\t\t\tcerr << \"Transpose with the red & blue pixels on the \"\n> +\t\t\t     << \"antidiagonal, should switch their position \"\n\nSame here.\n\n> +\t\t\t     << \" result: '\" << transposeFmt.toString() << \"'\"\n> +\t\t\t     << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(BayerFormatTest);\n\ns/;//\n\n> diff --git a/test/meson.build b/test/meson.build\n> index 7f0682ad..709b47aa 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -27,6 +27,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'],","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 C4DBBC0F2B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jan 2021 23:13:16 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 5AC8A68334;\n\tWed, 27 Jan 2021 00:13:16 +0100 (CET)","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 45304682D2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jan 2021 00:13:15 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 7C3D02C1;\n\tWed, 27 Jan 2021 00:13:14 +0100 (CET)"],"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=\"XA95jYyg\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611702794;\n\tbh=XQU4fhkjvNy3MGMYqDucT0A7ztN5e72hvW+654T18VE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=XA95jYygkD4CeD/87yUouetm9Y08c+XVIzm5vSpeXFyOH3xIgd6unyG3yscaGBvPV\n\tEPv0sGYjAUvbZd1xIZrjL28G2itYxZaZYcU4W/nGbB0XzZIqL6N8l8HOyQ5kCLd0R1\n\tR+/gtisSaJFYPSpOHuqL9oQqhx2WoNmr9NCfUgHU=","Date":"Wed, 27 Jan 2021 01:12:55 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sebastian Fricke <sebastian.fricke@posteo.net>","Message-ID":"<YBCh99qHEmpEl0l7@pendragon.ideasonboard.com>","References":"<20210126184854.46156-1-sebastian.fricke@posteo.net>\n\t<20210126184854.46156-6-sebastian.fricke@posteo.net>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20210126184854.46156-6-sebastian.fricke@posteo.net>","Subject":"Re: [libcamera-devel] [PATCH v3 5/5] 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>","Cc":"libcamera-devel@lists.libcamera.org","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>"}},{"id":14804,"web_url":"https://patchwork.libcamera.org/comment/14804/","msgid":"<YBCkAJzT8glUwp6+@pendragon.ideasonboard.com>","date":"2021-01-26T23:21:36","subject":"Re: [libcamera-devel] [PATCH v3 5/5] test: Add unit tests for the\n\tBayerFormat class","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Sebastian,\n\nA few other comments.\n\nOn Wed, Jan 27, 2021 at 01:12:56AM +0200, Laurent Pinchart wrote:\n> On Tue, Jan 26, 2021 at 07:48:54PM +0100, Sebastian Fricke wrote:\n> > Test all of the present methods including the newly implemented\n> > `fromV4L2PixelFormat`, as well as the new operators `==/!=`.\n> > \n> > Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> > Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > Reviewed-by: David Plowman <david.plowman@raspberrypi.com>\n> > Signed-off-by: Sebastian Fricke <sebastian.fricke@posteo.net>\n> > ---\n> >  test/bayer_format.cpp | 210 ++++++++++++++++++++++++++++++++++++++++++\n> >  test/meson.build      |   1 +\n> >  2 files changed, 211 insertions(+)\n> >  create mode 100644 test/bayer_format.cpp\n> > \n> > diff --git a/test/bayer_format.cpp b/test/bayer_format.cpp\n> > new file mode 100644\n> > index 00000000..f763500f\n> > --- /dev/null\n> > +++ b/test/bayer_format.cpp\n> > @@ -0,0 +1,210 @@\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> > +\n> > +#include <iostream>\n> > +\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> > +\tint run()\n> > +\t{\n> > +\t\t/* An empty Bayer format has to be invalid. */\n> > +\t\tBayerFormat bayerFmt;\n> > +\t\tif (bayerFmt.isValid()) {\n> > +\t\t\tcerr << \"An empty BayerFormat has to be invalid.\"\n> > +\t\t\t     << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/* A correct Bayer format has to be valid. */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tif (!bayerFmt.isValid()) {\n> > +\t\t\tcerr << \"A correct BayerFormat has to be valid.\"\n> > +\t\t\t     << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Two bayer formats created with the same order and bit depth\n> > +\t\t * have to be equal.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tBayerFormat bayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,\n> > +\t\t\t\t\t\t\t BayerFormat::None);\n> > +\t\tif (bayerFmt != bayerFmtExpect) {\n> > +\t\t\tcerr << \"Comparison of identical formats failed.\"\n> > +\t\t\t     << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Two Bayer formats created with the same order but with a\n> > +\t\t * different bitDepth are not equal.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tbayerFmtExpect = BayerFormat(BayerFormat::BGGR, 12,\n> > +\t\t\t\t\t     BayerFormat::None);\n> > +\t\tif (bayerFmt == bayerFmtExpect) {\n> > +\t\t\tcerr << \"Comparison of divergent formats failed.\"\n> \n> s/divergent/different/\n> \n> > +\t\t\t     << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Create a Bayer format with a V4L2PixelFormat and check if we\n> > +\t\t * get the same format after converting back to the V4L2 Format.\n> > +\t\t */\n> > +\t\tV4L2PixelFormat v4l2FmtExpect = V4L2PixelFormat(\n> > +\t\t\tV4L2_PIX_FMT_SBGGR8);\n> > +\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtExpect);\n> > +\t\tV4L2PixelFormat v4l2Fmt = bayerFmt.toV4L2PixelFormat();\n> > +\t\tif (v4l2Fmt != v4l2FmtExpect) {\n> > +\t\t\tcerr << \"Expected: '\" << v4l2FmtExpect.toString()\n> > +\t\t\t     << \"' got: '\" << v4l2Fmt.toString() << \"'\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Use an empty Bayer format and verify that no matching\n> > +\t\t * V4L2PixelFormat is found.\n> > +\t\t */\n> > +\t\tv4l2FmtExpect = V4L2PixelFormat();\n> > +\t\tbayerFmt = BayerFormat();\n> > +\t\tv4l2Fmt = bayerFmt.toV4L2PixelFormat();\n> > +\t\tif (v4l2Fmt != v4l2FmtExpect) {\n> > +\t\t\tcerr << \"Expected: empty V4L2PixelFormat got: '\"\n> > +\t\t\t     << v4l2Fmt.toString() << \"'\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Check if we get the expected Bayer format BGGR8\n> > +\t\t * when we convert the V4L2PixelFormat (V4L2_PIX_FMT_SBGGR8)\n> > +\t\t * to a Bayer format.\n> > +\t\t */\n> > +\t\tbayerFmtExpect = BayerFormat(BayerFormat::BGGR, 8,\n> > +\t\t\t\t\t     BayerFormat::None);\n> > +\t\tv4l2Fmt = V4L2PixelFormat(V4L2_PIX_FMT_SBGGR8);\n> > +\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2Fmt);\n> > +\t\tif (bayerFmt != bayerFmtExpect) {\n> > +\t\t\tcerr << \"Expected BayerFormat '\"\n> > +\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n> > +\t\t\t     << bayerFmt.toString() << \"'\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Confirm that a V4L2PixelFormat that is not found in\n> > +\t\t * the conversion table, doesn't yield a Bayer format.\n> > +\t\t */\n> > +\t\tV4L2PixelFormat v4l2FmtUnknown = V4L2PixelFormat(\n> > +\t\t\tV4L2_PIX_FMT_BGRA444);\n> > +\t\tbayerFmt = BayerFormat::fromV4L2PixelFormat(v4l2FmtUnknown);\n> > +\t\tif (bayerFmt.isValid()) {\n> > +\t\t\tcerr << \"Expected empty BayerFormat got: '\"\n> > +\t\t\t     << bayerFmt.toString() << \"'\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Test if a valid Bayer format can be converted to a\n> > +\t\t * string representation.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tif (bayerFmt.toString() != \"BGGR-8\") {\n> > +\t\t\tcerr << \"String representation != 'BGGR-8' (got: '\"\n> > +\t\t\t     << bayerFmt.toString() << \"' ) \" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Determine if an empty Bayer format results in no\n> > +\t\t * string representation.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat();\n> > +\t\tif (bayerFmt.toString() != \"INVALID\") {\n> > +\t\t\tcerr << \"String representation != 'INVALID' (got: '\"\n> > +\t\t\t     << bayerFmt.toString() << \"' ) \" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Perform a horizontal Flip and make sure that the\n> > +\t\t * order is adjusted accordingly.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tbayerFmtExpect = BayerFormat(BayerFormat::GBRG, 8,\n> > +\t\t\t\t\t     BayerFormat::None);\n> > +\t\tBayerFormat hFlipFmt = bayerFmt.transform(Transform::HFlip);\n> > +\t\tif (hFlipFmt != bayerFmtExpect) {\n> > +\t\t\tcerr << \"Horizontal flip of 'BGGR-8' should result in '\"\n> > +\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n> > +\t\t\t     << hFlipFmt.toString() << \"'\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Perform a vertical Flip and make sure that\n> > +\t\t * the order is adjusted accordingly.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tbayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8,\n> > +\t\t\t\t\t     BayerFormat::None);\n> > +\t\tBayerFormat vFlipFmt = bayerFmt.transform(Transform::VFlip);\n> > +\t\tif (vFlipFmt != bayerFmtExpect) {\n> > +\t\t\tcerr << \"Vertical flip of 'BGGR-8' should result in '\"\n> > +\t\t\t     << bayerFmtExpect.toString() << \"', got: '\"\n> > +\t\t\t     << vFlipFmt.toString() << \"'\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Perform a transposition on a pixel order with both green\n> > +\t\t * pixels on the bottom left to top right diagonal and make\n> > +\t\t * sure, that it doesn't change.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::BGGR, 8, BayerFormat::None);\n> > +\t\tBayerFormat transposeFmt = bayerFmt.transform(\n> > +\t\t\tTransform::Transpose);\n> > +\t\tif (transposeFmt != bayerFmt) {\n> > +\t\t\tcerr << \"Transpose with both green pixels on the \"\n> > +\t\t\t     << \"antidiagonal, should not change the order \"\n> \n> s/antidiagonal,/antidiagonal/\n> \n> > +\t\t\t     << \" result: '\" << transposeFmt.toString() << \"'\"\n\nThere's no line break before this line, so the message on the console\nwould look weird. I'd write\n\n\t\t\t     << \"(got '\" << transposeFmt.toString() << \"')\"\n\n> > +\t\t\t     << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Perform a transposition on an pixel order with red and blue\n> > +\t\t * on the bottom left to top right diagonal and make sure\n> > +\t\t * that their positions are switched.\n> > +\t\t */\n> > +\t\tbayerFmt = BayerFormat(BayerFormat::GBRG, 8, BayerFormat::None);\n> > +\t\tbayerFmtExpect = BayerFormat(BayerFormat::GRBG, 8,\n> > +\t\t\t\t\t     BayerFormat::None);\n> > +\t\ttransposeFmt = bayerFmt.transform(Transform::Transpose);\n> > +\t\tif (transposeFmt != bayerFmtExpect) {\n> > +\t\t\tcerr << \"Transpose with the red & blue pixels on the \"\n> > +\t\t\t     << \"antidiagonal, should switch their position \"\n> \n> Same here.\n> \n> > +\t\t\t     << \" result: '\" << transposeFmt.toString() << \"'\"\n\nSame here.\n\n> > +\t\t\t     << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\treturn TestPass;\n> > +\t}\n> > +};\n> > +\n> > +TEST_REGISTER(BayerFormatTest);\n> \n> s/;//\n> \n> > diff --git a/test/meson.build b/test/meson.build\n> > index 7f0682ad..709b47aa 100644\n> > --- a/test/meson.build\n> > +++ b/test/meson.build\n> > @@ -27,6 +27,7 @@ public_tests = [\n> >  ]\n> >  \n> >  internal_tests = [\n> > +    ['bayer-format',                    'bayer_format.cpp'],\n\nI'd rename the file to bayer-format.cpp to match the other files in this\ndirectory.\n\n> >      ['byte-stream-buffer',              'byte-stream-buffer.cpp'],\n> >      ['camera-sensor',                   'camera-sensor.cpp'],\n> >      ['event',                           'event.cpp'],","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 2BA23C0F2B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 26 Jan 2021 23:21:59 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id B10E568337;\n\tWed, 27 Jan 2021 00:21:58 +0100 (CET)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED46C682D2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jan 2021 00:21:57 +0100 (CET)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6F58B2C1;\n\tWed, 27 Jan 2021 00:21:56 +0100 (CET)"],"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=\"qr79r1XQ\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1611703316;\n\tbh=LMELA/TQq86vPkZvNlNJiTUXkktbUwyNugwWtuAeQ3Q=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=qr79r1XQPDfxnXcPp2odrZub1JouImyTOLXBXbTgDroEDqzyDQLAiiPFlXxPPD14e\n\ti0DwAaXfIntpoN3VEyzNuDqZw33li2rxTne1YfNKa/6r5sIVqBPHw6Qmzk/vAW0yHP\n\toGz/Xs+Jk3U4aWsGkxATCceegKQfNlQEf9mzCWio=","Date":"Wed, 27 Jan 2021 01:21:36 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Sebastian Fricke <sebastian.fricke@posteo.net>","Message-ID":"<YBCkAJzT8glUwp6+@pendragon.ideasonboard.com>","References":"<20210126184854.46156-1-sebastian.fricke@posteo.net>\n\t<20210126184854.46156-6-sebastian.fricke@posteo.net>\n\t<YBCh99qHEmpEl0l7@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<YBCh99qHEmpEl0l7@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 5/5] 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>","Cc":"libcamera-devel@lists.libcamera.org","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>"}}]