{"id":23625,"url":"https://patchwork.libcamera.org/api/1.1/patches/23625/?format=json","web_url":"https://patchwork.libcamera.org/patch/23625/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20250612135943.522819-2-stefan.klug@ideasonboard.com>","date":"2025-06-12T13:56:44","name":"[v2,1/2] libcamera: test: Add a failing test for the log level parser","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"64d4b9d591aa56fde2d6a561601894388fc3fb12","submitter":{"id":184,"url":"https://patchwork.libcamera.org/api/1.1/people/184/?format=json","name":"Stefan Klug","email":"stefan.klug@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/23625/mbox/","series":[{"id":5240,"url":"https://patchwork.libcamera.org/api/1.1/series/5240/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=5240","date":"2025-06-12T13:56:43","name":"Fix log level parsing when multiple categories are listed","version":2,"mbox":"https://patchwork.libcamera.org/series/5240/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/23625/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/23625/checks/","tags":{},"headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":["parsemail@patchwork.libcamera.org","kbingham@ideasonboard.com"],"Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 5D3A7BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 14:12:20 +0000 (UTC)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust6594.18-1.cable.virginm.net\n\t[86.31.185.195])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id A885915BF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 16:12:03 +0200 (CEST)","from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id 0B0kKlfdSmgaMi0A4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 12 Jun 2025 15:59:51 +0200","from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\tby perceval.ideasonboard.com (Postfix) with ESMTPS\n\tid 88BDA169;\tThu, 12 Jun 2025 15:59:51 +0200 (CEST)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 1E4B468DC2;\n\tThu, 12 Jun 2025 15:59:59 +0200 (CEST)","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 B7C6D61551\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jun 2025 15:59:53 +0200 (CEST)","from ideasonboard.com (unknown\n\t[IPv6:2a00:6020:448c:6c00:3176:2bf8:8f04:4c4])\n\tby perceval.ideasonboard.com (Postfix) with UTF8SMTPSA id C4DE0169;\n\tThu, 12 Jun 2025 15:59:44 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750687923;\n\tbh=oXWnWY8eXvX5cVuwOlFhkQrR5v4i4wBsledl1Kd06hc=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id:\n\tList-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\tResent-From:Resent-To:From;\n\tb=djwTKfh/yFI4BgQbGput1OyeMr3Q+ofZDNXgSlkLhk+01pUoItDxsIfR9GhCsXPya\n\t1aaf4/ZOdTjtLym1PZx24JRt2hoJGisb3dHlq5rXN0RagaizQ8ObNbR9TXjTiftzep\n\tRqtElud7iJp2Tw+2ldPaa1xv/su6Y/O09Erf4Mto=","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749736784;\n\tbh=ZKg3lMlyX7gLA7uXXVKXCtfM8PCrRdeKQUgLQtc5cRw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=jJr01cUYtWLk9nupb1IKkQ9Bo22pQLFkY+8J0AqWtq3h4uhGIMF4C/+eki5EMTWlA\n\tYowPDcdmXtbK3Q75NVwuP3A0buI8jBvFVopXCod5sBkXSUOtqhY5JuemBUuP9h0ed+\n\txhxa4DONh5hJaYnah3EdSM5Lm9G93aNcxCpAgJPw="],"Authentication-Results":["perceval.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.a=rsa-sha256 header.s=mail header.b=jJr01cUY; dkim-atps=neutral","lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"jJr01cUY\";\tdkim-atps=neutral"],"From":"Stefan Klug <stefan.klug@ideasonboard.com>","To":"libcamera-devel@lists.libcamera.org","Cc":"Stefan Klug <stefan.klug@ideasonboard.com>, =?utf-8?q?Barnab=C3=A1s_P?=\n\t=?utf-8?b?xZFjemU=?= <barnabas.pocze@ideasonboard.com>","Subject":"[PATCH v2 1/2] libcamera: test: Add a failing test for the log level\n\tparser","Date":"Thu, 12 Jun 2025 15:56:44 +0200","Message-ID":"<20250612135943.522819-2-stefan.klug@ideasonboard.com>","X-Mailer":"git-send-email 2.48.1","In-Reply-To":"<20250612135943.522819-1-stefan.klug@ideasonboard.com>","References":"<20250612135943.522819-1-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"quoted-printable","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>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>","X-TUID":"EZK/VqjjYHAd","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"},"content":"Log level parsing doesn't always work as expected.  Add a failing test\nfor that.\n\nCo-authored-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\nSigned-off-by: Stefan Klug <stefan.klug@ideasonboard.com>\n---\n test/log/log_api.cpp | 39 ++++++++++++++++++++++++++++++++++++++-\n test/log/meson.build |  5 +++--\n 2 files changed, 41 insertions(+), 3 deletions(-)","diff":"diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp\nindex 0b999738d891..8d19cf0ceb67 100644\n--- a/test/log/log_api.cpp\n+++ b/test/log/log_api.cpp\n@@ -26,6 +26,11 @@ using namespace std;\n using namespace libcamera;\n \n LOG_DEFINE_CATEGORY(LogAPITest)\n+LOG_DEFINE_CATEGORY(Cat0)\n+LOG_DEFINE_CATEGORY(Cat1)\n+LOG_DEFINE_CATEGORY(Cat2)\n+LOG_DEFINE_CATEGORY(Cat3)\n+LOG_DEFINE_CATEGORY(Cat4)\n \n class LogAPITest : public Test\n {\n@@ -74,6 +79,34 @@ protected:\n \t\treturn TestPass;\n \t}\n \n+\tint testEnvLevels()\n+\t{\n+\t\tsetenv(\"LIBCAMERA_LOG_LEVELS\",\n+\t\t       \"Cat0:0,Cat0:9999,Cat1:INFO,Cat1:INVALID,Cat2:2,Cat2:-1,\"\n+\t\t       \"Cat3:ERROR,Cat3:{[]},Cat4:4,Cat4:rubbish\",\n+\t\t       true);\n+\t\tlogSetTarget(libcamera::LoggingTargetNone);\n+\n+\t\tconst std::pair<const LogCategory &, libcamera::LogSeverity> expected[] = {\n+\t\t\t{ _LOG_CATEGORY(Cat0)(), libcamera::LogDebug },\n+\t\t\t{ _LOG_CATEGORY(Cat1)(), libcamera::LogInfo },\n+\t\t\t{ _LOG_CATEGORY(Cat2)(), libcamera::LogWarning },\n+\t\t\t{ _LOG_CATEGORY(Cat3)(), libcamera::LogError },\n+\t\t\t{ _LOG_CATEGORY(Cat4)(), libcamera::LogFatal },\n+\t\t};\n+\t\tbool ok = true;\n+\n+\t\tfor (const auto &[c, s] : expected) {\n+\t\t\tif (c.severity() != s) {\n+\t\t\t\tok = false;\n+\t\t\t\tcerr << \"Severity of \" << c.name() << \" (\" << c.severity() << \") \"\n+\t\t\t\t     << \"does not equal \" << s << endl;\n+\t\t\t}\n+\t\t}\n+\n+\t\treturn ok ? TestPass : TestFail;\n+\t}\n+\n \tint testFile()\n \t{\n \t\tint fd = open(\"/tmp\", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);\n@@ -135,7 +168,11 @@ protected:\n \n \tint run() override\n \t{\n-\t\tint ret = testFile();\n+\t\tint ret = testEnvLevels();\n+\t\tif (ret != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\tret = testFile();\n \t\tif (ret != TestPass)\n \t\t\treturn TestFail;\n \ndiff --git a/test/log/meson.build b/test/log/meson.build\nindex 2298ff84ee62..d91f62b9ea5b 100644\n--- a/test/log/meson.build\n+++ b/test/log/meson.build\n@@ -1,7 +1,7 @@\n # SPDX-License-Identifier: CC0-1.0\n \n log_test = [\n-    {'name': 'log_api', 'sources': ['log_api.cpp']},\n+    {'name': 'log_api', 'sources': ['log_api.cpp'], 'should_fail':true},\n     {'name': 'log_process', 'sources': ['log_process.cpp']},\n ]\n \n@@ -11,5 +11,6 @@ foreach test : log_test\n                      link_with : test_libraries,\n                      include_directories : test_includes_internal)\n \n-    test(test['name'], exe, suite : 'log')\n+    test(test['name'], exe, suite : 'log',\n+         should_fail : test.get('should_fail', false))\n endforeach\n","prefixes":["v2","1/2"]}