Patch Detail
Show a patch.
GET /api/1.1/patches/2034/?format=api
{ "id": 2034, "url": "https://patchwork.libcamera.org/api/1.1/patches/2034/?format=api", "web_url": "https://patchwork.libcamera.org/patch/2034/", "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": "<20190927024417.725906-11-niklas.soderlund@ragnatech.se>", "date": "2019-09-27T02:44:14", "name": "[libcamera-devel,v3,10/13] test: Add timeline test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "f33a0e17e078018518e2b8ccc7ca86087a710347", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/2034/mbox/", "series": [ { "id": 508, "url": "https://patchwork.libcamera.org/api/1.1/series/508/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=508", "date": "2019-09-27T02:44:04", "name": "libcamera: ipa: Add basic IPA support", "version": 3, "mbox": "https://patchwork.libcamera.org/series/508/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/2034/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/2034/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 39BB861767\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 Sep 2019 04:45:33 +0200 (CEST)", "from bismarck.berto.se (unknown [84.172.88.101])\n\tby bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA\n\tid d0cab3ad-e0d0-11e9-bdc3-005056917a89;\n\tFri, 27 Sep 2019 04:45:07 +0200 (CEST)" ], "X-Halon-ID": "d0cab3ad-e0d0-11e9-bdc3-005056917a89", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Fri, 27 Sep 2019 04:44:14 +0200", "Message-Id": "<20190927024417.725906-11-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.23.0", "In-Reply-To": "<20190927024417.725906-1-niklas.soderlund@ragnatech.se>", "References": "<20190927024417.725906-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v3 10/13] test: Add timeline 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": "Fri, 27 Sep 2019 02:45:33 -0000" }, "content": "Add a test of the timeline to make sure events fire and the estimated\nframe interval are OK.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/meson.build | 1 +\n test/timeline.cpp | 97 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 98 insertions(+)\n create mode 100644 test/timeline.cpp", "diff": "diff --git a/test/meson.build b/test/meson.build\nindex 84722cceb35db86e..6a4c4cd373043469 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -28,6 +28,7 @@ internal_tests = [\n ['object-invoke', 'object-invoke.cpp'],\n ['signal-threads', 'signal-threads.cpp'],\n ['threads', 'threads.cpp'],\n+ ['timeline', 'timeline.cpp'],\n ['timer', 'timer.cpp'],\n ['timer-thread', 'timer-thread.cpp'],\n ]\ndiff --git a/test/timeline.cpp b/test/timeline.cpp\nnew file mode 100644\nindex 0000000000000000..55b651b455a07ffc\n--- /dev/null\n+++ b/test/timeline.cpp\n@@ -0,0 +1,97 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * timeline.cpp - Timeline test\n+ */\n+\n+#include <chrono>\n+#include <iostream>\n+#include <unistd.h>\n+\n+#include <libcamera/event_dispatcher.h>\n+\n+#include \"test.h\"\n+#include \"thread.h\"\n+#include \"timeline.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+enum TimelineTestActionType {\n+\tInc,\n+};\n+\n+class IncrementAction : public FrameAction\n+{\n+public:\n+\tIncrementAction(unsigned int frame, unsigned int *counter)\n+\t\t: FrameAction(Inc, frame), counter_(counter)\n+\t{\n+\t}\n+\n+\tvoid run() override\n+\t{\n+\t\t(*counter_)++;\n+\t}\n+\n+private:\n+\tunsigned int *counter_;\n+};\n+\n+class TimelineTest : public Test\n+{\n+public:\n+\tvoid fakeSOE()\n+\t{\n+\t\ttimeline_.notifyStartOfExposure(sequence_++,\n+\t\t\t\t\t\tstd::chrono::steady_clock::now());\n+\t}\n+\n+\tint init()\n+\t{\n+\t\tsequence_ = 0;\n+\t\treturn 0;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\tEventDispatcher *dispatcher = Thread::current()->eventDispatcher();\n+\t\tunsigned int loops, counter;\n+\t\tTimer timer;\n+\n+\t\t/*\n+\t\t * Run frames and make sure an event is fired for each and that\n+\t\t * the messured frame interval is true.\n+\t\t */\n+\t\tloops = 500;\n+\t\tcounter = 0;\n+\t\tfor (unsigned int i = 0; i < loops; i++) {\n+\t\t\ttimeline_.scheduleAction(new IncrementAction(i + 1, &counter));\n+\t\t\tfakeSOE();\n+\t\t\ttimer.start(10);\n+\t\t\twhile (timer.isRunning())\n+\t\t\t\tdispatcher->processEvents();\n+\t\t}\n+\n+\t\tcout << \"Got \" << counter << \" evens, expected \" << loops - 1 << endl;\n+\t\tif (counter != loops - 1)\n+\t\t\treturn TestFail;\n+\n+\t\tunsigned int interval = std::chrono::duration_cast<std::chrono::milliseconds>(timeline_.frameInterval()).count();\n+\t\tcout << \"Messured frame interval \" << interval << \" expected 10\" << endl;\n+\t\tif (interval != 10)\n+\t\t\treturn TestFail;\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t}\n+private:\n+\tunsigned int sequence_;\n+\tTimeline timeline_;\n+};\n+\n+TEST_REGISTER(TimelineTest)\n", "prefixes": [ "libcamera-devel", "v3", "10/13" ] }