Show a patch.

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

{
    "id": 2109,
    "url": "https://patchwork.libcamera.org/api/1.1/patches/2109/?format=api",
    "web_url": "https://patchwork.libcamera.org/patch/2109/",
    "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": "<20191006053226.8976-5-laurent.pinchart@ideasonboard.com>",
    "date": "2019-10-06T05:32:21",
    "name": "[libcamera-devel,4/9] test: timer: Test that a timer can be restarted before it expires",
    "commit_ref": null,
    "pull_url": null,
    "state": "accepted",
    "archived": false,
    "hash": "b3e4da3f870fb33db1f6463be1fa10832b3565b3",
    "submitter": {
        "id": 2,
        "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api",
        "name": "Laurent Pinchart",
        "email": "laurent.pinchart@ideasonboard.com"
    },
    "delegate": null,
    "mbox": "https://patchwork.libcamera.org/patch/2109/mbox/",
    "series": [
        {
            "id": 522,
            "url": "https://patchwork.libcamera.org/api/1.1/series/522/?format=api",
            "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=522",
            "date": "2019-10-06T05:32:17",
            "name": "Timer fixes and enhancements",
            "version": 1,
            "mbox": "https://patchwork.libcamera.org/series/522/mbox/"
        }
    ],
    "comments": "https://patchwork.libcamera.org/api/patches/2109/comments/",
    "check": "pending",
    "checks": "https://patchwork.libcamera.org/api/patches/2109/checks/",
    "tags": {},
    "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 D51CA6196C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 07:32:37 +0200 (CEST)",
            "from pendragon.ideasonboard.com\n\t(modemcable151.96-160-184.mc.videotron.ca [184.160.96.151])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 40460DD\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun,  6 Oct 2019 07:32:37 +0200 (CEST)"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1570339957;\n\tbh=TL/JInXT1/VKkEKGlh6gIo9p7VKswEP0BpSBTjHdIjo=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=qUxj0lFiB432AUy3vzF6BYL374AruyhR2g1c9SJTiDfjxRbiCH0hIneNdiuVejXA9\n\tEfm0lsTqqOZjak2BGajwBb4btz6iadb0eknyh5BTGeGgCybK0kXyGr+uBoLOd3FH5q\n\tXYPVLJdLwDP/1Y83LC+xl3Hju+Gbh9qyUHzG0Gqo=",
        "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>",
        "To": "libcamera-devel@lists.libcamera.org",
        "Date": "Sun,  6 Oct 2019 08:32:21 +0300",
        "Message-Id": "<20191006053226.8976-5-laurent.pinchart@ideasonboard.com>",
        "X-Mailer": "git-send-email 2.21.0",
        "In-Reply-To": "<20191006053226.8976-1-laurent.pinchart@ideasonboard.com>",
        "References": "<20191006053226.8976-1-laurent.pinchart@ideasonboard.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Subject": "[libcamera-devel] [PATCH 4/9] test: timer: Test that a timer can be\n\trestarted before it expires",
        "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>",
        "X-List-Received-Date": "Sun, 06 Oct 2019 05:32:38 -0000"
    },
    "content": "The Timer API allows restarting a timer before it expires. Add a\ncorresponding test. The test fails as the Timer class doesn't comply\nwith its API documentation.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/timer.cpp | 28 ++++++++++++++++++++++++----\n 1 file changed, 24 insertions(+), 4 deletions(-)",
    "diff": "diff --git a/test/timer.cpp b/test/timer.cpp\nindex d4f16a9bdd97..5ff94dbbdeb0 100644\n--- a/test/timer.cpp\n+++ b/test/timer.cpp\n@@ -21,13 +21,14 @@ class ManagedTimer : public Timer\n {\n public:\n \tManagedTimer()\n-\t\t: Timer()\n+\t\t: Timer(), count_(0)\n \t{\n \t\ttimeout.connect(this, &ManagedTimer::timeoutHandler);\n \t}\n \n \tvoid start(int msec)\n \t{\n+\t\tcount_ = 0;\n \t\tstart_ = std::chrono::steady_clock::now();\n \t\texpiration_ = std::chrono::steady_clock::time_point();\n \n@@ -40,12 +41,19 @@ public:\n \t\treturn abs(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count());\n \t}\n \n+\tbool hasFailed()\n+\t{\n+\t\treturn isRunning() || count_ != 1 || jitter() > 50;\n+\t}\n+\n private:\n \tvoid timeoutHandler(Timer *timer)\n \t{\n \t\texpiration_ = std::chrono::steady_clock::now();\n+\t\tcount_++;\n \t}\n \n+\tunsigned int count_;\n \tstd::chrono::steady_clock::time_point start_;\n \tstd::chrono::steady_clock::time_point expiration_;\n };\n@@ -74,7 +82,7 @@ protected:\n \n \t\tdispatcher->processEvents();\n \n-\t\tif (timer.isRunning() || timer.jitter() > 50) {\n+\t\tif (timer.hasFailed()) {\n \t\t\tcout << \"Timer expiration test failed\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -87,7 +95,7 @@ protected:\n \t\ttimer.start(4295);\n \t\tdispatcher->processEvents();\n \n-\t\tif (timer.isRunning() || timer.jitter() > 50) {\n+\t\tif (timer.hasFailed()) {\n \t\t\tcout << \"Timer expiration test failed\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n@@ -102,11 +110,23 @@ protected:\n \n \t\tdispatcher->processEvents();\n \n-\t\tif (timer.isRunning() || timer.jitter() > 50) {\n+\t\tif (timer.hasFailed()) {\n \t\t\tcout << \"Timer restart test failed\" << endl;\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/* Timer restart before expiration. */\n+\t\ttimer.start(50);\n+\t\ttimer.start(100);\n+\t\ttimer.start(150);\n+\n+\t\tdispatcher->processEvents();\n+\n+\t\tif (timer.hasFailed()) {\n+\t\t\tcout << \"Timer restart before expiration test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\t/* Two timers. */\n \t\ttimer.start(1000);\n \t\ttimer2.start(300);\n",
    "prefixes": [
        "libcamera-devel",
        "4/9"
    ]
}