[{"id":453,"web_url":"https://patchwork.libcamera.org/comment/453/","msgid":"<d11e976a-5bd8-f4e3-bab7-2d70f04043cd@ideasonboard.com>","date":"2019-01-21T15:49:28","subject":"Re: [libcamera-devel] [PATCH v3 2/2] test: pipeline: IPU3: Add IPU3\n\tpipeline 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 21/01/2019 10:57, Jacopo Mondi wrote:\n> Add test for the Intel IPU3 pipeline that lists all the cameras\n> registered in the system and verifies the result matches the expected.\n> \n> This test is meant to be run on IPU3 platforms, it gets skipped\n> otherwise.\n> \n> Signed-off-by: Jacopo Mondi <jacopo@jmondi.org>\n> ---\n>  test/meson.build                          |   3 +\n>  test/pipeline/ipu3/ipu3_pipeline_test.cpp | 140 ++++++++++++++++++++++\n>  test/pipeline/ipu3/meson.build            |  11 ++\n>  test/pipeline/meson.build                 |   1 +\n>  4 files changed, 155 insertions(+)\n>  create mode 100644 test/pipeline/ipu3/ipu3_pipeline_test.cpp\n>  create mode 100644 test/pipeline/ipu3/meson.build\n>  create mode 100644 test/pipeline/meson.build\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index fb6b115..594082a 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -1,6 +1,9 @@\n>  subdir('libtest')\n>  \n>  subdir('media_device')\n> +\n> +subdir('pipeline')\n> +\n\nI would keep these together. I separated libtest because it's a\ndependency for the tests, and must come first.\n\nAny test subdirs are a common group as I see it.\n\n\nAside from this minor nit, it looks like code which exercises the\npipeline at least to the levels we can support at the moment.\n\n\n>  subdir('v4l2_device')\n>  \n>  public_tests = [\n> diff --git a/test/pipeline/ipu3/ipu3_pipeline_test.cpp b/test/pipeline/ipu3/ipu3_pipeline_test.cpp\n\nI might have put this just under test/pipeline/ipu3.cpp ... but I don't\nobject to the extra levels, if you think you'll add more specific ipu3\npipeline tests as separate files.\n\nFurther tests will depend on how the pipeline API expands, but I think\nthis is a good start, and I'm all for getting it in as fast as possible.\n\nAcked-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n--\nKieran\n\n\n> new file mode 100644\n> index 0000000..deaee40\n> --- /dev/null\n> +++ b/test/pipeline/ipu3/ipu3_pipeline_test.cpp\n> @@ -0,0 +1,140 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2018, Google Inc.\n> + *\n> + * ipu3_pipeline_test.cpp - Intel IPU3 pipeline test\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include <sys/types.h>\n> +#include <sys/stat.h>\n> +#include <unistd.h>\n> +\n> +#include <libcamera/camera.h>\n> +#include <libcamera/camera_manager.h>\n> +\n> +#include \"media_device.h\"\n> +#include \"media_object.h\"\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +/*\n> + * Verify that the Intel IPU3 pipeline handler gets matched and cameras\n> + * are enumerated correctly.\n> + *\n> + * The test is supposed to be run on an IPU3 platform, otherwise it gets\n> + * skipped.\n> + *\n> + * The test lists all cameras registered in the system, if any camera is\n> + * available at all.\n> + */\n> +class IPU3PipelineTest : public Test\n> +{\n> +protected:\n> +\tint init();\n> +\tint run();\n> +\tvoid cleanup();\n> +\n> +private:\n> +\tCameraManager *cameraManager_;\n> +\tunsigned int sensors_;\n> +};\n> +\n> +int IPU3PipelineTest::init()\n> +{\n> +\tconst string devnode(\"/dev/media\");\n> +\tbool cio2 = false;\n> +\tbool imgu = false;\n> +\tunsigned int i;\n> +\tint ret;\n> +\n> +\tsensors_ = 0;\n> +\n> +\t/*\n> +\t * Test all media devices from /dev/media0 to /dev/media256.\n> +\t * Media device numbering might not be continue, and we cannot stop\n> +\t * as soon as we hit a non accessible media device.\n> +\t */\n> +\tfor (i = 0; i < 256; i++) {\n> +\t\tstring mediadev = devnode + to_string(i);\n> +\t\tstruct stat pstat = { };\n> +\n> +\t\tif (stat(mediadev.c_str(), &pstat))\n> +\t\t\tcontinue;\n> +\n> +\t\tMediaDevice dev(mediadev);\n> +\t\tif (dev.open()) {\n> +\t\t\tcerr << \"Failed to open media device \" << mediadev << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (dev.driver() == \"ipu3-imgu\") {\n> +\t\t\timgu = true;\n> +\t\t} else if (dev.driver() == \"ipu3-cio2\") {\n> +\t\t\t/*\n> +\t\t\t * Camera sensor are connected to the CIO2 unit.\n> +\t\t\t * Count how many sensors are connected in the system\n> +\t\t\t * and later verify this matches the number of registered\n> +\t\t\t * cameras.\n> +\t\t\t */\n> +\t\t\tret = dev.populate();\n> +\t\t\tif (ret) {\n> +\t\t\t\tcerr << \"Failed to populate media device \" << dev.devnode() << endl;\n> +\t\t\t\treturn TestFail;\n> +\t\t\t}\n> +\n> +\t\t\tvector<MediaEntity *> entities = dev.entities();\n> +\t\t\tfor (MediaEntity *entity : entities) {\n> +\t\t\t\tif (entity->function() == MEDIA_ENT_F_CAM_SENSOR)\n> +\t\t\t\t\tsensors_++;\n> +\t\t\t}\n> +\n> +\t\t\tcio2 = true;\n> +\t\t}\n> +\n> +\t\tdev.close();\n> +\n> +\t\tif (imgu && cio2)\n> +\t\t\tbreak;\n> +\t}\n> +\n> +\t/* Not running on an IPU3 system: skip test. */\n> +\tif (!(imgu && cio2))\n> +\t\treturn TestSkip;\n> +\n> +\tcameraManager_ = CameraManager::instance();\n> +\tret = cameraManager_->start();\n> +\tif (ret) {\n> +\t\tcerr << \"Failed to start the CameraManager\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn 0;\n> +}\n> +\n> +int IPU3PipelineTest::run()\n> +{\n> +\tunsigned int cameras = 0;\n> +\tfor (const shared_ptr<Camera> &cam : cameraManager_->cameras()) {\n> +\t\tcout << \"Found camera '\" << cam->name() << \"'\" << endl;\n> +\t\tcameras++;\n> +\t}\n> +\n> +\tif (cameras != sensors_) {\n> +\t\tcerr << cameras << \" cameras registered, but \" << sensors_\n> +\t\t     << \" were expected\" << endl;\n> +\t\treturn TestFail;\n> +\t}\n> +\n> +\treturn TestPass;\n> +}\n> +\n> +void IPU3PipelineTest::cleanup()\n> +{\n> +\tcameraManager_->stop();\n> +}\n> +\n> +TEST_REGISTER(IPU3PipelineTest)\n> diff --git a/test/pipeline/ipu3/meson.build b/test/pipeline/ipu3/meson.build\n> new file mode 100644\n> index 0000000..caba5c7\n> --- /dev/null\n> +++ b/test/pipeline/ipu3/meson.build\n> @@ -0,0 +1,11 @@\n> +ipu3_test = [\n> +    ['ipu3_pipeline_test',\t      'ipu3_pipeline_test.cpp'],\n> +]\n> +\n> +foreach t : ipu3_test\n> +    exe = executable(t[0], t[1],\n> +                     link_with : test_libraries,\n> +                     include_directories : test_includes_internal)\n> +\n> +    test(t[0], exe, suite: 'ipu3', is_parallel: false)\n> +endforeach\n> diff --git a/test/pipeline/meson.build b/test/pipeline/meson.build\n> new file mode 100644\n> index 0000000..f434c79\n> --- /dev/null\n> +++ b/test/pipeline/meson.build\n> @@ -0,0 +1 @@\n> +subdir('ipu3')\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 39B9560C80\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 21 Jan 2019 16:49:32 +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 93F1E53E;\n\tMon, 21 Jan 2019 16:49:31 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1548085771;\n\tbh=SJwTavzX/5WoJBiRtGjL4hW8ZAlRJY2DCavczmZ2kvc=;\n\th=Reply-To:Subject:To:References:From:Date:In-Reply-To:From;\n\tb=wmko/MGyfmum+3doz7iFf1N/GmTFjqzSjJ29aeukXnpm6b5fkLA/HOwOzEVfQSwW0\n\tOMl3EkJe0eZliRegUBKDIB6YAuwHNHt87CYixOrkUSFWmAhFRYyQFr+mB1aiYphw8+\n\tc3k6zK6u96ciTD3BBRM7KiMitp4YB/l44scTU/S4=","Reply-To":"kieran.bingham@ideasonboard.com","To":"Jacopo Mondi <jacopo@jmondi.org>, libcamera-devel@lists.libcamera.org","References":"<20190121105725.8351-1-jacopo@jmondi.org>\n\t<20190121105725.8351-3-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/HST8TpFeqI5nVeq0/lqtBRQKumuIqDg+Bkr4L1V/PSB6XgQ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Ki/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":"<d11e976a-5bd8-f4e3-bab7-2d70f04043cd@ideasonboard.com>","Date":"Mon, 21 Jan 2019 15:49:28 +0000","User-Agent":"Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101\n\tThunderbird/60.2.1","MIME-Version":"1.0","In-Reply-To":"<20190121105725.8351-3-jacopo@jmondi.org>","Content-Type":"text/plain; charset=utf-8","Content-Language":"en-GB","Content-Transfer-Encoding":"8bit","Subject":"Re: [libcamera-devel] [PATCH v3 2/2] test: pipeline: IPU3: Add IPU3\n\tpipeline 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":"Mon, 21 Jan 2019 15:49:32 -0000"}}]