From patchwork Mon Jul 18 08:15:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naushir Patuck X-Patchwork-Id: 16668 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 DC199BD1F1 for ; Mon, 18 Jul 2022 08:16:09 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 486BA63314; Mon, 18 Jul 2022 10:16:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658132169; 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=Kma5P3pu5OIYsuIaZXy6wF1mwD3Ulg+/dWkj9sH4KPGnn6H+SwMPQkQfwnK9T4ygq /Ook9Uk3Sb0pNxCsHQ12VhQFJVidQK7ud6HAcNvHYyziE+u2CfoR/PFhWF69+eoBJa m5rMvLvb5pRs4aFJiTy5LRptTozg0FirrB8AOwCLIrJig+2WvnbVokFSKw2sz1EqRE GMNTRBa14ptg/TQCL/J0smyP2nyY82Pn431izIF4/q6G1rx9M4fviOe3xHm6rZose0 YYpiO8zuD+zrh5vXYHYwswZdeyEPCkuEJ70qR9mJYtBJqk0ug9OE3p7yyGBUMR/bDO IYu0Wn6abrtXQ== Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id CDDE56048A for ; Mon, 18 Jul 2022 10:16:06 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (2048-bit key; unprotected) header.d=raspberrypi.com header.i=@raspberrypi.com header.b="nSjZbQ4E"; dkim-atps=neutral Received: by mail-wm1-x336.google.com with SMTP id ay11-20020a05600c1e0b00b003a3013da120so7292022wmb.5 for ; Mon, 18 Jul 2022 01:16:06 -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=nSjZbQ4E6W/29SA2JTUCvfzNsYneexE1X3IADFUT88iZDwhUXOlRaJ5m68QbwhSCk0 vL7lW+Hnj1qT/A2uafqbLxfXPCRKPyL1KSMFSZQfx2xTIvEOWqOkbla08Vqhgpbr6/iG luCFcj8z4ijXUvjhVRiTigQPsIyR3KmdNrX/6pvaN07nI2TOVOlhFnb9oeedLcdVTc9l XrUcAtrYn6GVYELMfiYT8qnez1YjmX1/hdxqJGNkkeHfWqWH/KrMVodckT97CNOTeS+m VDgffXmUeifuQFkWsJPb43b6pfmlrbD0PBgz5rqJaO5ngZSo2EoM6Nd13uKKhkGzmYQ4 /5kw== 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=yqtE31SUpkUYJQJuwcRERsTJ+AHjonKhzNO8NyHdusmMwrnqjPdkYmk+JQ23sIFSYX 7vu0X9RubMeRrdCuQzFxzrmekkeQ18HW2eW9ECWnAYmUV+x1UZOhN5M6fuSBdQq3KWRL yzN8DW12m7o+IkJ+I7oUAGqQwgUZjPVobsfem4PpA8nrBao2qERyMihcsuaNcafliP8S 7F+VnRfie18OUg6pmk/1VvQDYkyr1bMe/vyAzVnz1uG3GnZt4d5mgoBq8cKsdCaY9wbD rp7T0b7PQaibj1zHd8e7ETUsYN4H/2gZyFiF7uvmBBX75lPsJiYFklozVuDbynyZgMIG JRmQ== X-Gm-Message-State: AJIora955EkcYeKTQB3EBaeLbhW+/JU+08CQgrPPtOxrnqNXrkGeSgmH 5k06vNbgiXgQ6m+hR4VRuaRB/P9n4AbCKA== X-Google-Smtp-Source: AGRyM1uYkpOmLDb+tf2d+QAvcAs3R01zc/WaYAgKSNcowLNMpTC8KJg2gmVT7CnIHS92FWr4Vld3vw== X-Received: by 2002:a7b:c3cc:0:b0:3a3:8ec:d69 with SMTP id t12-20020a7bc3cc000000b003a308ec0d69mr16208848wmj.78.1658132166277; Mon, 18 Jul 2022 01:16:06 -0700 (PDT) Received: from naush-laptop.localdomain ([93.93.133.154]) by smtp.gmail.com with ESMTPSA id a15-20020adffb8f000000b0021dbac444a7sm10206795wrr.59.2022.07.18.01.16.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 18 Jul 2022 01:16:05 -0700 (PDT) To: libcamera-devel@lists.libcamera.org Date: Mon, 18 Jul 2022 09:15:55 +0100 Message-Id: <20220718081602.32535-2-naush@raspberrypi.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220718081602.32535-1-naush@raspberrypi.com> References: <20220718081602.32535-1-naush@raspberrypi.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v6 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++; }