Patch Detail
Show a patch.
GET /api/patches/2806/?format=api
{ "id": 2806, "url": "https://patchwork.libcamera.org/api/patches/2806/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2806/", "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": "<20200213124538.21556-2-laurent.pinchart@ideasonboard.com>", "date": "2020-02-13T12:45:37", "name": "[libcamera-devel,v2,2/3] test: threads: Add wait() timeout test", "commit_ref": "a6388e494e88b4a284bba7cce8b9cb5c3a558ab6", "pull_url": null, "state": "accepted", "archived": false, "hash": "faa55be2104d4cd3fe8eaedb33beb9221c69667b", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2806/mbox/", "series": [ { "id": 669, "url": "https://patchwork.libcamera.org/api/series/669/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=669", "date": "2020-02-13T12:45:36", "name": "[libcamera-devel,v2,1/3] libcamera: thread: Support timeout in wait() function", "version": 2, "mbox": "https://patchwork.libcamera.org/series/669/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2806/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2806/checks/", "tags": {}, "headers": { "Return-Path": "<laurent.pinchart@ideasonboard.com>", "Received": [ "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39F4D6194C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Feb 2020 13:45:59 +0100 (CET)", "from pendragon.bb.dnainternet.fi (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C73099D3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 13 Feb 2020 13:45:58 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1581597959;\n\tbh=FdqcIqDdEZpGndnjY0aC5fqpLG4tc4BJ7+pBb/PjPd4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=Y6NldCxDx6iXmKptO4I8SUZwyz2lBIcnJjTeUVsRuMHITj0sec6lNCo3TrD0M+QYu\n\tQOvD/9EzJ8ekEk/OadBeqC3rVUUn7L3ZrlVQX5LwXRXaqqbbgqiNQtsPTsDm5XpvVr\n\tideQ6obJm2/BdYxbPCpw3TCfd1VwNuTSiSb253x4=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 13 Feb 2020 14:45:37 +0200", "Message-Id": "<20200213124538.21556-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200213124538.21556-1-laurent.pinchart@ideasonboard.com>", "References": "<20200213124538.21556-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 2/3] test: threads: Add wait() timeout\n\ttest", "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": "Thu, 13 Feb 2020 12:45:59 -0000" }, "content": "Add a test case to wait with a timeout, testing both a too short and a\nlong enough duration.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/threads.cpp | 33 ++++++++++++++++++++++++++-------\n 1 file changed, 26 insertions(+), 7 deletions(-)", "diff": "diff --git a/test/threads.cpp b/test/threads.cpp\nindex 9a2d39dfd106..1fa26020ce5c 100644\n--- a/test/threads.cpp\n+++ b/test/threads.cpp\n@@ -15,24 +15,22 @@\n using namespace std;\n using namespace libcamera;\n \n-class InstrumentedThread : public Thread\n+class DelayThread : public Thread\n {\n public:\n-\tInstrumentedThread(unsigned int iterations)\n-\t\t: iterations_(iterations)\n+\tDelayThread(chrono::steady_clock::duration duration)\n+\t\t: duration_(duration)\n \t{\n \t}\n \n protected:\n \tvoid run()\n \t{\n-\t\tfor (unsigned int i = 0; i < iterations_; ++i) {\n-\t\t\tthis_thread::sleep_for(chrono::milliseconds(50));\n-\t\t}\n+\t\tthis_thread::sleep_for(duration_);\n \t}\n \n private:\n-\tunsigned int iterations_;\n+\tchrono::steady_clock::duration duration_;\n };\n \n class ThreadTest : public Test\n@@ -82,6 +80,27 @@ protected:\n \n \t\tdelete thread;\n \n+\t\t/* Test waiting for completion with a timeout. */\n+\t\tthread = new DelayThread(chrono::milliseconds(500));\n+\t\tthread->start();\n+\t\tthread->exit(0);\n+\n+\t\tbool timeout = !thread->wait(chrono::milliseconds(100));\n+\n+\t\tif (!timeout) {\n+\t\t\tcout << \"Waiting for thread didn't time out\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\ttimeout = !thread->wait(chrono::milliseconds(1000));\n+\n+\t\tif (timeout) {\n+\t\t\tcout << \"Waiting for thread timed out\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tdelete thread;\n+\n \t\treturn TestPass;\n \t}\n \n", "prefixes": [ "libcamera-devel", "v2", "2/3" ] }