Patch Detail
Show a patch.
GET /api/patches/149/?format=api
{ "id": 149, "url": "https://patchwork.libcamera.org/api/patches/149/?format=api", "web_url": "https://patchwork.libcamera.org/patch/149/", "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": "<20190103173859.22624-6-jacopo@jmondi.org>", "date": "2019-01-03T17:38:59", "name": "[libcamera-devel,5/5] test: MediaDevice: Add link exercize test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "2a445e3bd48db2ecdaf9379fe8be518f2ecf03e3", "submitter": { "id": 3, "url": "https://patchwork.libcamera.org/api/people/3/?format=api", "name": "Jacopo Mondi", "email": "jacopo@jmondi.org" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/149/mbox/", "series": [ { "id": 52, "url": "https://patchwork.libcamera.org/api/series/52/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=52", "date": "2019-01-03T17:38:54", "name": "libcamera: media device: Add link handling", "version": 1, "mbox": "https://patchwork.libcamera.org/series/52/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/149/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/149/checks/", "tags": {}, "headers": { "Return-Path": "<jacopo@jmondi.org>", "Received": [ "from relay9-d.mail.gandi.net (relay9-d.mail.gandi.net\n\t[217.70.183.199])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D16D160B3D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 3 Jan 2019 18:39:04 +0100 (CET)", "from uno.lan (2-224-242-101.ip172.fastwebnet.it [2.224.242.101])\n\t(Authenticated sender: jacopo@jmondi.org)\n\tby relay9-d.mail.gandi.net (Postfix) with ESMTPSA id 67C0DFF804;\n\tThu, 3 Jan 2019 17:39:04 +0000 (UTC)" ], "X-Originating-IP": "2.224.242.101", "From": "Jacopo Mondi <jacopo@jmondi.org>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 3 Jan 2019 18:38:59 +0100", "Message-Id": "<20190103173859.22624-6-jacopo@jmondi.org>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190103173859.22624-1-jacopo@jmondi.org>", "References": "<20190103173859.22624-1-jacopo@jmondi.org>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 5/5] test: MediaDevice: Add link exercize\n\ttest", "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, 03 Jan 2019 17:39:05 -0000" }, "content": "Add test function to exercize the link handling abilities of the media\ndevice.\n\nSigned-off-by: Jacopo Mondi <jacopo@jmondi.org>\n---\n test/media_device/media_device_test.cpp | 101 ++++++++++++++++++++++++\n 1 file changed, 101 insertions(+)", "diff": "diff --git a/test/media_device/media_device_test.cpp b/test/media_device/media_device_test.cpp\nindex c482b2e..99da3a6 100644\n--- a/test/media_device/media_device_test.cpp\n+++ b/test/media_device/media_device_test.cpp\n@@ -42,8 +42,104 @@ private:\n \tvoid printMediaGraph(const MediaDevice &media, ostream &os);\n \tvoid printLinkFlags(const MediaLink *link, ostream &os);\n \tvoid printNode(const MediaPad *pad, ostream &os);\n+\n+\tint exercizeLinks(const MediaDevice &media);\n+\tint testLink(const MediaDevice &media, MediaLink *link);\n };\n \n+int MediaDeviceTest::testLink(const MediaDevice &media, MediaLink *link)\n+{\n+\tMediaPad *sourcePad = link->source();\n+\tMediaEntity *source = sourcePad->entity();\n+\tMediaPad *sinkPad = link->sink();\n+\tMediaEntity *sink = sinkPad->entity();\n+\n+\tcerr << \"Test link handling interface on link: \"\n+\t << source->name() << \":\" << sourcePad->index()\n+\t << \" -> \" << sink->name() << \":\" << sinkPad->index() << \"\\n\";\n+\n+\t/* Test the link() functions to be consistent. */\n+\tMediaLink *alink = media.link(source->name(), sourcePad->index(),\n+\t\t\t\t sink->name(), sinkPad->index());\n+\tif (link != alink)\n+\t\treturn -EINVAL;\n+\n+\talink = media.link(source, sourcePad->index(),\n+\t\t\t sink, sinkPad->index());\n+\tif (link != alink)\n+\t\treturn -EINVAL;\n+\n+\talink = media.link(sourcePad, sinkPad);\n+\tif (link != alink)\n+\t\treturn -EINVAL;\n+\n+\t/* Fine, we get consisten results... now try to manipulate the link. */\n+\tint ret = link->enable(true);\n+\tif (ret)\n+\t\treturn ret;\n+\n+\tret = link->enable(false);\n+\tif (ret) {\n+\t\tif (!(link->flags() & MEDIA_LNK_FL_IMMUTABLE))\n+\t\t\treturn ret;\n+\t}\n+\n+\treturn 0;\n+\n+}\n+\n+/*\n+ * Exercize the link handling interface.\n+ * Try to get existing and non-existing links, and try to enable\n+ * disable link.\n+ *\n+ * WARNING: this test will change the link between pads on the media\n+ * device it runs on, potentially modying the behavior of the system\n+ * where the test is run on.\n+ */\n+int MediaDeviceTest::exercizeLinks(const MediaDevice &media)\n+{\n+\tauto entities = media.entities();\n+\n+\t/* First of all, reset all links in the media graph. */\n+\tfor (MediaEntity *ent : entities) {\n+\t\tcerr << \"Disable all links in entity: \" << ent->name() << \"\\n\";\n+\n+\t\tfor (MediaPad *pad : ent->pads()) {\n+\t\t\tif (pad->flags() & MEDIA_PAD_FL_SINK)\n+\t\t\t\tcontinue;\n+\n+\t\t\tfor (MediaLink *link : pad->links()) {\n+\t\t\t\tint ret = link->enable(false);\n+\t\t\t\tif (ret) {\n+\t\t\t\t\tif (!(link->flags() &\n+\t\t\t\t\t MEDIA_LNK_FL_IMMUTABLE))\n+\t\t\t\t\t\treturn ret;\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\n+\t/*\n+\t * Exercize the link handling interface.\n+\t */\n+\tfor (MediaEntity *ent : entities) {\n+\t\tfor (MediaPad *pad : ent->pads()) {\n+\t\t\tif (pad->flags() & MEDIA_PAD_FL_SINK)\n+\t\t\t\tcontinue;\n+\n+\t\t\tfor (MediaLink *link : pad->links()) {\n+\t\t\t\tint ret = testLink(media, link);\n+\t\t\t\tif (ret)\n+\t\t\t\t\treturn ret;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\treturn 0;\n+}\n+\n void MediaDeviceTest::printNode(const MediaPad *pad, ostream &os)\n {\n \tconst MediaEntity *entity = pad->entity();\n@@ -136,6 +232,11 @@ int MediaDeviceTest::testMediaDevice(const string devnode)\n \n \t/* Run tests in sequence. */\n \tprintMediaGraph(dev, cerr);\n+\n+\tret = exercizeLinks(dev);\n+\tif (ret)\n+\t\treturn ret;\n+\n \t/* TODO: add more tests here. */\n \n \tdev.close();\n", "prefixes": [ "libcamera-devel", "5/5" ] }