[{"id":34606,"web_url":"https://patchwork.libcamera.org/comment/34606/","msgid":"<20250612142048.GB10542@pendragon.ideasonboard.com>","date":"2025-06-12T14:20:48","subject":"Re: [PATCH v2 1/2] libcamera: test: Add a failing test for the log\n\tlevel parser","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"On Thu, Jun 12, 2025 at 03:56:44PM +0200, Stefan Klug wrote:\n> Log level parsing doesn't always work as expected.  Add a failing test\n> for that.\n> \n> Co-authored-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> Signed-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(-)\n> \n> diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp\n> index 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\tint result = TestPass;\n\n> +\n> +\t\tfor (const auto &[c, s] : expected) {\n> +\t\t\tif (c.severity() != s) {\n> +\t\t\t\tok = false;\n\n\t\t\t\tresult = TestFail;\n\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\n\t\treturn result;\n\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>  \n> diff --git a/test/log/meson.build b/test/log/meson.build\n> index 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\nMissing space before true.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\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","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 D9D0DBDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 14:12:42 +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 31EC115BF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 16:12:26 +0200 (CEST)","from perceval.ideasonboard.com\n\tby perceval.ideasonboard.com with LMTP id YJFNB0riSmgtRC0A4E0KoQ\n\t(envelope-from <libcamera-devel-bounces@lists.libcamera.org>)\n\tfor <kbingham@ideasonboard.com>; Thu, 12 Jun 2025 16:20:58 +0200","from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\tby perceval.ideasonboard.com (Postfix) with ESMTPS\n\tid BA661D6;\tThu, 12 Jun 2025 16:20:57 +0200 (CEST)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 7033E68DC0;\n\tThu, 12 Jun 2025 16:21:04 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 834B56154C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 12 Jun 2025 16:21:02 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-209-231.bb.dnainternet.fi\n\t[81.175.209.231])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 5B06CD6;\n\tThu, 12 Jun 2025 16:20:53 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750687946;\n\tbh=f4RH/9lRq0SgNmnFl0OsYSuVlfthycMp8uClO5Jeu5c=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:List-Id:\n\tList-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe:\n\tResent-From:Resent-To:From;\n\tb=rp9L3uyLxU3TCuL88kvh/j1TVOh4mKbWZLXHl7KCErm9BcV9KV9kpoh/eI4ukFD44\n\tIFC/gJ9SrqGDbDzuC41Z2gXvl8huxdsTvUDaOefYyZxl/eGuUcrwr8C+1E66hgLBdT\n\tZKIHc3oAewkqHQbUB9Qwd/s5p8FGLW1d+8DORhhA=","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1749738053;\n\tbh=DvPr69toDw3AEGw0lskhB8jIx8iyxzRqCpEimzEPYPs=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=hyBYXJY+DIbAQjGTZ8KRET3AjXaUUxdO8j0fWBOzU2K2YuLWEDXSn4m1Gr5U1/CsN\n\tqJuMA0VSNI2pzBAQ0vTER6TfJFgXUGoyptmucd4+CIhl4VrwqBwhVHbOnm7mwbXyqX\n\tLWIqQyckZuXup8mC7q7gIWZG4VAL/pjWlR5HIGRs="],"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=hyBYXJY+; 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=\"hyBYXJY+\";\tdkim-atps=neutral"],"Date":"Thu, 12 Jun 2025 17:20:48 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Stefan Klug <stefan.klug@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org, =?utf-8?b?QmFybmFiw6FzIFDFkWN6?=\n\t=?utf-8?q?e?= <barnabas.pocze@ideasonboard.com>","Subject":"Re: [PATCH v2 1/2] libcamera: test: Add a failing test for the log\n\tlevel parser","Message-ID":"<20250612142048.GB10542@pendragon.ideasonboard.com>","References":"<20250612135943.522819-1-stefan.klug@ideasonboard.com>\n\t<20250612135943.522819-2-stefan.klug@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Disposition":"inline","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250612135943.522819-2-stefan.klug@ideasonboard.com>","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":"sIid6v3htYjF","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"}},{"id":34607,"web_url":"https://patchwork.libcamera.org/comment/34607/","msgid":"<174980296328.425770.14546440633752747037@ping.linuxembedded.co.uk>","date":"2025-06-13T08:22:43","subject":"Re: [PATCH v2 1/2] libcamera: test: Add a failing test for the log\n\tlevel parser","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Laurent Pinchart (2025-06-12 15:20:48)\n> On Thu, Jun 12, 2025 at 03:56:44PM +0200, Stefan Klug wrote:\n> > Log level parsing doesn't always work as expected.  Add a failing test\n> > for that.\n> > \n> > Co-authored-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>\n> > Signed-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(-)\n> > \n> > diff --git a/test/log/log_api.cpp b/test/log/log_api.cpp\n> > index 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> >               return TestPass;\n> >       }\n> >  \n> > +     int testEnvLevels()\n> > +     {\n> > +             setenv(\"LIBCAMERA_LOG_LEVELS\",\n> > +                    \"Cat0:0,Cat0:9999,Cat1:INFO,Cat1:INVALID,Cat2:2,Cat2:-1,\"\n> > +                    \"Cat3:ERROR,Cat3:{[]},Cat4:4,Cat4:rubbish\",\n> > +                    true);\n> > +             logSetTarget(libcamera::LoggingTargetNone);\n> > +\n> > +             const std::pair<const LogCategory &, libcamera::LogSeverity> expected[] = {\n> > +                     { _LOG_CATEGORY(Cat0)(), libcamera::LogDebug },\n> > +                     { _LOG_CATEGORY(Cat1)(), libcamera::LogInfo },\n> > +                     { _LOG_CATEGORY(Cat2)(), libcamera::LogWarning },\n> > +                     { _LOG_CATEGORY(Cat3)(), libcamera::LogError },\n> > +                     { _LOG_CATEGORY(Cat4)(), libcamera::LogFatal },\n> > +             };\n> > +             bool ok = true;\n> \n>                 int result = TestPass;\n> \n> > +\n> > +             for (const auto &[c, s] : expected) {\n> > +                     if (c.severity() != s) {\n> > +                             ok = false;\n> \n>                                 result = TestFail;\n> \n> > +                             cerr << \"Severity of \" << c.name() << \" (\" << c.severity() << \") \"\n> > +                                  << \"does not equal \" << s << endl;\n> > +                     }\n> > +             }\n> > +\n> > +             return ok ? TestPass : TestFail;\n> \n>                 return result;\n> \n> > +     }\n> > +\n> >       int testFile()\n> >       {\n> >               int fd = open(\"/tmp\", O_TMPFILE | O_RDWR, S_IRUSR | S_IWUSR);\n> > @@ -135,7 +168,11 @@ protected:\n> >  \n> >       int run() override\n> >       {\n> > -             int ret = testFile();\n> > +             int ret = testEnvLevels();\n> > +             if (ret != TestPass)\n> > +                     return TestFail;\n> > +\n> > +             ret = testFile();\n> >               if (ret != TestPass)\n> >                       return TestFail;\n> >  \n> > diff --git a/test/log/meson.build b/test/log/meson.build\n> > index 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> \n> Missing space before true.\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nI have nothign on top of that so:\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n> \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> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<kieran.bingham@ideasonboard.com>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 59A88BDE6B\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 14:12:54 +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 A76AC15BF\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon, 23 Jun 2025 16:12:37 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1750687957;\n\tbh=MC4PhsmRHcjLjwjexIokae6bX9HpvO74nA3g6sizE9g=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:Resent-From:\n\tResent-To:From;\n\tb=ujoIOcM9c8TWaSwGNKrcRJL57+Fa15JqKYbsN3dWp/2JCZkXw5QyqyHx/WcduZG7E\n\tHhV/IDQanoHJtyPHTgbbglQF+D/PiAAmxwRM8h4slEPJJu3QchVuEER5lVffLnyeXq\n\tzav2676H0xFxnOb2nUcfR3vpr2g2NW7btbsAVLnk=","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20250612142048.GB10542@pendragon.ideasonboard.com>","References":"<20250612135943.522819-1-stefan.klug@ideasonboard.com>\n\t<20250612135943.522819-2-stefan.klug@ideasonboard.com>\n\t<20250612142048.GB10542@pendragon.ideasonboard.com>","Subject":"Re: [PATCH v2 1/2] libcamera: test: Add a failing test for the log\n\tlevel parser","From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org,\n\tBarnab??s P??cze <barnabas.pocze@ideasonboard.com>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tStefan Klug <stefan.klug@ideasonboard.com>","Date":"Fri, 13 Jun 2025 09:22:43 +0100","Message-ID":"<174980296328.425770.14546440633752747037@ping.linuxembedded.co.uk>","User-Agent":"alot/0.9.1","Resent-From":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Resent-To":"parsemail@patchwork.libcamera.org"}}]