From patchwork Thu Jul 14 15:24:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16628 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 592A3BD1F1 for ; Thu, 14 Jul 2022 15:24:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 0C03D63316; Thu, 14 Jul 2022 17:24:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657812258; bh=Za0RSyh7GJx6ULQnAyPxXi/CJuO19WzhW3cRUhju2wQ=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=FwUWdvSyRe4EAxndNJP93+zg1Gh1K8lS/uHL3tq5Au3+H4PzQflTT8IvSVF1T//kk DerJzCr26lu8dHP/F5F22+mcjTQpwWTWjawJ99msv1oC9t09sKbwJOKkJTbtVSnMer To2C9v+3kgrckSvAx/4WpXht1HGiAbxmqoN6TmhUX1FVXiLevUf+IlrsCoJaQW403O jxZmnf//PCnnQjrGeCK0aD3IaFQmIxFybYCcalzhCERJN6h7xuxXjQV1BCh8UyeHNt eq8L35uQUC+PPTRPfbtY5p20WFZKp7xTqvdZMIV6O8zNf/KRhFLWrJEuagwqFm8u6t EUK5o/y9a5RJQ== Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CB4016330E for ; Thu, 14 Jul 2022 17:24:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="qcWm+AkS"; dkim-atps=neutral Received: by mail-wr1-x429.google.com with SMTP id r10so3037367wrv.4 for ; Thu, 14 Jul 2022 08:24:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=raspberrypi.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=eGWCuZvF3p1ex2VhNai6PufjKuo7/6apKJWnuPxNTQQ=; b=qcWm+AkShzg3XbHtF1gm9x2Wrq9Ugqznl/Z4psfL3AIYO0GXCFP3BEbQI9/cZdel/n zF+J3zwiAfJAiKfZDdJg5uh9eNXffYW6U5+FHBE1dw+IHNWncw+/7SdaB8ZjTLC3z+gi ZhyXMffGHjlYYp/VUD4OJ/u/RhvV5sEdDGdcZSD8xKGuoIHRaWSryG2RNKKkaQvpxqFT fg+F1LXaW7S4tn80zMvnquKNLrRfsHlEHoj9adxLfN3tcLjoIVr3TeZoe5RC+yg7eRlz 2j97FBo8kTF58OcuAcN5OtpxZtS1KuQr/tcSS788/KHaPZ+UHX9i90tDYlWifTA9JHLn MWQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eGWCuZvF3p1ex2VhNai6PufjKuo7/6apKJWnuPxNTQQ=; b=6oklLOUnx7v2wyXzR/ViOT+gRRW//8Lyg79RslkYwBzCMMWNFJmNqczI5YCb42npLQ XCKrNTjitTI0I/SH1CgbdXttZy6CNeMeMyqLAETPrAbuyTONO8y+IRnpXMqQ3oPRDSSA gGwlPkBkTUXEyGuNJUdOUlLxF9a8HR5RyE1GBNvjt1EaPV3gEtBeHO5j4Ez6hyV33H8F gKgc/VSSySOXWUKaCGp0E6xCZsrm3BotcVg8nAulTPeS/aoCAzng0kt5lteECJa9XrkN 8lWUiF+AX8IHgrqTNqqJ27GqrKVoWKAQPiZxv2XkJbbU+zsUzSbt8wWmCAmVUN/9XIg0 dKRA== X-Gm-Message-State: AJIora9hAEjw2M7MhX7w7jKQvXr/NkLKbvktB5g8RVoAz7nU6QU49+MW j6G1JX7np0W9dmMFyV80t1LyKYZLqdlK1Q== X-Google-Smtp-Source: AGRyM1uoqJQN0sk8rfSzAoR99zP7fecYKHTGRmq/apd8YTqy/XrcX7sy+/r65wt0jlPvvY6YyoQq7Q== X-Received: by 2002:adf:d206:0:b0:21d:6434:a158 with SMTP id j6-20020adfd206000000b0021d6434a158mr8993819wrh.37.1657812254182; Thu, 14 Jul 2022 08:24:14 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id h14-20020a1ccc0e000000b003a2e7c13a3asm2322476wmb.42.2022.07.14.08.24.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Jul 2022 08:24:13 -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 Subject: [libcamera-devel] [PATCH v5 1/8] test: yaml-parser: Test dictionary items ordering X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Naushir Patuck via libcamera-devel From: Naushir Patuck Reply-To: Naushir Patuck Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" From: Laurent Pinchart While YAML specifies that mappings are unordered, the Raspberry Pi IPA relies on elements being ordered as in the YAML data. To replace the dependency on boost with the YamlParser class, we thus need to guarantee that the order is preserved. Update the corresponding unit test to ensure this. The test currently fails at the YamlParser doesn't correctly preserve the order, this will be fixed by the next commit. This commit should be reverted when the Raspberry Pi IPA updates to a new tuning data format and drops support for the old format. Signed-off-by: Laurent Pinchart Reviewed-by: Naushir Patuck Tested-by: Naushir Patuck --- test/yaml-parser.cpp | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp index 38f848232fa6..157ecea256cd 100644 --- a/test/yaml-parser.cpp +++ b/test/yaml-parser.cpp @@ -32,8 +32,8 @@ static const string testYaml = " - Mary\n" "dictionary:\n" " a: 1\n" - " b: 2\n" " c: 3\n" + " b: 2\n" "level1:\n" " level2:\n" " - [1, 2]\n" @@ -449,10 +449,10 @@ protected: return TestFail; } - std::map dictValues{ { + static constexpr std::array, 3> dictValues{ { { "a", 1 }, - { "b", 2 }, { "c", 3 }, + { "b", 2 }, } }; size_t dictSize = dictValues.size(); @@ -470,8 +470,8 @@ protected: return TestFail; } - const auto item = dictValues.find(key); - if (item == dictValues.end()) { + const auto &item = dictValues[i]; + if (item.first != key) { std::cerr << "Dictionary key " << i << " has wrong value" << std::endl; return TestFail; @@ -483,17 +483,12 @@ protected: return TestFail; } - if (elem.get(0) != item->second) { + if (elem.get(0) != item.second) { std::cerr << "Dictionary element " << i << " has wrong value" << std::endl; return TestFail; } - /* - * Erase the item to make sure that each iteration - * produces a different value. - */ - dictValues.erase(item); i++; }