Patch Detail
Show a patch.
GET /api/1.1/patches/17130/?format=api
{ "id": 17130, "url": "https://patchwork.libcamera.org/api/1.1/patches/17130/?format=api", "web_url": "https://patchwork.libcamera.org/patch/17130/", "project": { "id": 1, "url": "https://patchwork.libcamera.org/api/1.1/projects/1/?format=api", "name": "libcamera", "link_name": "libcamera", "list_id": "libcamera_core", "list_email": "libcamera-devel@lists.libcamera.org", "web_url": "", "scm_url": "", "webscm_url": "" }, "msgid": "<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>", "date": "2022-08-16T01:54:08", "name": "[libcamera-devel,v4,3/9] test: yaml-parser: Test out-of-range checks on integer parsing", "commit_ref": null, "pull_url": null, "state": "accepted", "archived": false, "hash": "d82a21f7a17427417361e84e5083f67e5af03bde", "submitter": { "id": 2, "url": "https://patchwork.libcamera.org/api/1.1/people/2/?format=api", "name": "Laurent Pinchart", "email": "laurent.pinchart@ideasonboard.com" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/17130/mbox/", "series": [ { "id": 3418, "url": "https://patchwork.libcamera.org/api/1.1/series/3418/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=3418", "date": "2022-08-16T01:54:05", "name": "Add DPF tuning support for RkISP1", "version": 4, "mbox": "https://patchwork.libcamera.org/series/3418/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/17130/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/17130/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 9893CC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 16 Aug 2022 01:54:36 +0000 (UTC)", "from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FED161FCC;\n\tTue, 16 Aug 2022 03:54:36 +0200 (CEST)", "from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 912B161FC7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 16 Aug 2022 03:54:32 +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 2E7D0496;\n\tTue, 16 Aug 2022 03:54:32 +0200 (CEST)" ], "DKIM-Signature": [ "v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660614876;\n\tbh=2yct2hbDhZ7Y5+s+AVYn0T62Z6ztIKO9p9BNEyV/fAA=;\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=3cjkh3uH2zoUJZBdjYcvVS1MYXLZi8gr8uWay7rgwQbxSTO0Hzqw5vf/F/iDfjrXM\n\tiz7OqnVVqVLizaIrWIQfzZZKyWdeVBrXM5rnasv1V2ROF1+xrpJ220EcgGrEgAFXbH\n\tMy3x34C1hF+r6n3dXlLOaJkT7tpxpuQ7JsA+w2+arVNu1mZppvB+PfJKSV3pgilHSI\n\tPlxbIDiutnRQ5UFU9IYfsfC91JP0CSEuSavp+7FU1SwG2wNZkOZ+Bidb/tAgks68Gj\n\t6EEntPS9GliMjQ+Z9PW245gmP232QIy0ZMuVpaKoesr7Q7VqA2dqx17an6N3dDK/Gl\n\tsL8ye3xyojltA==", "v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660614872;\n\tbh=2yct2hbDhZ7Y5+s+AVYn0T62Z6ztIKO9p9BNEyV/fAA=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=dqYJtJDrFeTI+YXaKGBp48hEDwwSQ1VgfWDreroBdzPALLNoeNIbUaQgbudujY5ni\n\tJXVJuRpjLR+YYDTK6ep0NVn4Wj7MSXjcdlno4mjNs5er3sfrrXiyukbWdnTwOOIBdI\n\tcpaCJqvd9M3adDSKOJQEGTDoQlD6EtSS0Hqm/2AE=" ], "Authentication-Results": "lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"dqYJtJDr\"; dkim-atps=neutral", "To": "libcamera-devel@lists.libcamera.org", "Date": "Tue, 16 Aug 2022 04:54:08 +0300", "Message-Id": "<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>", "X-Mailer": "git-send-email 2.35.1", "In-Reply-To": "<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>", "References": "<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>", "MIME-Version": "1.0", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v4 3/9] test: yaml-parser: Test\n\tout-of-range checks on integer parsing", "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": "Add 16-bit integer parsing tests, including a test to verify the\nout-of-range checks when parsing 32-bit integers as 16-bit values. That\ntest currently fails.\n\nSigned-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n test/yaml-parser.cpp | 77 ++++++++++++++++++++++++++++++++++++++------\n 1 file changed, 68 insertions(+), 9 deletions(-)", "diff": "diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\nindex 803e70beb782..28f8cc8822b3 100644\n--- a/test/yaml-parser.cpp\n+++ b/test/yaml-parser.cpp\n@@ -24,8 +24,10 @@ using namespace std;\n static const string testYaml =\n \t\"string: libcamera\\n\"\n \t\"double: 3.14159\\n\"\n-\t\"uint32_t: 100\\n\"\n-\t\"int32_t: -100\\n\"\n+\t\"int16_t: -1000\\n\"\n+\t\"uint16_t: 1000\\n\"\n+\t\"int32_t: -100000\\n\"\n+\t\"uint32_t: 100000\\n\"\n \t\"size: [1920, 1080]\\n\"\n \t\"list:\\n\"\n \t\" - James\\n\"\n@@ -74,6 +76,8 @@ protected:\n \n \tenum class Type {\n \t\tString,\n+\t\tInt16,\n+\t\tUInt16,\n \t\tInt32,\n \t\tUInt32,\n \t\tDouble,\n@@ -86,8 +90,10 @@ protected:\n \t{\n \t\tbool isList = type == Type::List || type == Type::Size;\n \t\tbool isScalar = !isList && type != Type::Dictionary;\n-\t\tbool isInteger = type == Type::Int32 || type == Type::UInt32;\n-\t\tbool isSigned = type == Type::Int32;\n+\t\tbool isInteger16 = type == Type::Int16 || type == Type::UInt16;\n+\t\tbool isInteger32 = type == Type::Int32 || type == Type::UInt32;\n+\t\tbool isInteger = isInteger16 || isInteger32;\n+\t\tbool isSigned = type == Type::Int16 || type == Type::Int32;\n \n \t\tif ((isScalar && !obj.isValue()) || (!isScalar && obj.isValue())) {\n \t\t\tstd::cerr\n@@ -118,6 +124,20 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tif (!isInteger16 && obj.get<int16_t>()) {\n+\t\t\tstd::cerr\n+\t\t\t\t<< \"Object \" << name << \" didn't fail to parse as \"\n+\t\t\t\t<< \"int16_t\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif ((!isInteger16 || isSigned) && obj.get<uint16_t>()) {\n+\t\t\tstd::cerr\n+\t\t\t\t<< \"Object \" << name << \" didn't fail to parse as \"\n+\t\t\t\t<< \"uint16_t\" << std::endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n \t\tif (!isInteger && obj.get<int32_t>()) {\n \t\t\tstd::cerr\n \t\t\t\t<< \"Object \" << name << \" didn't fail to parse as \"\n@@ -154,7 +174,8 @@ protected:\n \t{\n \t\tuint64_t unsignedValue = static_cast<uint64_t>(value);\n \t\tstd::string strValue = std::to_string(value);\n-\t\tbool isSigned = type == Type::Int32;\n+\t\tbool isInteger16 = type == Type::Int16 || type == Type::UInt16;\n+\t\tbool isSigned = type == Type::Int16 || type == Type::Int32;\n \n \t\t/* All integers can be parsed as strings or double. */\n \n@@ -174,6 +195,26 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\tif (isInteger16) {\n+\t\t\tif (obj.get<int16_t>().value_or(0) != value ||\n+\t\t\t obj.get<int16_t>(0) != value) {\n+\t\t\t\tstd::cerr\n+\t\t\t\t\t<< \"Object \" << name << \" failed to parse as \"\n+\t\t\t\t\t<< \"int16_t\" << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n+\t\tif (isInteger16 && !isSigned) {\n+\t\t\tif (obj.get<uint16_t>().value_or(0) != unsignedValue ||\n+\t\t\t obj.get<uint16_t>(0) != unsignedValue) {\n+\t\t\t\tstd::cerr\n+\t\t\t\t\t<< \"Object \" << name << \" failed to parse as \"\n+\t\t\t\t\t<< \"uint16_t\" << std::endl;\n+\t\t\t\treturn TestFail;\n+\t\t\t}\n+\t\t}\n+\n \t\tif (obj.get<int32_t>().value_or(0) != value ||\n \t\t obj.get<int32_t>(0) != value) {\n \t\t\tstd::cerr\n@@ -231,8 +272,8 @@ protected:\n \t\t}\n \n \t\tstd::vector<const char *> rootElemNames = {\n-\t\t\t\"string\", \"double\", \"int32_t\", \"uint32_t\", \"size\",\n-\t\t\t\"list\", \"dictionary\", \"level1\",\n+\t\t\t\"string\", \"double\", \"int16_t\", \"uint16_t\", \"int32_t\",\n+\t\t\t\"uint32_t\", \"size\", \"list\", \"dictionary\", \"level1\",\n \t\t};\n \n \t\tfor (const char *name : rootElemNames) {\n@@ -255,13 +296,31 @@ protected:\n \t\t\treturn TestFail;\n \t\t}\n \n+\t\t/* Test int16_t object */\n+\t\tauto &int16Obj = (*root)[\"int16_t\"];\n+\n+\t\tif (testObjectType(int16Obj, \"int16_t\", Type::Int16) != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\tif (testIntegerObject(int16Obj, \"int16_t\", Type::Int16, -1000) != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\t/* Test uint16_t object */\n+\t\tauto &uint16Obj = (*root)[\"uint16_t\"];\n+\n+\t\tif (testObjectType(uint16Obj, \"uint16_t\", Type::UInt16) != TestPass)\n+\t\t\treturn TestFail;\n+\n+\t\tif (testIntegerObject(uint16Obj, \"uint16_t\", Type::UInt16, 1000) != TestPass)\n+\t\t\treturn TestFail;\n+\n \t\t/* Test int32_t object */\n \t\tauto &int32Obj = (*root)[\"int32_t\"];\n \n \t\tif (testObjectType(int32Obj, \"int32_t\", Type::Int32) != TestPass)\n \t\t\treturn TestFail;\n \n-\t\tif (testIntegerObject(int32Obj, \"int32_t\", Type::Int32, -100) != TestPass)\n+\t\tif (testIntegerObject(int32Obj, \"int32_t\", Type::Int32, -100000) != TestPass)\n \t\t\treturn TestFail;\n \n \t\t/* Test uint32_t object */\n@@ -270,7 +329,7 @@ protected:\n \t\tif (testObjectType(uint32Obj, \"uint32_t\", Type::UInt32) != TestPass)\n \t\t\treturn TestFail;\n \n-\t\tif (testIntegerObject(uint32Obj, \"uint32_t\", Type::UInt32, 100) != TestPass)\n+\t\tif (testIntegerObject(uint32Obj, \"uint32_t\", Type::UInt32, 100000) != TestPass)\n \t\t\treturn TestFail;\n \n \t\t/* Test double value */\n", "prefixes": [ "libcamera-devel", "v4", "3/9" ] }