Patch Detail
Show a patch.
GET /api/patches/160/?format=api
{ "id": 160, "url": "https://patchwork.libcamera.org/api/patches/160/?format=api", "web_url": "https://patchwork.libcamera.org/patch/160/", "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": "<20190106023328.10989-11-laurent.pinchart@ideasonboard.com>", "date": "2019-01-06T02:33:28", "name": "[libcamera-devel,11/11] test: Add event notifier test", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "84e52e5cd95218587b43a8008ef5ad33436f3222", "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/160/mbox/", "series": [ { "id": 53, "url": "https://patchwork.libcamera.org/api/series/53/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=53", "date": "2019-01-06T02:33:18", "name": "[libcamera-devel,01/11] libcamera: log: Add a LogFatal log level", "version": 1, "mbox": "https://patchwork.libcamera.org/series/53/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/160/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/160/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 7857560B49\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 6 Jan 2019 03:32:30 +0100 (CET)", "from avalon.bb.dnainternet.fi\n\t(dfj612ybrt5fhg77mgycy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:2e86:4862:ef6a:2804])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 16094513\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 6 Jan 2019 03:32:30 +0100 (CET)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1546741950;\n\tbh=Tc4Wf0VAQO5mKzYZoUU69kcuFeSmmSDiRQUyEsy9xr4=;\n\th=From:To:Subject:Date:In-Reply-To:References:From;\n\tb=fBN6XlzAPZfJVUC9038u93Ont0R04iyUCBfd5KFULkISPa5Ic4LhxygBiWMyKq/Nz\n\tkZXeLGiE9bcaJPN20hsm97jEJr1Ogvcmc7GiznG/oeu2MqNRbjCxrvM2I7gpR0IGSH\n\tNO8toyK1vuFAWI7F1948ztPNqFk34QrNN1xp5m+I=", "From": "Laurent Pinchart <laurent.pinchart@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sun, 6 Jan 2019 04:33:28 +0200", "Message-Id": "<20190106023328.10989-11-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.19.2", "In-Reply-To": "<20190106023328.10989-1-laurent.pinchart@ideasonboard.com>", "References": "<20190106023328.10989-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 11/11] test: Add event notifier test", "X-BeenThere": "libcamera-devel@lists.libcamera.org", "X-Mailman-Version": "2.1.23", "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 Jan 2019 02:32:31 -0000" }, "content": "Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/event.cpp | 117 +++++++++++++++++++++++++++++++++++++++++++++++\n test/meson.build | 1 +\n 2 files changed, 118 insertions(+)\n create mode 100644 test/event.cpp", "diff": "diff --git a/test/event.cpp b/test/event.cpp\nnew file mode 100644\nindex 000000000000..52bc0c7e77f5\n--- /dev/null\n+++ b/test/event.cpp\n@@ -0,0 +1,117 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * event.cpp - Event test\n+ */\n+\n+#include <iostream>\n+#include <string.h>\n+#include <unistd.h>\n+\n+#include <libcamera/camera_manager.h>\n+#include <libcamera/event_dispatcher.h>\n+#include <libcamera/event_notifier.h>\n+#include <libcamera/timer.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class EventTest : public Test\n+{\n+protected:\n+\tvoid readReady(EventNotifier *notifier)\n+\t{\n+\t\tsize_ = read(notifier->fd(), data_, sizeof(data_));\n+\t\tnotified_ = true;\n+\t}\n+\n+\tint init()\n+\t{\n+\t\treturn pipe(pipefd_);\n+\t}\n+\n+\tint run()\n+\t{\n+\t\tEventDispatcher *dispatcher = CameraManager::instance()->eventDispatcher();\n+\t\tstd::string data(\"H2G2\");\n+\t\tTimer timeout;\n+\n+\t\tEventNotifier readNotifier(pipefd_[0], EventNotifier::Read);\n+\t\treadNotifier.activated.connect(this, &EventTest::readReady);\n+\n+\t\t/* Test read notification with data. */\n+\t\tmemset(data_, 0, sizeof(data_));\n+\t\tsize_ = 0;\n+\n+\t\twrite(pipefd_[1], data.data(), data.size());\n+\n+\t\ttimeout.start(100);\n+\t\tdispatcher->processEvents();\n+\t\ttimeout.stop();\n+\n+\t\tif (static_cast<size_t>(size_) != data.size()) {\n+\t\t\tcout << \"Event notifier read ready test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test read notification without data. */\n+\t\tnotified_ = false;\n+\n+\t\ttimeout.start(100);\n+\t\tdispatcher->processEvents();\n+\t\ttimeout.stop();\n+\n+\t\tif (notified_) {\n+\t\t\tcout << \"Event notifier read no ready test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test read notifier disabling. */\n+\t\tnotified_ = false;\n+\t\treadNotifier.setEnabled(false);\n+\n+\t\twrite(pipefd_[1], data.data(), data.size());\n+\n+\t\ttimeout.start(100);\n+\t\tdispatcher->processEvents();\n+\t\ttimeout.stop();\n+\n+\t\tif (notified_) {\n+\t\t\tcout << \"Event notifier read disabling failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/* Test read notifier enabling. */\n+\t\tnotified_ = false;\n+\t\treadNotifier.setEnabled(true);\n+\n+\t\ttimeout.start(100);\n+\t\tdispatcher->processEvents();\n+\t\ttimeout.stop();\n+\n+\t\tif (!notified_) {\n+\t\t\tcout << \"Event notifier read enabling test failed\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t\tclose(pipefd_[0]);\n+\t\tclose(pipefd_[1]);\n+\t}\n+\n+private:\n+\tint pipefd_[2];\n+\n+\tbool notified_;\n+\tchar data_[16];\n+\tssize_t size_;\n+};\n+\n+TEST_REGISTER(EventTest)\ndiff --git a/test/meson.build b/test/meson.build\nindex 12e7b30d4f73..e923404502b7 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -3,6 +3,7 @@ subdir('libtest')\n subdir('media_device')\n \n public_tests = [\n+ ['event', 'event.cpp'],\n ['list-cameras', 'list.cpp'],\n ['signal', 'signal.cpp'],\n ['timer', 'timer.cpp'],\n", "prefixes": [ "libcamera-devel", "11/11" ] }