Patch Detail
Show a patch.
GET /api/patches/1676/?format=api
{ "id": 1676, "url": "https://patchwork.libcamera.org/api/patches/1676/?format=api", "web_url": "https://patchwork.libcamera.org/patch/1676/", "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": "<20190712201620.30457-2-paul.elder@ideasonboard.com>", "date": "2019-07-12T20:16:18", "name": "[libcamera-devel,2/4] test: logging: add logSetStream test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "eaa19912d9631a6c0468e5e533dfad506e13cf6f", "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/1676/mbox/", "series": [ { "id": 427, "url": "https://patchwork.libcamera.org/api/series/427/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=427", "date": "2019-07-12T20:16:17", "name": "[libcamera-devel,1/4] libcamera: logging: add syslog, stream, and nowhere logging targets", "version": 1, "mbox": "https://patchwork.libcamera.org/series/427/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/1676/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/1676/checks/", "tags": {}, "headers": { "Return-Path": "<paul.elder@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 1D9F861607\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 12 Jul 2019 22:16:32 +0200 (CEST)", "from neptunite.amanokami.net (softbank126209254147.bbtec.net\n\t[126.209.254.147])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 6396D2B2;\n\tFri, 12 Jul 2019 22:16:30 +0200 (CEST)" ], "DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1562962591;\n\tbh=rvkyK7edjzN2JWOT54Mw0k+Pn94QaMBEyyw+XbTYZlc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=hZXxtFUzPF3Mu2mplqub5xQGBpnbO3QTDugbMxSA4a0TjH3SxFCBn9EhGP57Gru+F\n\tLnXCGj/scBTusws6Ldl07Sy0Yp7pfJhTQ7thV2qeqPW0ENhFmDOh6hO75yoaPeB6vS\n\tuW3JQgRC2LaWMr6D3tiK7b7hKifiCy87FM2iFrDs=", "From": "Paul Elder <paul.elder@ideasonboard.com>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Sat, 13 Jul 2019 05:16:18 +0900", "Message-Id": "<20190712201620.30457-2-paul.elder@ideasonboard.com>", "X-Mailer": "git-send-email 2.20.1", "In-Reply-To": "<20190712201620.30457-1-paul.elder@ideasonboard.com>", "References": "<20190712201620.30457-1-paul.elder@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH 2/4] test: logging: add logSetStream 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": "Fri, 12 Jul 2019 20:16:32 -0000" }, "content": "Test the new logSetStream loggin API call. Reorganize the logging API\ntests at the same time.\n\nlogSetTarget is not tested since the nowhere and syslog logging\ndestinations do not really need to be tested.\n\nSigned-off-by: Paul Elder <paul.elder@ideasonboard.com>\n---\n test/log.cpp | 82 +++++++++++++++++++++++++++++++++++++---------------\n 1 file changed, 58 insertions(+), 24 deletions(-)", "diff": "diff --git a/test/log.cpp b/test/log.cpp\nindex 89fb5ca..c1446bd 100644\n--- a/test/log.cpp\n+++ b/test/log.cpp\n@@ -29,19 +29,8 @@ LOG_DEFINE_CATEGORY(LogAPITest)\n class LogAPITest : public Test\n {\n protected:\n-\tint run() override\n+\tvoid doLogging()\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[32];\n-\t\tsnprintf(path, sizeof(path), \"/proc/self/fd/%u\", fd);\n-\n-\t\tlogSetFile(path);\n-\n \t\tlogSetLevel(\"LogAPITest\", \"DEBUG\");\n \t\tLOG(LogAPITest, Info) << \"good 1\";\n \n@@ -55,19 +44,13 @@ protected:\n \t\tlogSetLevel(\"LogAPITest\", \"WARN\");\n \t\tLOG(LogAPITest, Warning) << \"good 5\";\n \t\tLOG(LogAPITest, Info) << \"bad\";\n+\t}\n \n-\t\tchar buf[1000];\n-\t\tmemset(buf, 0, sizeof(buf));\n-\t\tlseek(fd, 0, SEEK_SET);\n-\t\tif (read(fd, buf, sizeof(buf)) < 0) {\n-\t\t\tcerr << \"Failed to read tmp log file\" << endl;\n-\t\t\treturn TestFail;\n-\t\t}\n-\t\tclose(fd);\n-\n-\t\tstd::list<int> goodList = { 1, 3, 5 };\n-\t\tstd::basic_istringstream<char> iss((std::string(buf)));\n-\t\tstd::string line;\n+\tint verifyOutput(string &str)\n+\t{\n+\t\tlist<int> goodList = { 1, 3, 5 };\n+\t\tbasic_istringstream<char> iss(str);\n+\t\tstring line;\n \t\twhile (getline(iss, line)) {\n \t\t\tif (goodList.empty()) {\n \t\t\t\tcout << \"Too many log lines\" << endl;\n@@ -90,6 +73,57 @@ protected:\n \n \t\treturn TestPass;\n \t}\n+\n+\tint testFile()\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[32];\n+\t\tsnprintf(path, sizeof(path), \"/proc/self/fd/%u\", fd);\n+\n+\t\tlogSetFile(path);\n+\n+\t\tdoLogging();\n+\n+\t\tchar buf[1000];\n+\t\tmemset(buf, 0, sizeof(buf));\n+\t\tlseek(fd, 0, SEEK_SET);\n+\t\tif (read(fd, buf, sizeof(buf)) < 0) {\n+\t\t\tcerr << \"Failed to read tmp log file\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\t\tclose(fd);\n+\n+\t\tstring str(buf);\n+\t\treturn verifyOutput(str);\n+\t}\n+\n+\tint testStream()\n+\t{\n+\t\tostringstream log;\n+\t\tlogSetStream(log);\n+\n+\t\tdoLogging();\n+\n+\t\tstring str(log.str());\n+\t\treturn verifyOutput(str);\n+\t}\n+\n+\tint run() override\n+\t{\n+\t\tint ret1 = testFile();\n+\n+\t\tint ret2 = testStream();\n+\n+\t\tif (ret1 == TestPass && ret2 == TestPass)\n+\t\t\treturn TestPass;\n+\n+\t\treturn TestFail;\n+\t}\n };\n \n TEST_REGISTER(LogAPITest)\n", "prefixes": [ "libcamera-devel", "2/4" ] }