Patch Detail
Show a patch.
GET /api/patches/1652/?format=api
{ "id": 1652, "url": "https://patchwork.libcamera.org/api/patches/1652/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1652/", "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": "<20190711093632.22133-2-paul.elder@ideasonboard.com>", "date": "2019-07-11T09:36:32", "name": "[libcamera-devel,2/2] test: add logging API test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "6978eac1506776925bdfabe080db745a7653327f", "submitter": { "id": 17, "url": "https://patchwork.libcamera.org/api/people/17/?format=api", "name": "Paul Elder", "email": "paul.elder@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/1652/mbox/", "series": [ { "id": 416, "url": "https://patchwork.libcamera.org/api/series/416/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=416", "date": "2019-07-11T09:36:31", "name": "[libcamera-devel,1/2] libcamera: logging: add logging API for applications", "version": 1, "mbox": "https://patchwork.libcamera.org/series/416/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1652/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1652/checks/", "tags": {}, "headers": { "Return-Path": "<paul.elder@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 4AF0261574\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 11 Jul 2019 11:36:42 +0200 (CEST)", "from neptunite.amanokami.net (softbank126163157105.bbtec.net\n\t[126.163.157.105])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EC07031C;\n\tThu, 11 Jul 2019 11:36:40 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562837802;\n\tbh=MEe5LOrSjSEUgloFHFiVyg1HAL8LDkX77lUmON/smz4=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=mjkT46jQQMWxETAzVSvDxW+O6V9mCiI2lw+JlhPrB6LZJ6/ZgZatmoRhiV7ZoL6Xn\n\thEB8iPN1AD5EewHuE6ngKdfBOjr+K4kv88nEeYQVWdynVC2UP8ZvstYhG3vvpH9xLx\n\tVRJjfANjifH1niJK2xPSX7xL4z/Opx6Dhf1Rg9hE=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Thu, 11 Jul 2019 18:36:32 +0900", "Message-Id": "<20190711093632.22133-2-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190711093632.22133-1-paul.elder@ideasonboard.com>", "References": "<20190711093632.22133-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/2] test: add logging API 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": "Thu, 11 Jul 2019 09:36:42 -0000" }, "content": "Test that setting the log file and log levels works from an application\npoint of view. The test uses the internal logging mechanism as well,\njust to write to the log file.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n test/log/log_api.cpp | 66 ++++++++++++++++++++++++++++++++++++++++++++\n test/log/meson.build | 12 ++++++++\n test/meson.build | 1 +\n 3 files changed, 79 insertions(+)\n create mode 100644 test/log/log_api.cpp\n create mode 100644 test/log/meson.build", "diff": "diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp\nnew file mode 100644\nindex 0000000..e294d1e\n--- /dev/null\n+++ b/test/log/log_api.cpp\n@@ -0,0 +1,66 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * log_api.cpp - log API test\n+ */\n+\n+#include <algorithm>\n+#include <fcntl.h>\n+#include <iostream>\n+#include <stdio.h>\n+#include <string.h>\n+#include <sys/stat.h>\n+#include <sys/types.h>\n+#include <unistd.h>\n+\n+#include <libcamera/logging.h>\n+\n+#include \"log.h\"\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+LOG_DEFINE_CATEGORY(LogAPITest)\n+\n+class LogAPITest : public Test\n+{\n+protected:\n+\tint run() override\n+\t{\n+\t\tint fd = open(\"/tmp\", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);\n+\t\tif (fd < 0) {\n+\t\t\tcerr << \"Failed to open tmp log file\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tchar path[PATH_MAX];\n+\t\tsnprintf(path, PATH_MAX, \"/proc/self/fd/%d\", fd);\n+\n+\t\tlogSetFile(path);\n+\n+\t\tlogSetLevel(\"LogAPITest\", \"WARN\");\n+\t\tLOG(LogAPITest, Info) << \"asdf\";\n+\n+\t\tlogSetLevel(\"LogAPITest\", \"INFO\");\n+\t\tLOG(LogAPITest, Warning) << \"asdf\";\n+\n+\t\tlogSetLevel(\"LogAPITest\", \"ERROR\");\n+\t\tLOG(LogAPITest, Error) << \"asdf\";\n+\n+\t\tchar buf[200];\n+\t\tlseek(fd, 0, SEEK_SET);\n+\t\tread(fd, buf, 1000);\n+\t\tclose(fd);\n+\n+\t\tstd::string s(buf);\n+\t\tint n = count(s.begin(), s.end(), '\\n');\n+\t\tif (n == 2)\n+\t\t\treturn TestPass;\n+\n+\t\treturn TestFail;\n+\t}\n+};\n+\n+TEST_REGISTER(LogAPITest)\ndiff --git a/test/log/meson.build b/test/log/meson.build\nnew file mode 100644\nindex 0000000..35ea553\n--- /dev/null\n+++ b/test/log/meson.build\n@@ -0,0 +1,12 @@\n+log_api_test = [\n+ ['log_api', 'log_api.cpp'],\n+]\n+\n+foreach t : log_api_test\n+ exe = executable(t[0], t[1],\n+ dependencies : libcamera_dep,\n+ link_with : test_libraries,\n+ include_directories : test_includes_internal)\n+\n+ test(t[0], exe, suite : 'log')\n+endforeach\ndiff --git a/test/meson.build b/test/meson.build\nindex 60ce960..44d8495 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -4,6 +4,7 @@ subdir('camera')\n subdir('controls')\n subdir('ipa')\n subdir('ipc')\n+subdir('log')\n subdir('media_device')\n subdir('pipeline')\n subdir('stream')\n", "prefixes": [ "libcamera-devel", "2/2" ] }