Patch Detail
Show a patch.
GET /api/1.1/patches/2731/?format=api
{ "id": 2731, "url": "https://patchwork.libcamera.org/api/1.1/patches/2731/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2731/", "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": "<20200123025520.12149-2-laurent.pinchart@ideasonboard.com>", "date": "2020-01-23T02:55:20", "name": "[libcamera-devel,2/2] test: threads: Add wait() timeout test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "bca558173f86767238ecb1e0171de300d41a63ce", "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/2731/mbox/", "series": [ { "id": 646, "url": "https://patchwork.libcamera.org/api/1.1/series/646/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=646", "date": "2020-01-23T02:55:19", "name": "[libcamera-devel,1/2] libcamera: thread: Support timeout in wait() function", "version": 1, "mbox": "https://patchwork.libcamera.org/series/646/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2731/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2731/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 0BEC36044D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jan 2020 03:55:40 +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 92DB19C0\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 23 Jan 2020 03:55:39 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1579748139;\n\tbh=rqG8akmlAjZy2QTAXPrqOlhG3XD6FWfBZRZzqQe47p8=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=oenQHnlGGqLJJodmfaAexMs0uvghL5aQPia6q+LoYlgPwaBCq0eFaEedc9o1DdEYy\n\tgUNxyEXafBxGOYz2IawS2fMJNP1/GCS9b406v6A/RTFRBT5LotHDuWlt2ZFyJb4pOC\n\tvWQsvKOwFQP/pePip906G/2TE3/FBKUHAanwFRXk=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 23 Jan 2020 04:55:20 +0200", "Message-Id": "<20200123025520.12149-2-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.24.1", "In-Reply-To": "<20200123025520.12149-1-laurent.pinchart@ideasonboard.com>", "References": "<20200123025520.12149-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] test: threads: Add wait() timeout test", "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, 23 Jan 2020 02:55:40 -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>\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..fc4b07cc6428 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", "2/2" ] }