[{"id":905,"web_url":"https://patchwork.libcamera.org/comment/905/","msgid":"<26f97bc6-b8d9-4377-66c2-f28487d95a8f@ideasonboard.com>","date":"2019-02-26T23:50:37","subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Hi Jacopo,\n\nOn 26/02/2019 16:26, Jacopo Mondi wrote:\n> Add test to list formats on a v4l2 subdevice.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  test/v4l2_subdevice/list_formats.cpp | 76 ++++++++++++++++++++++++++++\n>  test/v4l2_subdevice/meson.build      |  1 +\n>  2 files changed, 77 insertions(+)\n>  create mode 100644 test/v4l2_subdevice/list_formats.cpp\n> \n> diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp\n> new file mode 100644\n> index 000000000000..3c4737a17afc\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/list_formats.cpp\n> @@ -0,0 +1,76 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * libcamera V4L2 Subdevice format handling test\n> + */\n> +\n> +#include <iostream>\n> +#include <vector>\n> +\n> +#include \"v4l2_subdevice.h\"\n> +\n> +#include \"v4l2_subdevice_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/* List image formats on the \"Scaler\" subdevice of vimc media device.  */\n> +\n> +class ListFormatsTest : public V4L2SubdeviceTest\n> +{\n> +protected:\n> +\tint run();\n> +\n> +private:\n> +\tvoid printFormats(unsigned int pad,\n> +\t\t\t  std::vector<V4L2SubdeviceFormat> &formats);\n> +};\n> +\n> +void ListFormatsTest::printFormats(unsigned int pad,\n> +\t\t\t\t   std::vector<V4L2SubdeviceFormat> &formats)\n> +{\n> +\tcout << \"Enumerate formats on pad \" << pad << endl;\n> +\tfor (V4L2SubdeviceFormat &format : formats) {\n> +\t\tcout << \"\tMbus code: 0x\" << hex << format.mbus_code << endl;\n> +\t\tcout << \"\tWidth: \" << dec << format.width << endl;\n> +\t\tcout << \"\tHeight: \" << dec << format.height << endl;\n> +\t}\n> +}\n> +\n> +int ListFormatsTest::run()\n> +{\n> +\t/* List all formats available on existing \"Scaler\" pads. */\n> +\tstd::vector<V4L2SubdeviceFormat> formats = {};\n> +\n> +\tformats = scaler_->formats(0);\n> +\tif (formats.empty()) {\n> +\t\tcerr << \"Failed to list formats on pad 0 of sudevice \"\n\nIs the 'list' a verb or a noun in listFormats?\n\nShould it be getFormats()? or enumFormats() in the Subdevice\nimplementation as it seems formats() will name clash :)\n\n\n> +\t\t     << scaler_->deviceNode() << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\tprintFormats(0, formats);\n> +> +\tformats = {};\n> +\tformats = scaler_->formats(1);\n> +\tif (formats.empty()) {\n> +\t\tcerr << \"Failed to list formats on pad 1 of sudevice \"\n\ns/sudevice/subdevice/ here and above on pad 0.\n\n> +\t\t     << scaler_->deviceNode() << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\tprintFormats(1, formats);\n> +\n> +\t/* List format on a non-existing pad, format vector shall be empty. */\n> +\tformats = {};\n> +\tformats = scaler_->formats(2);\n> +\tif (!formats.empty()) {\n> +\t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n> +\t\t     << scaler_->deviceNode()\n> +\t\t     << \" should return an empty format list\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n> +}\n> +\n> +TEST_REGISTER(ListFormatsTest);\n> diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\n> index a4359fe1bc19..6023d15e1558 100644\n> --- a/test/v4l2_subdevice/meson.build\n> +++ b/test/v4l2_subdevice/meson.build\n> @@ -1,4 +1,5 @@\n>  v4l2_subdevice_tests = [\n> +  [ 'list_formats',             'list_formats.cpp'],\n>    [ 'test_formats',             'test_formats.cpp'],\n>  ]\n>  \n>","headers":{"Return-Path":"<kieran.bingham@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 BAE9A610B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 00:50:40 +0100 (CET)","from [192.168.0.21]\n\t(cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 9C16167;\n\tWed, 27 Feb 2019 00:50:39 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551225039;\n\tbh=E+clz+RWlhkv7y9yLRWKLFvbSk3qGH+wvdDZx9jzh1g=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=vzHAhNFAljWNJFOAf26/3XDbvMEf41OLmy2omB5C3Bg9HzQKl22m186jDACBWGDoG\n\tuScAtFM5qO8vkA7RWSm833NyLjQtr+NjDBRDtMSqMMvsAvJFftYF+mk8w2NZ2YZCnK\n\tQSVchcIm1vjfWJM4uqzXs0mAFqzkabb9ZEkpRx5o=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-7-jacopo@jmondi.org>","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Openpgp":"preference=signencrypt","Autocrypt":"addr=kieran.bingham@ideasonboard.com; keydata=\n\tmQINBFYE/WYBEACs1PwjMD9rgCu1hlIiUA1AXR4rv2v+BCLUq//vrX5S5bjzxKAryRf0uHat\n\tV/zwz6hiDrZuHUACDB7X8OaQcwhLaVlq6byfoBr25+hbZG7G3+5EUl9cQ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o89IeqljaRsCdP\n\t7WCIECWYem6pLwaw6IAL7oX+tEqIMPph/G/jwZcdS6Hkyt/esHPuHNwX4guqTbVEuRqbDzDI\n\t2DJO5FbxABEBAAGJAiUEGAEKAA8CGwwFAlnDlGsFCQeA/gIACgkQoR5GchCkYf1yYRAAq+Yo\n\tnbf9DGdK1kTAm2RTFg+w9oOp2Xjqfhds2PAhFFvrHQg1XfQR/UF/SjeUmaOmLSczM0s6XMeO\n\tVcE77UFtJ/+hLo4PRFKm5X1Pcar6g5m4xGqa+Xfzi9tRkwC29KMCoQOag1BhHChgqYaUH3yo\n\tUzaPwT/fY75iVI+yD0ih/e6j8qYvP8pvGwMQfrmN9YB0zB39YzCSdaUaNrWGD3iCBxg6lwSO\n\tLKeRhxxfiXCIYEf3vwOsP3YMx2JkD5doseXmWBGW1U0T/oJF+DVfKB6mv5UfsTzpVhJRgee7\n\t4jkjqFq4qsUGxcvF2xtRkfHFpZDbRgRlVmiWkqDkT4qMA+4q1y/dWwshSKi/uwVZNycuLsz+\n\t+OD8xPNCsMTqeUkAKfbD8xW4LCay3r/dD2ckoxRxtMD9eOAyu5wYzo/ydIPTh1QEj9SYyvp8\n\tO0g6CpxEwyHUQtF5oh15O018z3ZLztFJKR3RD42VKVsrnNDKnoY0f4U0z7eJv2NeF8xHMuiU\n\tRCIzqxX1GVYaNkKTnb/Qja8hnYnkUzY1Lc+OtwiGmXTwYsPZjjAaDX35J/RSKAoy5wGo/YFA\n\tJxB1gWThL4kOTbsqqXj9GLcyOImkW0lJGGR3o/fV91Zh63S5TKnf2YGGGzxki+ADdxVQAm+Q\n\tsbsRB8KNNvVXBOVNwko86rQqF9drZuw=","Organization":"Ideas on Board","Message-ID":"<26f97bc6-b8d9-4377-66c2-f28487d95a8f@ideasonboard.com>","Date":"Tue, 26 Feb 2019 23:50:37 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.4.0","MIME-Version":"1.0","In-Reply-To":"<20190226162641.12116-7-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Tue, 26 Feb 2019 23:50:40 -0000"}},{"id":911,"web_url":"https://patchwork.libcamera.org/comment/911/","msgid":"<20190227083743.vzyzopabkbpxwgjc@uno.localdomain>","date":"2019-02-27T08:37:43","subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Kieran,\n\nOn Tue, Feb 26, 2019 at 11:50:37PM +0000, Kieran Bingham wrote:\n> Hi Jacopo,\n>\n> On 26/02/2019 16:26, Jacopo Mondi wrote:\n> > Add test to list formats on a v4l2 subdevice.\n> >\n\n[snip]\n\n> > +int ListFormatsTest::run()\n> > +{\n> > +\t/* List all formats available on existing \"Scaler\" pads. */\n> > +\tstd::vector<V4L2SubdeviceFormat> formats = {};\n> > +\n> > +\tformats = scaler_->formats(0);\n> > +\tif (formats.empty()) {\n> > +\t\tcerr << \"Failed to list formats on pad 0 of sudevice \"\n>\n> Is the 'list' a verb or a noun in listFormats?\n>\n\nI interpreted it as a verb.\n\n> Should it be getFormats()? or enumFormats() in the Subdevice\n> implementation as it seems formats() will name clash :)\n\ngetFormats() is easily confusable with getFormat(), enumFormats()\nmight make sense, but recalls the SUBDEV_ENUM_ ioctls, which have a\ndifferent behaviour.\n\nAs the 'formats()' methods return the 'formats_' field, which is a\nvector of formats, according to out policy that getters should just\nrepeat the name of the field they access, I would keep 'formats()' as\nthe method name, even if I might have missed which name clash you're\nreporting here...\n\nThanks\n  j\n\n>\n>\n> > +\t\t     << scaler_->deviceNode() << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\tprintFormats(0, formats);\n> > +> +\tformats = {};\n> > +\tformats = scaler_->formats(1);\n> > +\tif (formats.empty()) {\n> > +\t\tcerr << \"Failed to list formats on pad 1 of sudevice \"\n>\n> s/sudevice/subdevice/ here and above on pad 0.\n>\n> > +\t\t     << scaler_->deviceNode() << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\tprintFormats(1, formats);\n> > +\n> > +\t/* List format on a non-existing pad, format vector shall be empty. */\n> > +\tformats = {};\n> > +\tformats = scaler_->formats(2);\n> > +\tif (!formats.empty()) {\n> > +\t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n> > +\t\t     << scaler_->deviceNode()\n> > +\t\t     << \" should return an empty format list\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\treturn TestPass;\n> > +}\n> > +\n> > +TEST_REGISTER(ListFormatsTest);\n> > diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\n> > index a4359fe1bc19..6023d15e1558 100644\n> > --- a/test/v4l2_subdevice/meson.build\n> > +++ b/test/v4l2_subdevice/meson.build\n> > @@ -1,4 +1,5 @@\n> >  v4l2_subdevice_tests = [\n> > +  [ 'list_formats',             'list_formats.cpp'],\n> >    [ 'test_formats',             'test_formats.cpp'],\n> >  ]\n> >\n> >\n>\n> --\n> Regards\n> --\n> Kieran","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id ED2BD601E2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 09:37:14 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 6C13F40009;\n\tWed, 27 Feb 2019 08:37:14 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Wed, 27 Feb 2019 09:37:43 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190227083743.vzyzopabkbpxwgjc@uno.localdomain>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-7-jacopo@jmondi.org>\n\t<26f97bc6-b8d9-4377-66c2-f28487d95a8f@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"qabybtmysppoabkf\"","Content-Disposition":"inline","In-Reply-To":"<26f97bc6-b8d9-4377-66c2-f28487d95a8f@ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Wed, 27 Feb 2019 08:37:15 -0000"}},{"id":933,"web_url":"https://patchwork.libcamera.org/comment/933/","msgid":"<20190227182721.GP4813@pendragon.ideasonboard.com>","date":"2019-02-27T18:27:22","subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Jacopo,\n\nThank you for the patch.\n\nOn Tue, Feb 26, 2019 at 05:26:39PM +0100, Jacopo Mondi wrote:\n> Add test to list formats on a v4l2 subdevice.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  test/v4l2_subdevice/list_formats.cpp | 76 ++++++++++++++++++++++++++++\n>  test/v4l2_subdevice/meson.build      |  1 +\n>  2 files changed, 77 insertions(+)\n>  create mode 100644 test/v4l2_subdevice/list_formats.cpp\n> \n> diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp\n> new file mode 100644\n> index 000000000000..3c4737a17afc\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/list_formats.cpp\n> @@ -0,0 +1,76 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * libcamera V4L2 Subdevice format handling test\n> + */\n> +\n> +#include <iostream>\n> +#include <vector>\n> +\n> +#include \"v4l2_subdevice.h\"\n> +\n\nMaybe no need for a blank line here either ?\n\n> +#include \"v4l2_subdevice_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/* List image formats on the \"Scaler\" subdevice of vimc media device.  */\n> +\n> +class ListFormatsTest : public V4L2SubdeviceTest\n> +{\n> +protected:\n> +\tint run();\n\noverride ?\n\n> +\n> +private:\n> +\tvoid printFormats(unsigned int pad,\n> +\t\t\t  std::vector<V4L2SubdeviceFormat> &formats);\n> +};\n> +\n> +void ListFormatsTest::printFormats(unsigned int pad,\n> +\t\t\t\t   std::vector<V4L2SubdeviceFormat> &formats)\n> +{\n> +\tcout << \"Enumerate formats on pad \" << pad << endl;\n> +\tfor (V4L2SubdeviceFormat &format : formats) {\n> +\t\tcout << \"\tMbus code: 0x\" << hex << format.mbus_code << endl;\n> +\t\tcout << \"\tWidth: \" << dec << format.width << endl;\n> +\t\tcout << \"\tHeight: \" << dec << format.height << endl;\n> +\t}\n> +}\n> +\n> +int ListFormatsTest::run()\n> +{\n> +\t/* List all formats available on existing \"Scaler\" pads. */\n> +\tstd::vector<V4L2SubdeviceFormat> formats = {};\n\nNo need to initialize the vector as you overwrite it on the next line.\n\n> +\n> +\tformats = scaler_->formats(0);\n> +\tif (formats.empty()) {\n> +\t\tcerr << \"Failed to list formats on pad 0 of sudevice \"\n\ns/sudevice/subdevice/\n\n> +\t\t     << scaler_->deviceNode() << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\tprintFormats(0, formats);\n> +\n> +\tformats = {};\n\nNo need for this.\n\n> +\tformats = scaler_->formats(1);\n> +\tif (formats.empty()) {\n> +\t\tcerr << \"Failed to list formats on pad 1 of sudevice \"\n\ns/sudevice/subdevice/\n\n> +\t\t     << scaler_->deviceNode() << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\tprintFormats(1, formats);\n> +\n> +\t/* List format on a non-existing pad, format vector shall be empty. */\n> +\tformats = {};\n\nSame here.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\tformats = scaler_->formats(2);\n> +\tif (!formats.empty()) {\n> +\t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n> +\t\t     << scaler_->deviceNode()\n> +\t\t     << \" should return an empty format list\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n> +}\n> +\n> +TEST_REGISTER(ListFormatsTest);\n> diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\n> index a4359fe1bc19..6023d15e1558 100644\n> --- a/test/v4l2_subdevice/meson.build\n> +++ b/test/v4l2_subdevice/meson.build\n> @@ -1,4 +1,5 @@\n>  v4l2_subdevice_tests = [\n> +  [ 'list_formats',             'list_formats.cpp'],\n>    [ 'test_formats',             'test_formats.cpp'],\n>  ]\n>","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CCD3C610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 19:27:35 +0100 (CET)","from pendragon.ideasonboard.com (unknown [83.145.195.18])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 45C9549;\n\tWed, 27 Feb 2019 19:27:33 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551292055;\n\tbh=hd0w2CzXQO31KuE93SiNfIyINsnVJngiz+E+5C1EK2c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=S44yDGG5OUOo8oTAGKdYGXo2YQnN5QbfJ6jwXxqm6n7OgzPXd7xCQWG8JqWdRQJKS\n\tXwAVT8aD7M0VProHZWEBmchNGAKbm/NQAPqds77AbDMNGA8apqkIL1B7LVtCAxEVmu\n\tb6kuRpiKKDXZLlE2CXrLCUEYBeBnU6Fo43VEMylM=","Date":"Wed, 27 Feb 2019 20:27:22 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190227182721.GP4813@pendragon.ideasonboard.com>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-7-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190226162641.12116-7-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Wed, 27 Feb 2019 18:27:36 -0000"}},{"id":942,"web_url":"https://patchwork.libcamera.org/comment/942/","msgid":"<20190228085158.aulhh7nfagjh4dhb@uno.localdomain>","date":"2019-02-28T08:51:58","subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent,\n\nOn Wed, Feb 27, 2019 at 08:27:22PM +0200, Laurent Pinchart wrote:\n> Hi Jacopo,\n>\n> Thank you for the patch.\n>\n> On Tue, Feb 26, 2019 at 05:26:39PM +0100, Jacopo Mondi wrote:\n> > Add test to list formats on a v4l2 subdevice.\n> >\n> > Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> > ---\n> >  test/v4l2_subdevice/list_formats.cpp | 76 ++++++++++++++++++++++++++++\n> >  test/v4l2_subdevice/meson.build      |  1 +\n> >  2 files changed, 77 insertions(+)\n> >  create mode 100644 test/v4l2_subdevice/list_formats.cpp\n> >\n> > diff --git a/test/v4l2_subdevice/list_formats.cpp b/test/v4l2_subdevice/list_formats.cpp\n> > new file mode 100644\n> > index 000000000000..3c4737a17afc\n> > --- /dev/null\n> > +++ b/test/v4l2_subdevice/list_formats.cpp\n> > @@ -0,0 +1,76 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2019, Google Inc.\n> > + *\n> > + * libcamera V4L2 Subdevice format handling test\n> > + */\n> > +\n> > +#include <iostream>\n> > +#include <vector>\n> > +\n> > +#include \"v4l2_subdevice.h\"\n> > +\n>\n> Maybe no need for a blank line here either ?\n>\n> > +#include \"v4l2_subdevice_test.h\"\n> > +\n> > +using namespace std;\n> > +using namespace libcamera;\n> > +\n> > +/* List image formats on the \"Scaler\" subdevice of vimc media device.  */\n> > +\n> > +class ListFormatsTest : public V4L2SubdeviceTest\n> > +{\n> > +protected:\n> > +\tint run();\n>\n> override ?\n>\n> > +\n> > +private:\n> > +\tvoid printFormats(unsigned int pad,\n> > +\t\t\t  std::vector<V4L2SubdeviceFormat> &formats);\n> > +};\n> > +\n> > +void ListFormatsTest::printFormats(unsigned int pad,\n> > +\t\t\t\t   std::vector<V4L2SubdeviceFormat> &formats)\n> > +{\n> > +\tcout << \"Enumerate formats on pad \" << pad << endl;\n> > +\tfor (V4L2SubdeviceFormat &format : formats) {\n> > +\t\tcout << \"\tMbus code: 0x\" << hex << format.mbus_code << endl;\n> > +\t\tcout << \"\tWidth: \" << dec << format.width << endl;\n> > +\t\tcout << \"\tHeight: \" << dec << format.height << endl;\n> > +\t}\n> > +}\n> > +\n> > +int ListFormatsTest::run()\n> > +{\n> > +\t/* List all formats available on existing \"Scaler\" pads. */\n> > +\tstd::vector<V4L2SubdeviceFormat> formats = {};\n>\n> No need to initialize the vector as you overwrite it on the next line.\n>\n> > +\n> > +\tformats = scaler_->formats(0);\n> > +\tif (formats.empty()) {\n> > +\t\tcerr << \"Failed to list formats on pad 0 of sudevice \"\n>\n> s/sudevice/subdevice/\n>\n> > +\t\t     << scaler_->deviceNode() << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\tprintFormats(0, formats);\n> > +\n> > +\tformats = {};\n>\n> No need for this.\n>\n\nI -really- wanted this vector to be initialized!\n\nThanks\n  j\n\n> > +\tformats = scaler_->formats(1);\n> > +\tif (formats.empty()) {\n> > +\t\tcerr << \"Failed to list formats on pad 1 of sudevice \"\n>\n> s/sudevice/subdevice/\n>\n> > +\t\t     << scaler_->deviceNode() << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\tprintFormats(1, formats);\n> > +\n> > +\t/* List format on a non-existing pad, format vector shall be empty. */\n> > +\tformats = {};\n>\n> Same here.\n>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n>\n> > +\tformats = scaler_->formats(2);\n> > +\tif (!formats.empty()) {\n> > +\t\tcerr << \"Listing formats on non-existing pad 2 of subdevice \"\n> > +\t\t     << scaler_->deviceNode()\n> > +\t\t     << \" should return an empty format list\" << endl;\n> > +\t\treturn TestFail;\n> > +\t}\n> > +\n> > +\treturn TestPass;\n> > +}\n> > +\n> > +TEST_REGISTER(ListFormatsTest);\n> > diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\n> > index a4359fe1bc19..6023d15e1558 100644\n> > --- a/test/v4l2_subdevice/meson.build\n> > +++ b/test/v4l2_subdevice/meson.build\n> > @@ -1,4 +1,5 @@\n> >  v4l2_subdevice_tests = [\n> > +  [ 'list_formats',             'list_formats.cpp'],\n> >    [ 'test_formats',             'test_formats.cpp'],\n> >  ]\n> >\n>\n> --\n> Regards,\n>\n> Laurent Pinchart","headers":{"Return-Path":"<jacopo@jmondi.org>","Received":["from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net\n\t[217.70.183.194])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 87BE4600FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 28 Feb 2019 09:51:28 +0100 (CET)","from uno.localdomain (2-224-242-101.ip172.fastwebnet.it\n\t[2.224.242.101]) (Authenticated sender: jacopo@jmondi.org)\n\tby relay2-d.mail.gandi.net (Postfix) with ESMTPSA id 0FE6740005;\n\tThu, 28 Feb 2019 08:51:27 +0000 (UTC)"],"X-Originating-IP":"2.224.242.101","Date":"Thu, 28 Feb 2019 09:51:58 +0100","From":"Jacopo Mondi <jacopo@jmondi.org>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190228085158.aulhh7nfagjh4dhb@uno.localdomain>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-7-jacopo@jmondi.org>\n\t<20190227182721.GP4813@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"multipart/signed; micalg=pgp-sha256;\n\tprotocol=\"application/pgp-signature\"; boundary=\"3ardpfcaicvwl77c\"","Content-Disposition":"inline","In-Reply-To":"<20190227182721.GP4813@pendragon.ideasonboard.com>","User-Agent":"NeoMutt/20180716","Subject":"Re: [libcamera-devel] [PATCH v3 6/8] test: v4l2_subdevice: Add\n\tListFormat test","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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":"Thu, 28 Feb 2019 08:51:28 -0000"}}]