{"id":16628,"url":"https://patchwork.libcamera.org/api/1.1/patches/16628/?format=json","web_url":"https://patchwork.libcamera.org/patch/16628/","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":"<20220714152409.9780-2-naush@raspberrypi.com>","date":"2022-07-14T15:24:02","name":"[libcamera-devel,v5,1/8] test: yaml-parser: Test dictionary items ordering","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"d89c593b2871d55f929b50b449389f1e48112f49","submitter":{"id":34,"url":"https://patchwork.libcamera.org/api/1.1/people/34/?format=json","name":"Naushir Patuck","email":"naush@raspberrypi.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16628/mbox/","series":[{"id":3285,"url":"https://patchwork.libcamera.org/api/1.1/series/3285/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3285","date":"2022-07-14T15:24:01","name":"Replace boost JSON parser with libyaml in Raspberry Pi IPA","version":5,"mbox":"https://patchwork.libcamera.org/series/3285/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16628/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16628/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 592A3BD1F1\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 14 Jul 2022 15:24:18 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0C03D63316;\n\tThu, 14 Jul 2022 17:24:18 +0200 (CEST)","from mail-wr1-x429.google.com (mail-wr1-x429.google.com\n\t[IPv6:2a00:1450:4864:20::429])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CB4016330E\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Jul 2022 17:24:15 +0200 (CEST)","by mail-wr1-x429.google.com with SMTP id r10so3037367wrv.4\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 14 Jul 2022 08:24:15 -0700 (PDT)","from naush-laptop.localdomain ([93.93.133.154])\n\tby smtp.gmail.com with ESMTPSA id\n\th14-20020a1ccc0e000000b003a2e7c13a3asm2322476wmb.42.2022.07.14.08.24.12\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tThu, 14 Jul 2022 08:24:13 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1657812258;\n\tbh=Za0RSyh7GJx6ULQnAyPxXi/CJuO19WzhW3cRUhju2wQ=;\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=FwUWdvSyRe4EAxndNJP93+zg1Gh1K8lS/uHL3tq5Au3+H4PzQflTT8IvSVF1T//kk\n\tDerJzCr26lu8dHP/F5F22+mcjTQpwWTWjawJ99msv1oC9t09sKbwJOKkJTbtVSnMer\n\tTo2C9v+3kgrckSvAx/4WpXht1HGiAbxmqoN6TmhUX1FVXiLevUf+IlrsCoJaQW403O\n\tjxZmnf//PCnnQjrGeCK0aD3IaFQmIxFybYCcalzhCERJN6h7xuxXjQV1BCh8UyeHNt\n\teq8L35uQUC+PPTRPfbtY5p20WFZKp7xTqvdZMIV6O8zNf/KRhFLWrJEuagwqFm8u6t\n\tEUK5o/y9a5RJQ==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=raspberrypi.com; s=google;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references\n\t:mime-version:content-transfer-encoding;\n\tbh=eGWCuZvF3p1ex2VhNai6PufjKuo7/6apKJWnuPxNTQQ=;\n\tb=qcWm+AkShzg3XbHtF1gm9x2Wrq9Ugqznl/Z4psfL3AIYO0GXCFP3BEbQI9/cZdel/n\n\tzF+J3zwiAfJAiKfZDdJg5uh9eNXffYW6U5+FHBE1dw+IHNWncw+/7SdaB8ZjTLC3z+gi\n\tZhyXMffGHjlYYp/VUD4OJ/u/RhvV5sEdDGdcZSD8xKGuoIHRaWSryG2RNKKkaQvpxqFT\n\tfg+F1LXaW7S4tn80zMvnquKNLrRfsHlEHoj9adxLfN3tcLjoIVr3TeZoe5RC+yg7eRlz\n\t2j97FBo8kTF58OcuAcN5OtpxZtS1KuQr/tcSS788/KHaPZ+UHX9i90tDYlWifTA9JHLn\n\tMWQA=="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (2048-bit key; \n\tunprotected) header.d=raspberrypi.com\n\theader.i=@raspberrypi.com\n\theader.b=\"qcWm+AkS\"; dkim-atps=neutral","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20210112;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references:mime-version:content-transfer-encoding;\n\tbh=eGWCuZvF3p1ex2VhNai6PufjKuo7/6apKJWnuPxNTQQ=;\n\tb=6oklLOUnx7v2wyXzR/ViOT+gRRW//8Lyg79RslkYwBzCMMWNFJmNqczI5YCb42npLQ\n\tXCKrNTjitTI0I/SH1CgbdXttZy6CNeMeMyqLAETPrAbuyTONO8y+IRnpXMqQ3oPRDSSA\n\tgGwlPkBkTUXEyGuNJUdOUlLxF9a8HR5RyE1GBNvjt1EaPV3gEtBeHO5j4Ez6hyV33H8F\n\tgKgc/VSSySOXWUKaCGp0E6xCZsrm3BotcVg8nAulTPeS/aoCAzng0kt5lteECJa9XrkN\n\t8lWUiF+AX8IHgrqTNqqJ27GqrKVoWKAQPiZxv2XkJbbU+zsUzSbt8wWmCAmVUN/9XIg0\n\tdKRA==","X-Gm-Message-State":"AJIora9hAEjw2M7MhX7w7jKQvXr/NkLKbvktB5g8RVoAz7nU6QU49+MW\n\tj6G1JX7np0W9dmMFyV80t1LyKYZLqdlK1Q==","X-Google-Smtp-Source":"AGRyM1uoqJQN0sk8rfSzAoR99zP7fecYKHTGRmq/apd8YTqy/XrcX7sy+/r65wt0jlPvvY6YyoQq7Q==","X-Received":"by 2002:adf:d206:0:b0:21d:6434:a158 with SMTP id\n\tj6-20020adfd206000000b0021d6434a158mr8993819wrh.37.1657812254182; \n\tThu, 14 Jul 2022 08:24:14 -0700 (PDT)","To":"libcamera-devel@lists.libcamera.org","Date":"Thu, 14 Jul 2022 16:24:02 +0100","Message-Id":"<20220714152409.9780-2-naush@raspberrypi.com>","X-Mailer":"git-send-email 2.25.1","In-Reply-To":"<20220714152409.9780-1-naush@raspberrypi.com>","References":"<20220714152409.9780-1-naush@raspberrypi.com>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","Subject":"[libcamera-devel] [PATCH v5 1/8] test: yaml-parser: Test dictionary\n\titems 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":"Naushir Patuck via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Naushir Patuck <naush@raspberrypi.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nWhile 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 38f848232fa6..157ecea256cd 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@@ -449,10 +449,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@@ -470,8 +470,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@@ -483,17 +483,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","v5","1/8"]}