[{"id":904,"web_url":"https://patchwork.libcamera.org/comment/904/","msgid":"<f7c262a6-8b96-c7ea-5118-a7673cbdfa82@ideasonboard.com>","date":"2019-02-26T23:40:37","subject":"Re: [libcamera-devel] [PATCH v3 5/8] test: v4l2_subdevice: Add\n\tformat handling 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 for video format get and set operations on V4L2Subdevice class.\n> \n\nSmall comment fix below but otherwise looks like a good start to get the\ntests in place.\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  test/meson.build                            |  1 +\n>  test/v4l2_subdevice/meson.build             | 10 +++\n>  test/v4l2_subdevice/test_formats.cpp        | 79 ++++++++++++++++++\n>  test/v4l2_subdevice/v4l2_subdevice_test.cpp | 90 +++++++++++++++++++++\n>  test/v4l2_subdevice/v4l2_subdevice_test.h   | 36 +++++++++\n>  5 files changed, 216 insertions(+)\n>  create mode 100644 test/v4l2_subdevice/meson.build\n>  create mode 100644 test/v4l2_subdevice/test_formats.cpp\n>  create mode 100644 test/v4l2_subdevice/v4l2_subdevice_test.cpp\n>  create mode 100644 test/v4l2_subdevice/v4l2_subdevice_test.h\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index d515a716207e..5fb16fa6afb6 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -3,6 +3,7 @@ subdir('libtest')\n>  subdir('media_device')\n>  subdir('pipeline')\n>  subdir('v4l2_device')\n> +subdir('v4l2_subdevice')\n>  \n>  public_tests = [\n>      ['event',                           'event.cpp'],\n> diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\n> new file mode 100644\n> index 000000000000..a4359fe1bc19\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/meson.build\n> @@ -0,0 +1,10 @@\n> +v4l2_subdevice_tests = [\n> +  [ 'test_formats',             'test_formats.cpp'],\n> +]\n> +\n> +foreach t : v4l2_subdevice_tests\n> +  exe = executable(t[0], [t[1], 'v4l2_subdevice_test.cpp'],\n> +            link_with : test_libraries,\n> +            include_directories : test_includes_internal)\n> +  test(t[0], exe, suite: 'v4l2_subdevice', is_parallel: false)\n> +endforeach\n> diff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\n> new file mode 100644\n> index 000000000000..91b460f64e7e\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/test_formats.cpp\n> @@ -0,0 +1,79 @@\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 <climits>\n> +#include <iostream>\n> +\n> +#include \"v4l2_subdevice.h\"\n> +\n> +#include \"v4l2_subdevice_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/* Test format handling on the \"Scaler\" subdevice of vimc media device.  */\n> +\n> +class FormatHandlingTest : public V4L2SubdeviceTest\n> +{\n> +protected:\n> +\tint run();\n> +};\n> +\n> +int FormatHandlingTest::run()\n> +{\n> +\tV4L2SubdeviceFormat format = {};\n> +\n> +\t/*\n> +\t * Get format on a non-existing Scaler pad: expect failure.\n> +\t */\n> +\tint ret = scaler_->getFormat(2, &format);\n> +\tif (!ret) {\n> +\t\tcerr << \"Get format on a non existing pad should fail\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tret = scaler_->getFormat(0, &format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to get format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\t/*\n> +\t * Set unrealistic image resolutions and make sure it gets updated.\n> +\t */\n> +\tformat.width = UINT_MAX;\n> +\tformat.height = UINT_MAX;\n> +\tret = scaler_->setFormat(0, &format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tformat.width = 0;\n> +\tformat.height = 0;\n> +\tret = scaler_->setFormat(0, &format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == 0 || format.height == 0) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n> +}\n> +\n> +TEST_REGISTER(FormatHandlingTest);\n> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> new file mode 100644\n> index 000000000000..10fe2655e5e4\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> @@ -0,0 +1,90 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * v4l2_subdevice_test.cpp - V4L2 subdevice test\n> + */\n> +\n> +#include <iostream>\n> +#include <string.h>\n> +#include <sys/stat.h>\n> +\n> +#include \"device_enumerator.h\"\n> +#include \"media_device.h\"\n> +#include \"v4l2_subdevice.h\"\n> +\n> +#include \"v4l2_subdevice_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/*\n> + * This test runs on vimc media device. For a description of vimc, in the\n> + * context of libcamera testingrefer to\n\ns/testingrefer to/testing, please refer to the/\n\n> + * 'test/media_device/media_device_link_test.cpp' file.\n> + *\n> + * If the vimc module is not loaded, the test gets skipped.\n> + */\n> +\n> +int V4L2SubdeviceTest::init()\n> +{\n> +\tenumerator_ = DeviceEnumerator::create();\n> +\tif (!enumerator_) {\n> +\t\tcerr << \"Failed to create device enumerator\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (enumerator_->enumerate()) {\n> +\t\tcerr << \"Failed to enumerate media devices\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tDeviceMatch dm(\"vimc\");\n> +\tmedia_ = std::move(enumerator_->search(dm));\n> +\tif (!media_) {\n> +\t\tcerr << \"Unable to find \\'vimc\\' media device node\" << endl;\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\tmedia_->acquire();\n> +\n> +\tint ret = media_->open();\n> +\tif (ret) {\n> +\t\tcerr << \"Unable to open media device: \" << media_->deviceNode()\n> +\t\t     << \": \" << strerror(ret) << endl;\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\tMediaEntity *videoEntity = media_->getEntityByName(\"Scaler\");\n> +\tif (!videoEntity) {\n> +\t\tcerr << \"Unable to find media entity 'Scaler'\" << endl;\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\tscaler_ = new V4L2Subdevice(videoEntity);\n> +\tif (!scaler_) {\n> +\t\tcerr << \"Unable to create media device from media entity: \"\n> +\t\t     << videoEntity->deviceNode();\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\tret = scaler_->open();\n> +\tif (ret) {\n> +\t\tcerr << \"Unable to open video subdevice \"\n> +\t\t     << scaler_->deviceNode() << endl;\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n> +void V4L2SubdeviceTest::cleanup()\n> +{\n> +\tmedia_->release();\n> +\n> +\tdelete scaler_;\n> +}\n> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h\n> new file mode 100644\n> index 000000000000..7b64c6122745\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.h\n> @@ -0,0 +1,36 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * v4l2_subdevice_test.h - V4L2 subdevice test\n> + */\n> +\n> +#ifndef __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_\n> +#define __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_\n> +\n> +#include <libcamera/buffer.h>\n> +\n> +#include \"device_enumerator.h\"\n> +#include \"media_device.h\"\n> +#include \"test.h\"\n> +#include \"v4l2_subdevice.h\"\n> +\n> +using namespace libcamera;\n> +\n> +class V4L2SubdeviceTest : public Test\n> +{\n> +public:\n> +\tV4L2SubdeviceTest()\n> +\t\t: scaler_(nullptr){};\n> +\n> +protected:\n> +\tint init();\n> +\tvirtual int run() = 0;\n> +\tvoid cleanup();\n> +\n> +\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n> +\tstd::shared_ptr<MediaDevice> media_;\n> +\tV4L2Subdevice *scaler_;\n> +};\n> +\n> +#endif /* __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_ */\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 EC4E1610B2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 00:40: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 BA93967;\n\tWed, 27 Feb 2019 00:40:39 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551224439;\n\tbh=6mKXxHweGs//0wOzLmSf91tpDFKM0j14juxNN9K36H0=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=eomjfhXAeVh8WY0gfc4l7+dtyA/QKuI0JM940t7HCeKscHgEOlGfd82hCQ1gu+usB\n\tQHdS50OLKtEz/QIlPffanL5I1tDe91AsJZT4ZUF/Jg4cdOLT9TTGQdAv9L1DFPkdnM\n\tWy5ESz1b/mIDGI7Rxzuq2KWkG6ljonZbaO2qxxjw=","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-6-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+5EUl9cQ7dQEdvNj6V6y/SC\n\trRanWfelwQThCHckbobWiQJfK9n7rYNcPMq9B8e9F020LFH7Kj6YmO95ewJGgLm+idg1Kb3C\n\tpotzWkXc1xmPzcQ1fvQMOfMwdS+4SNw4rY9f07Xb2K99rjMwZVDgESKIzhsDB5GY465sCsiQ\n\tcSAZRxqE49RTBq2+EQsbrQpIc8XiffAB8qexh5/QPzCmR4kJgCGeHIXBtgRj+nIkCJPZvZtf\n\tKr2EAbc6tgg6DkAEHJb+1okosV09+0+TXywYvtEop/WUOWQ+zo+Y/OBd+8Ptgt1pDRyOBzL8\n\tRXa8ZqRf0Mwg75D+dKntZeJHzPRJyrlfQokngAAs4PaFt6UfS+ypMAF37T6CeDArQC41V3ko\n\tlPn1yMsVD0p+6i3DPvA/GPIksDC4owjnzVX9kM8Zc5Cx+XoAN0w5Eqo4t6qEVbuettxx55gq\n\t8K8FieAjgjMSxngo/HST8TpFeqI5nVeq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pZDbRgRlVmiWkqDkT4qMA+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":"<f7c262a6-8b96-c7ea-5118-a7673cbdfa82@ideasonboard.com>","Date":"Tue, 26 Feb 2019 23:40: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-6-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"7bit","Subject":"Re: [libcamera-devel] [PATCH v3 5/8] test: v4l2_subdevice: Add\n\tformat handling 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:40:41 -0000"}},{"id":931,"web_url":"https://patchwork.libcamera.org/comment/931/","msgid":"<20190227180416.GN4813@pendragon.ideasonboard.com>","date":"2019-02-27T18:04:16","subject":"Re: [libcamera-devel] [PATCH v3 5/8] test: v4l2_subdevice: Add\n\tformat handling 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:38PM +0100, Jacopo Mondi wrote:\n> Add test for video format get and set operations on V4L2Subdevice class.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  test/meson.build                            |  1 +\n>  test/v4l2_subdevice/meson.build             | 10 +++\n>  test/v4l2_subdevice/test_formats.cpp        | 79 ++++++++++++++++++\n>  test/v4l2_subdevice/v4l2_subdevice_test.cpp | 90 +++++++++++++++++++++\n>  test/v4l2_subdevice/v4l2_subdevice_test.h   | 36 +++++++++\n>  5 files changed, 216 insertions(+)\n>  create mode 100644 test/v4l2_subdevice/meson.build\n>  create mode 100644 test/v4l2_subdevice/test_formats.cpp\n>  create mode 100644 test/v4l2_subdevice/v4l2_subdevice_test.cpp\n>  create mode 100644 test/v4l2_subdevice/v4l2_subdevice_test.h\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index d515a716207e..5fb16fa6afb6 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -3,6 +3,7 @@ subdir('libtest')\n>  subdir('media_device')\n>  subdir('pipeline')\n>  subdir('v4l2_device')\n> +subdir('v4l2_subdevice')\n>  \n>  public_tests = [\n>      ['event',                           'event.cpp'],\n> diff --git a/test/v4l2_subdevice/meson.build b/test/v4l2_subdevice/meson.build\n> new file mode 100644\n> index 000000000000..a4359fe1bc19\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/meson.build\n> @@ -0,0 +1,10 @@\n> +v4l2_subdevice_tests = [\n> +  [ 'test_formats',             'test_formats.cpp'],\n> +]\n> +\n> +foreach t : v4l2_subdevice_tests\n> +  exe = executable(t[0], [t[1], 'v4l2_subdevice_test.cpp'],\n> +            link_with : test_libraries,\n> +            include_directories : test_includes_internal)\n> +  test(t[0], exe, suite: 'v4l2_subdevice', is_parallel: false)\n> +endforeach\n\n4 spaces for indentation ?\n\n> diff --git a/test/v4l2_subdevice/test_formats.cpp b/test/v4l2_subdevice/test_formats.cpp\n> new file mode 100644\n> index 000000000000..91b460f64e7e\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/test_formats.cpp\n> @@ -0,0 +1,79 @@\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 <climits>\n> +#include <iostream>\n> +\n> +#include \"v4l2_subdevice.h\"\n> +\n\nDo we need a blank line here ?\n\n> +#include \"v4l2_subdevice_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/* Test format handling on the \"Scaler\" subdevice of vimc media device.  */\n> +\n> +class FormatHandlingTest : public V4L2SubdeviceTest\n> +{\n> +protected:\n> +\tint run();\n\noverride ?\n\n> +};\n> +\n> +int FormatHandlingTest::run()\n> +{\n> +\tV4L2SubdeviceFormat format = {};\n> +\n> +\t/*\n> +\t * Get format on a non-existing Scaler pad: expect failure.\n> +\t */\n> +\tint ret = scaler_->getFormat(2, &format);\n> +\tif (!ret) {\n> +\t\tcerr << \"Get format on a non existing pad should fail\" << endl;\n\ns/Get/Getting/ or s/Get format/getFormat()/ ?\n\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tret = scaler_->getFormat(0, &format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to get format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\t/*\n> +\t * Set unrealistic image resolutions and make sure it gets updated.\n> +\t */\n> +\tformat.width = UINT_MAX;\n> +\tformat.height = UINT_MAX;\n> +\tret = scaler_->setFormat(0, &format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == UINT_MAX || format.height == UINT_MAX) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tformat.width = 0;\n> +\tformat.height = 0;\n> +\tret = scaler_->setFormat(0, &format);\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to set format: image resolution is wrong, but \"\n> +\t\t     << \"setFormat() should not fail.\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (format.width == 0 || format.height == 0) {\n> +\t\tcerr << \"Failed to update image format\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n> +}\n> +\n> +TEST_REGISTER(FormatHandlingTest);\n> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.cpp b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> new file mode 100644\n> index 000000000000..10fe2655e5e4\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.cpp\n> @@ -0,0 +1,90 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * v4l2_subdevice_test.cpp - V4L2 subdevice test\n\nMaybe \"VIMC-based V4L2 subdevice test\" given that the test class\nrequires VIMC ?\n\n> + */\n> +\n> +#include <iostream>\n> +#include <string.h>\n> +#include <sys/stat.h>\n> +\n> +#include \"device_enumerator.h\"\n> +#include \"media_device.h\"\n> +#include \"v4l2_subdevice.h\"\n> +\n> +#include \"v4l2_subdevice_test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/*\n> + * This test runs on vimc media device. For a description of vimc, in the\n> + * context of libcamera testingrefer to\n> + * 'test/media_device/media_device_link_test.cpp' file.\n> + *\n> + * If the vimc module is not loaded, the test gets skipped.\n> + */\n> +\n> +int V4L2SubdeviceTest::init()\n> +{\n> +\tenumerator_ = DeviceEnumerator::create();\n> +\tif (!enumerator_) {\n> +\t\tcerr << \"Failed to create device enumerator\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tif (enumerator_->enumerate()) {\n> +\t\tcerr << \"Failed to enumerate media devices\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\tDeviceMatch dm(\"vimc\");\n> +\tmedia_ = std::move(enumerator_->search(dm));\n> +\tif (!media_) {\n> +\t\tcerr << \"Unable to find \\'vimc\\' media device node\" << endl;\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\tmedia_->acquire();\n> +\n> +\tint ret = media_->open();\n> +\tif (ret) {\n> +\t\tcerr << \"Unable to open media device: \" << media_->deviceNode()\n> +\t\t     << \": \" << strerror(ret) << endl;\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n> +\t}\n> +\n> +\tMediaEntity *videoEntity = media_->getEntityByName(\"Scaler\");\n> +\tif (!videoEntity) {\n> +\t\tcerr << \"Unable to find media entity 'Scaler'\" << endl;\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n\nShouldn't this be TestFail ?\n\n> +\t}\n> +\n> +\tscaler_ = new V4L2Subdevice(videoEntity);\n> +\tif (!scaler_) {\n> +\t\tcerr << \"Unable to create media device from media entity: \"\n> +\t\t     << videoEntity->deviceNode();\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n\nAnd here too ?\n\n> +\t}\n> +\n> +\tret = scaler_->open();\n> +\tif (ret) {\n> +\t\tcerr << \"Unable to open video subdevice \"\n> +\t\t     << scaler_->deviceNode() << endl;\n> +\t\tmedia_->release();\n> +\t\treturn TestSkip;\n\nThis one can be a skip as there could be permission issues on the subdev\nnode.\n\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n> +void V4L2SubdeviceTest::cleanup()\n> +{\n> +\tmedia_->release();\n> +\n> +\tdelete scaler_;\n> +}\n> diff --git a/test/v4l2_subdevice/v4l2_subdevice_test.h b/test/v4l2_subdevice/v4l2_subdevice_test.h\n> new file mode 100644\n> index 000000000000..7b64c6122745\n> --- /dev/null\n> +++ b/test/v4l2_subdevice/v4l2_subdevice_test.h\n> @@ -0,0 +1,36 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * v4l2_subdevice_test.h - V4L2 subdevice test\n> + */\n> +\n> +#ifndef __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_\n> +#define __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_\n\nDouble underscore at the end of both line ?\n\n> +\n> +#include <libcamera/buffer.h>\n> +\n> +#include \"device_enumerator.h\"\n> +#include \"media_device.h\"\n> +#include \"test.h\"\n> +#include \"v4l2_subdevice.h\"\n> +\n> +using namespace libcamera;\n> +\n> +class V4L2SubdeviceTest : public Test\n> +{\n> +public:\n> +\tV4L2SubdeviceTest()\n> +\t\t: scaler_(nullptr){};\n> +\n> +protected:\n> +\tint init();\n\noverride ?\n\n> +\tvirtual int run() = 0;\n\nThis isn't needed, the Test class already declares the virtual function.\n\n> +\tvoid cleanup();\n\noverride here too ?\n\n> +\n> +\tstd::unique_ptr<DeviceEnumerator> enumerator_;\n> +\tstd::shared_ptr<MediaDevice> media_;\n> +\tV4L2Subdevice *scaler_;\n> +};\n> +\n> +#endif /* __LIBCAMERA_V4L2_SUBDEVICE_TEST_H_ */\n\nAnd double underscore here too ?\n\nOtherwise this looks good to me.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>","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 79298610B3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Feb 2019 19:04:24 +0100 (CET)","from pendragon.ideasonboard.com (unknown [83.145.195.18])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id D983749;\n\tWed, 27 Feb 2019 19:04:23 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1551290664;\n\tbh=KonpSjCP/rpHmb+wts9ZLc7v2DV7rZbLt0CKZR/PUNE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=e/7wZrdGm8PTFldsxvVI4RwIHFCabKgGsQZxQkmhULgLbD5gb321zEFAfRygpUx9i\n\t9HNsAvi+OnWjMi1kxtmJCorXoDToT5AsYr0be9tLQCaA8iz+CHOd+IDQlS6XA7R0zB\n\t2SuqCu7SdAroMMKD0LIU+fP9JDlRR9cF6H8/7sEA=","Date":"Wed, 27 Feb 2019 20:04:16 +0200","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190227180416.GN4813@pendragon.ideasonboard.com>","References":"<20190226162641.12116-1-jacopo@jmondi.org>\n\t<20190226162641.12116-6-jacopo@jmondi.org>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20190226162641.12116-6-jacopo@jmondi.org>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v3 5/8] test: v4l2_subdevice: Add\n\tformat handling 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:04:24 -0000"}}]