{"id":16814,"url":"https://patchwork.libcamera.org/api/1.1/patches/16814/?format=json","web_url":"https://patchwork.libcamera.org/patch/16814/","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":"<20220727023816.30008-3-laurent.pinchart@ideasonboard.com>","date":"2022-07-27T02:38:04","name":"[libcamera-devel,v7,02/14] test: yaml-parser: Test dictionary items ordering","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"d89c593b2871d55f929b50b449389f1e48112f49","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/1.1/people/2/?format=json","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16814/mbox/","series":[{"id":3331,"url":"https://patchwork.libcamera.org/api/1.1/series/3331/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3331","date":"2022-07-27T02:38:02","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":7,"mbox":"https://patchwork.libcamera.org/series/3331/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16814/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16814/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 72EC2BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tWed, 27 Jul 2022 02:38:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 37DAA6331B;\n\tWed, 27 Jul 2022 04:38:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 5A979603E8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tWed, 27 Jul 2022 04:38:20 +0200 (CEST)","from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi\n\t[62.78.145.57])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id E344C56D;\n\tWed, 27 Jul 2022 04:38:19 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1658889503;\n\tbh=MQkQfVXMW4E5zqC4m/MSSc5M0uv0lRmko8CSTsQgS8o=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=3gf56X+50duFgpEeRGZB05ktj+6Dgls0ERvfdi2cv/m99kehrV1cRLsUs+kZELQ0s\n\tyJiGqR3Ny5cM/Wcp52Tw8XOy3S6APla63Gbc0S6M+fSRwAQC4zhnPbA40sJJoz9hkp\n\tfWvkYrGSy9k7pOjw9Gyfx8fAU+TAKJ61DSzTunHuMHb6l5aRNGuWJbvjQk1IL8uXUn\n\tWPAfB8XwQWKwtmUlt3ieGa31+jcqQiaYfc5jn6T+GOpVXgm83XA1H8jTi5CHMDruIb\n\tu3toHEHKhcty5SeBQRLZfFholRq0KkufkUvhGXWcV8eS8K19S5NTeYanE/+LBOTrWg\n\t+55tNgM5EQUkA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1658889500;\n\tbh=MQkQfVXMW4E5zqC4m/MSSc5M0uv0lRmko8CSTsQgS8o=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=VeabkQSsN1pn6hvTX7e0Rdw86HuEesquh3efRTu4vAf6QNJZtcCBM7kxdmi3aIiKd\n\tg/Ab/rFP5+DoHcaoJM6JnjTGjHXYy073vThsmUfdH/duaLs6RLGqbr42WTTCBTOZDH\n\tZlh/Hi7O7c5arqglxs5/iAbnJX5ml6Um2vSATilU="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"VeabkQSs\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org","Date":"Wed, 27 Jul 2022 05:38:04 +0300","Message-Id":"<20220727023816.30008-3-laurent.pinchart@ideasonboard.com>","X-Mailer":"git-send-email 2.35.1","In-Reply-To":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>","References":"<20220727023816.30008-1-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v7 02/14] test: yaml-parser: Test\n\tdictionary items ordering","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>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"While YAML specifies that mappings are unordered, the Raspberry Pi IPA\nrelies on elements being ordered as in the YAML data. To replace the\ndependency on boost with the YamlParser class, we thus need to guarantee\nthat the order is preserved. Update the corresponding unit test to\nensure this. The test currently fails at the YamlParser doesn't\ncorrectly preserve the order, this will be fixed by the next commit.\n\nThis commit should be reverted when the Raspberry Pi IPA updates to a\nnew tuning data format and drops support for the old format.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\nReviewed-by: Naushir Patuck <naush@raspberrypi.com>\nTested-by: Naushir Patuck <naush@raspberrypi.com>\n---\n test/yaml-parser.cpp | 17 ++++++-----------\n 1 file changed, 6 insertions(+), 11 deletions(-)","diff":"diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\nindex ebb654f2ef9c..782331764346 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -32,8 +32,8 @@ static const string testYaml =\n \t\"  - Mary\\n\"\n \t\"dictionary:\\n\"\n \t\"  a: 1\\n\"\n-\t\"  b: 2\\n\"\n \t\"  c: 3\\n\"\n+\t\"  b: 2\\n\"\n \t\"level1:\\n\"\n \t\"  level2:\\n\"\n \t\"    - [1, 2]\\n\"\n@@ -448,10 +448,10 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n-\t\tstd::map<std::string, int> dictValues{ {\n+\t\tstatic constexpr std::array<std::pair<const char *, int>, 3> dictValues{ {\n \t\t\t{ \"a\", 1 },\n-\t\t\t{ \"b\", 2 },\n \t\t\t{ \"c\", 3 },\n+\t\t\t{ \"b\", 2 },\n \t\t} };\n \n \t\tsize_t dictSize = dictValues.size();\n@@ -469,8 +469,8 @@ protected:\n \t\t\t\treturn TestFail;\n \t\t\t}\n \n-\t\t\tconst auto item = dictValues.find(key);\n-\t\t\tif (item == dictValues.end()) {\n+\t\t\tconst auto &item = dictValues[i];\n+\t\t\tif (item.first != key) {\n \t\t\t\tstd::cerr << \"Dictionary key \" << i << \" has wrong value\"\n \t\t\t\t\t  << std::endl;\n \t\t\t\treturn TestFail;\n@@ -482,17 +482,12 @@ protected:\n \t\t\t\treturn TestFail;\n \t\t\t}\n \n-\t\t\tif (elem.get<int32_t>(0) != item->second) {\n+\t\t\tif (elem.get<int32_t>(0) != item.second) {\n \t\t\t\tstd::cerr << \"Dictionary element \" << i << \" has wrong value\"\n \t\t\t\t\t  << std::endl;\n \t\t\t\treturn TestFail;\n \t\t\t}\n \n-\t\t\t/*\n-\t\t\t * Erase the item to make sure that each iteration\n-\t\t\t * produces a different value.\n-\t\t\t */\n-\t\t\tdictValues.erase(item);\n \t\t\ti++;\n \t\t}\n \n","prefixes":["libcamera-devel","v7","02/14"]}