From patchwork Wed Jul 13 09:21:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16611 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 9CEEBBD1F1 for ; Wed, 13 Jul 2022 09:22:19 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 19FA963314; Wed, 13 Jul 2022 11:22:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1657704138; 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=MxrUL2x8ofEfYbNxplUmbYpQqE6mNjJZYSVWVFtdIAqmDAasbZeGncg1FYzwoboYx 7EKZ7P+FQ/8T/OCTF2HOMxQ39PYe4YJpA7BYqZZwA3d/vSGJ4SLRsLBjr/l8iu1r3c 8yaGS/7K99GSuj37wefRmR7ZO3o4ypT3gKfeePy+GIlFZ1BhlX/tqBc007jAObZ0B/ A+tJBjrXo36UDQw78bXNrHH9UCDTsvEnfCMqbBypOXrXlIJrJWjN+AGmnsK0B3arC4 dn30LdVllSPqT22XMhcYzJTOyGOEUT5DYu3bphX017LUHbmqllAEvx+REdx5AgMNYf E8+q0Fd30foRw== Received: from mail-wr1-x42a.google.com (mail-wr1-x42a.google.com [IPv6:2a00:1450:4864:20::42a]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C33CA6330A for ; Wed, 13 Jul 2022 11:22:15 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="TaDgFOt8"; dkim-atps=neutral Received: by mail-wr1-x42a.google.com with SMTP id r10so8456468wrv.4 for ; Wed, 13 Jul 2022 02:22: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=TaDgFOt8REvyIdHGCWSwsyh3SacKhyo4JwuvXicFIB55nVd89Hsh3bLUGlEK9cHeaA 7GT/bgZzykrc9ehsQnBzAaWU6BDm8+YOKQWewSHSwed6pzfP0RKWZmJDbpSvG/VK5yBE m7CQtTDGyr5dq6NG1dPiwaxvDSFVOZRmGeCewGeJ/8PFgnvLmlyz9tNvcXjQmvLAE5VC JYooT0lyhVLNWzIu+L/zJIYvlwBDpEtyKeMWEtf+VcvFXYfjmmOizTCc4cTuS4sQZ/3l WhhAXWngsmZ8QoXeYplmyNmuMty/1p83tmUcWof4yGdcnBvJxUHFo6k3dxgaBq6X2Vtx mIfA== 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=T+sutLFHEDlRQlHmXo4OQrsm85FBeIBhOWYm/q8p9wtS+lg90Opjw0GhXqzeFIK+DF hqQD9bfogCdvUX5YTWGp6DL2Uu6m8Z5CIOuD3mj67FV/4u9+iHV3jX63YM8Wg6YTVvig ZS/Ulss8OL2/CQKqwtB2EfEKPngldMFZwTNG3K8kkCPfKTP1UYCe529BP6XKRHvaINe8 jFgYchCIwOjGu8OoiT4WB85C4yZpWE2wfrBL6xSeWPUZYavR25RdeVaKJqNssVW9nLay IIFG7oTCXi0GXCbHJzwCKShD2uzxLXsQSSfEmXTGEnNyy+FDe/dokxwZfS0n1pCMkA0Q q/lA== X-Gm-Message-State: AJIora/Hc//yj9H6TLOy/ZmXVo/t0Yl6o6No5xKs1NyYbwKdA22eJAhs DUWiq9MdPk7TYe2vlrMsIvnFBMyenHW6Mg== X-Google-Smtp-Source: AGRyM1ugYsY0XM43I2VzWG3fXZ6j4X6KuzzNHFQBGETFeO6I4wcxOZyslr7pz6J4XV/xu0M7BRnXqA== X-Received: by 2002:a5d:4a0f:0:b0:21d:9a5e:6b47 with SMTP id m15-20020a5d4a0f000000b0021d9a5e6b47mr2251378wrq.213.1657704135188; Wed, 13 Jul 2022 02:22:15 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id bd20-20020a05600c1f1400b0039747cf8354sm1514778wmb.39.2022.07.13.02.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Jul 2022 02:22:14 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Jul 2022 10:21:52 +0100 Message-Id: <20220713092159.9014-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220713092159.9014-1-naush@raspberrypi.com> References: <20220713092159.9014-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 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++; }