Show a patch.

GET /api/1.1/patches/16726/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 16726,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/16726/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/16726/",
    "project": {
        "id": 1,
        "url": "https://patchwork.libcamera.org/api/1.1/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": "<20220721134531.1091104-2-umang.jain@ideasonboard.com>",
    "date": "2022-07-21T13:45:31",
    "name": "[libcamera-devel,2/2] test: gstreamer: Check availability of cameras before running",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "2a75160b2cfbd9880763e110654dad0bdacfe220",
    "submitter": {
        "id": 86,
        "url": "https://patchwork.libcamera.org/api/1.1/people/86/?format=api",
        "name": "Umang Jain",
        "email": "umang.jain@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/16726/mbox/",
    "series": [
        {
            "id": 3314,
            "url": "https://patchwork.libcamera.org/api/1.1/series/3314/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3314",
            "date": "2022-07-21T13:45:30",
            "name": "[libcamera-devel,1/2] test: gstreamer: Drop internal header from base class",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/3314/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/16726/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/16726/checks/",
    "tags": {},
    "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 C94C7BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 21 Jul 2022 13:45:44 +0000 (UTC)",
            "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8146063315;\n\tThu, 21 Jul 2022 15:45:44 +0200 (CEST)",
            "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 3DBE463310\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 21 Jul 2022 15:45:42 +0200 (CEST)",
            "from perceval.ideasonboard.com (unknown\n\t[IPv6:2401:4900:1f3f:a2d:c6dd:7a7c:3d3c:dbb9])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 00EBA496;\n\tThu, 21 Jul 2022 15:45:40 +0200 (CEST)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658411144;\n\tbh=mIvABvWeRKQBY6W0HPNmH9t9v8Zst598xYKrzVVD148=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=LOSSRRo0WJmMswmD0AESo4MTymJM1OZ0hQmVRoaG0FevQcXUPZJZoJ3leFGLVx5VU\n\tNovID1YwMzXQdJOQbdR++FeAWvecBlRqVrUIQ/OvisfiH68ydSZq6zV83lfzesXqA4\n\tIWDlSBP31M0vh6qeqlQyWsqrq6XDw2JcuxkiIvWRwFCxhdUnJvunvkBYMdk2VD8C7N\n\tWVFg/r5Z31okK5NYuf72klnUkCzvlY8VHQrMrIet+JCDxWGMccr7ROsj12TaBH4oi8\n\t/U8h6m+MERj3hPMXBcTcE73SwWE07Yz5qVclg3HLE/XlAxKZMSZ2c8URu4N4Tfv4EX\n\tNj8lcNhRHa+OA==",
            "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658411141;\n\tbh=mIvABvWeRKQBY6W0HPNmH9t9v8Zst598xYKrzVVD148=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=FrW3pZQoh+Nx8g50OXmKykhthd71dfs/HjP9jiMb8zbSVJ69i6uoYrpkJ+pyJGM2Q\n\tliqCDsTF2ES9xtm/JhJ44AISYfoyDQK8C+F/nBCq5pRimeW30pGM7e75R19+ZmdFr3\n\t81BSLCRkygZ8QyPRl1guLHYVh8U+Unn7MQlIHoAo="
        ],
        "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"FrW3pZQo\"; dkim-atps=neutral",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Thu, 21 Jul 2022 19:15:31 +0530",
        "Message-Id": "<20220721134531.1091104-2-umang.jain@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.31.1",
        "In-Reply-To": "<20220721134531.1091104-1-umang.jain@ideasonboard.com>",
        "References": "<20220721134531.1091104-1-umang.jain@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 2/2] test: gstreamer: Check availability\n\tof cameras before running",
        "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>",
        "From": "Umang Jain via libcamera-devel <libcamera-devel@lists.libcamera.org>",
        "Reply-To": "Umang Jain <umang.jain@ideasonboard.com>",
        "Errors-To": "libcamera-devel-bounces@lists.libcamera.org",
        "Sender": "\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"
    },
    "content": "Move the logic for checking the availability of cameras from\nmulti_stream_test to gstreamer test base class. Since\nsingle_stream_class always assumes that a camera is available on the\nsystem (which is not always the case for e.g. RPi in CI/CD environments)\nit makes sense to have the availability check in the base class.\nIf no cameras are available, the behaviour should be to skip instead\nof a failure.\n\nWe currently have 2 tests for gstreamer differing based on number\nof streams supported by the camera. Hence, the camera availability\nis checked in conjunction with the number of the streams required by\nthe derived class.\n\nSigned-off-by: Umang Jain <umang.jain@ideasonboard.com>\n---\n .../gstreamer/gstreamer_multi_stream_test.cpp | 20 +----------\n test/gstreamer/gstreamer_test.cpp             | 33 ++++++++++++++++++-\n test/gstreamer/gstreamer_test.h               |  4 ++-\n 3 files changed, 36 insertions(+), 21 deletions(-)",
    "diff": "diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp\nindex 112f1dee..b8387c10 100644\n--- a/test/gstreamer/gstreamer_multi_stream_test.cpp\n+++ b/test/gstreamer/gstreamer_multi_stream_test.cpp\n@@ -29,7 +29,7 @@ class GstreamerMultiStreamTest : public GstreamerTest, public Test\n {\n public:\n \tGstreamerMultiStreamTest()\n-\t\t: GstreamerTest()\n+\t\t: GstreamerTest(2)\n \t{\n \t}\n \n@@ -39,24 +39,6 @@ protected:\n \t\tif (status_ != TestPass)\n \t\t\treturn status_;\n \n-\t\t/* Check if platform supports multistream capture */\n-\t\tlibcamera::CameraManager cm;\n-\t\tcm.start();\n-\t\tbool cameraFound = false;\n-\t\tfor (auto &camera : cm.cameras()) {\n-\t\t\tif (camera->streams().size() > 1) {\n-\t\t\t\tcameraName_ = camera->id();\n-\t\t\t\tcameraFound = true;\n-\t\t\t\tcm.stop();\n-\t\t\t\tbreak;\n-\t\t\t}\n-\t\t}\n-\n-\t\tif (!cameraFound) {\n-\t\t\tcm.stop();\n-\t\t\treturn TestSkip;\n-\t\t}\n-\n \t\tconst gchar *streamDescription = \"queue ! fakesink\";\n \t\tg_autoptr(GError) error = NULL;\n \ndiff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp\nindex cfb8afc6..4668aa00 100644\n--- a/test/gstreamer/gstreamer_test.cpp\n+++ b/test/gstreamer/gstreamer_test.cpp\n@@ -5,6 +5,7 @@\n  * libcamera Gstreamer element API tests\n  */\n \n+#include <libcamera/libcamera.h>\n #include <libcamera/base/utils.h>\n \n #include \"gstreamer_test.h\"\n@@ -25,9 +26,10 @@ const char *__asan_default_options()\n }\n }\n \n-GstreamerTest::GstreamerTest()\n+GstreamerTest::GstreamerTest(unsigned int numStreams)\n \t: pipeline_(nullptr), libcameraSrc_(nullptr)\n {\n+\n \t/*\n \t* GStreamer by default spawns a process to run the\n \t* gst-plugin-scanner helper. If libcamera is compiled with ASan\n@@ -67,9 +69,38 @@ GstreamerTest::GstreamerTest()\n \t\treturn;\n \t}\n \n+\t/*\n+\t * Atleast one camera should be available with numStreams streams\n+\t * otherwise, skip the test entirely.\n+\t */\n+\tif (!satisfyCameraStreams(numStreams)) {\n+\t\tstatus_ = TestSkip;\n+\t\treturn;\n+\t}\n+\n \tstatus_ = TestPass;\n }\n \n+bool GstreamerTest::satisfyCameraStreams(unsigned int numStreams)\n+{\n+\tlibcamera::CameraManager cm;\n+\tbool cameraFound = false;\n+\n+\tcm.start();\n+\n+\tfor (auto &camera : cm.cameras()) {\n+\t\tif (camera->streams().size() < numStreams)\n+\t\t\tcontinue;\n+\n+\t\tcameraFound = true;\n+\t\tbreak;\n+\t}\n+\n+\tcm.stop();\n+\n+\treturn cameraFound;\n+}\n+\n GstreamerTest::~GstreamerTest()\n {\n \tg_clear_object(&pipeline_);\ndiff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h\nindex 35adab0e..fa41721f 100644\n--- a/test/gstreamer/gstreamer_test.h\n+++ b/test/gstreamer/gstreamer_test.h\n@@ -15,7 +15,7 @@\n class GstreamerTest\n {\n public:\n-\tGstreamerTest();\n+\tGstreamerTest(unsigned int numStreams = 1);\n \tvirtual ~GstreamerTest();\n \n protected:\n@@ -27,4 +27,6 @@ protected:\n \tGstElement *pipeline_;\n \tGstElement *libcameraSrc_;\n \tint status_;\n+private:\n+\tbool satisfyCameraStreams(unsigned int numStreams);\n };\n",
    "prefixes": [
        "libcamera-devel",
        "2/2"
    ]
}