[{"id":24632,"web_url":"https://patchwork.libcamera.org/comment/24632/","msgid":"<20220818122101.GG2412817@pyrite.rasen.tech>","date":"2022-08-18T12:21:01","subject":"Re: [libcamera-devel] [PATCH v4 3/9] test: yaml-parser: Test\n\tout-of-range checks on integer parsing","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\nOn Tue, Aug 16, 2022 at 04:54:08AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> Add 16-bit integer parsing tests, including a test to verify the\n> out-of-range checks when parsing 32-bit integers as 16-bit values. That\n\nI can't find the test for the out-of-range checks...? Or is it not added\nbecause it fails?\n\n\nPaul\n\n> test currently fails.\n> \n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  test/yaml-parser.cpp | 77 ++++++++++++++++++++++++++++++++++++++------\n>  1 file changed, 68 insertions(+), 9 deletions(-)\n> \n> diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\n> index 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> -- \n> Regards,\n> \n> Laurent Pinchart\n>","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 C0F80C3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 12:21:10 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3EF0D61FC0;\n\tThu, 18 Aug 2022 14:21:10 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0EF4C61FA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 14:21:09 +0200 (CEST)","from pyrite.rasen.tech (KD027085204050.au-net.ne.jp [27.85.204.50])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 81B908B;\n\tThu, 18 Aug 2022 14:21:07 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660825270;\n\tbh=SBTJ2gYLVmmmFz7q/nnq2QnCkipvLXHVYylw3TJAkzo=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=kxf94THO5/hzAI58Jjh9jItf2M/OVqDGOF+L0l19WQpGyK/9rjvJe26rQtHOAr6sQ\n\t9iojYoMsbxstVt/tkOKOGtNzdStn/JGGR1JvQ93I2tijz/WaZEzVb6+HQxwcaZoIaf\n\tmvtGcn1T8YRvLhKzXqAFijX8TZHOf+KX2gba0tiLqlGcEoPW340EuM7EHuBhrUnE8T\n\tGk2GNGMtEfJQ8hKMX2264vvW0TftouiH/iP6spsjrb8767IKGfJm4YpLa2z8WFamXs\n\tYQrgRemfy3up9xjm21ln2jrW5H7R08gjRSNhgHJF1ZwC2egiZX5JF6Upzh3ipqmqxr\n\tMyTHzSH765U2w==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660825268;\n\tbh=SBTJ2gYLVmmmFz7q/nnq2QnCkipvLXHVYylw3TJAkzo=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=fGPYRrOCTffxE2OL6RBRfCb7rnz+uyABWSVToYOf/Qm8mdw5QfKdkSVAp6fg5EEao\n\tDZZbNwxlo84yJj94Th06QuWfUYq4R05lMG1sz1NvYkDp3uHENog5K4SCmr/ZkI+O9u\n\t3d2zapPTd27H6nCBEyV9+kYIhUFY3GTKw6s94lq8="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"fGPYRrOC\"; dkim-atps=neutral","Date":"Thu, 18 Aug 2022 21:21:01 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220818122101.GG2412817@pyrite.rasen.tech>","References":"<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>\n\t<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24636,"web_url":"https://patchwork.libcamera.org/comment/24636/","msgid":"<20220818125251.ruapl6fm4jhophao@uno.localdomain>","date":"2022-08-18T12:52:51","subject":"Re: [libcamera-devel] [PATCH v4 3/9] test: yaml-parser: Test\n\tout-of-range checks on integer parsing","submitter":{"id":3,"url":"https://patchwork.libcamera.org/api/people/3/","name":"Jacopo Mondi","email":"jacopo@jmondi.org"},"content":"Hi Laurent\n\nOn Tue, Aug 16, 2022 at 04:54:08AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> Add 16-bit integer parsing tests, including a test to verify the\n> out-of-range checks when parsing 32-bit integers as 16-bit values. That\n> test currently fails.\n>\n> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\nReviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n\nThanks\n  j\n\n> ---\n>  test/yaml-parser.cpp | 77 ++++++++++++++++++++++++++++++++++++++------\n>  1 file changed, 68 insertions(+), 9 deletions(-)\n>\n> diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\n> index 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> --\n> Regards,\n>\n> Laurent Pinchart\n>","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 F040BBE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 12:52:55 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 690AD61FBC;\n\tThu, 18 Aug 2022 14:52:55 +0200 (CEST)","from relay12.mail.gandi.net (relay12.mail.gandi.net\n\t[IPv6:2001:4b98:dc4:8::232])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 81C9B61FA7\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 14:52:53 +0200 (CEST)","(Authenticated sender: jacopo@jmondi.org)\n\tby mail.gandi.net (Postfix) with ESMTPSA id 020BD200008;\n\tThu, 18 Aug 2022 12:52:52 +0000 (UTC)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660827175;\n\tbh=R6BsvgTel+oMyPILxCo2aXRoHM7FAleyDOmsgr/fSHs=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=sTNgr6xClH37etsRc38DttIJolLa2ntkMDFy8lf9HXW5fbqZJz6wegzAqkB7JwAcd\n\twwpdKvqbQMNhGSMmD31T1jc0E8zvm40qvpIHGWjAYNfxj1asxFvOEMLoHcMQrbkECk\n\tDn4/sIA4GWswuiKxdC7yCw4kcXV5xkj7Y5q0GsjpdWJhEadve43WrCwp4hHbHZhJwD\n\tqKVBXeE7xKXWCfRM2P+Q+VBPtVCq4fnm6Gj9xuuLzxRp4tDWDHPmPmjaQuAg5+WpFN\n\t0Jy1v0LOFs1bSw848zNgwmYzkHmnABXQcXuiir4m9fcQCzmSKWg7y3pj4m9+qcCVl0\n\tOvTC2UonZbvnA==","Date":"Thu, 18 Aug 2022 14:52:51 +0200","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220818125251.ruapl6fm4jhophao@uno.localdomain>","References":"<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>\n\t<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>","Subject":"Re: [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":"Jacopo Mondi via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"Jacopo Mondi <jacopo@jmondi.org>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24655,"web_url":"https://patchwork.libcamera.org/comment/24655/","msgid":"<Yv5PFzKsmcFoNoss@pendragon.ideasonboard.com>","date":"2022-08-18T14:39:19","subject":"Re: [libcamera-devel] [PATCH v4 3/9] test: yaml-parser: Test\n\tout-of-range checks on integer parsing","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Paul,\n\nOn Thu, Aug 18, 2022 at 09:21:01PM +0900, paul.elder@ideasonboard.com wrote:\n> On Tue, Aug 16, 2022 at 04:54:08AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> > Add 16-bit integer parsing tests, including a test to verify the\n> > out-of-range checks when parsing 32-bit integers as 16-bit values. That\n> \n> I can't find the test for the out-of-range checks...? Or is it not added\n> because it fails?\n\nSee below...\n\n> > test currently fails.\n> > \n> > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > ---\n> >  test/yaml-parser.cpp | 77 ++++++++++++++++++++++++++++++++++++++------\n> >  1 file changed, 68 insertions(+), 9 deletions(-)\n> > \n> > diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\n> > index 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\nHere. This fails with the int32_t and uint32_t, obj.get<int16_t>()\nshould return nullopt in those cases, and it doesn't.\n\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 */","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 C8C77BE173\n\tfor <parsemail@patchwork.libcamera.org>;\n\tThu, 18 Aug 2022 14:39:25 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 76C9861FC3;\n\tThu, 18 Aug 2022 16:39:25 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id B0F2961FC2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tThu, 18 Aug 2022 16:39:22 +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 23DDC8B;\n\tThu, 18 Aug 2022 16:39:22 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660833565;\n\tbh=5XPxMbUjyIvUIR9CV0WMWlRwpKDeTYSRo8owcFTHn2w=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=vG1S577pm4OgfdP1G99wrf1DchxFI0uMYs3UbWqU665YJvFCBmHdwn8gZrqOqFxrO\n\thas1p6hSI3y/ORRTdXHkCulnjoLMLnLRIu3K3cc61cKbv9SQooEN42K3TwWl3E5D/M\n\tTG3z9fXfcPn8j342eFhpAPDz2kNrHRyPoOZPwpFJ0b4HfKdA8MZIo4JjkdD/snjAc/\n\tR0kg3UVtZzKgazzYNp5yWS0b2K1D5/7FnIRUhxb1n5vGd/+4tUBtlAPJU0AzKZkZRW\n\tRRFqWqKrw/Bk1Ln4qub97mlYr26Mbzn7vtgxLRwRuYPyQB1QL+9VXNXf3gcfboP932\n\t2buJYEeUOJcOw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660833562;\n\tbh=5XPxMbUjyIvUIR9CV0WMWlRwpKDeTYSRo8owcFTHn2w=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=Ykj5Tm6cMUSribq0HDDTtff0nTHpZ2DtPvOS9UcnpHo23vD+KeVbT9QH3cP8Z/pyC\n\t9jijEJr6mPSvMNATzBkEoV4QtCjB0e4LOp7ybsKApNhNMm0HorwR6Dv1ZR/B28igpJ\n\tdpgtNb6Sc15QJyEyzNTVVwz0vgr/yxigUDgdMYyA="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Ykj5Tm6c\"; dkim-atps=neutral","Date":"Thu, 18 Aug 2022 17:39:19 +0300","To":"paul.elder@ideasonboard.com","Message-ID":"<Yv5PFzKsmcFoNoss@pendragon.ideasonboard.com>","References":"<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>\n\t<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>\n\t<20220818122101.GG2412817@pyrite.rasen.tech>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220818122101.GG2412817@pyrite.rasen.tech>","Subject":"Re: [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>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":24709,"web_url":"https://patchwork.libcamera.org/comment/24709/","msgid":"<20220819073241.GA34241@pyrite.rasen.tech>","date":"2022-08-19T07:32:41","subject":"Re: [libcamera-devel] [PATCH v4 3/9] test: yaml-parser: Test\n\tout-of-range checks on integer parsing","submitter":{"id":97,"url":"https://patchwork.libcamera.org/api/people/97/","name":"Nicolas Dufresne via libcamera-devel","email":"libcamera-devel@lists.libcamera.org"},"content":"Hi Laurent,\n\nOn Thu, Aug 18, 2022 at 05:39:19PM +0300, Laurent Pinchart wrote:\n> Hi Paul,\n> \n> On Thu, Aug 18, 2022 at 09:21:01PM +0900, paul.elder@ideasonboard.com wrote:\n> > On Tue, Aug 16, 2022 at 04:54:08AM +0300, Laurent Pinchart via libcamera-devel wrote:\n> > > Add 16-bit integer parsing tests, including a test to verify the\n> > > out-of-range checks when parsing 32-bit integers as 16-bit values. That\n> > \n> > I can't find the test for the out-of-range checks...? Or is it not added\n> > because it fails?\n> \n> See below...\n> \n> > > test currently fails.\n> > > \n> > > Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> > > ---\n> > >  test/yaml-parser.cpp | 77 ++++++++++++++++++++++++++++++++++++++------\n> > >  1 file changed, 68 insertions(+), 9 deletions(-)\n> > > \n> > > diff --git a/test/yaml-parser.cpp b/test/yaml-parser.cpp\n> > > index 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> Here. This fails with the int32_t and uint32_t, obj.get<int16_t>()\n> should return nullopt in those cases, and it doesn't.\n\nAh, I see.\n\nReviewed-by: Paul Elder <paul.elder@ideasonboard.com>\n\n> \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 */","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 3182CC3272\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 19 Aug 2022 07:32:51 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id EFD4561FC0;\n\tFri, 19 Aug 2022 09:32:49 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0531761FA3\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 19 Aug 2022 09:32:49 +0200 (CEST)","from pyrite.rasen.tech (h175-177-042-159.catv02.itscom.jp\n\t[175.177.42.159])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 738113F1;\n\tFri, 19 Aug 2022 09:32:47 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1660894370;\n\tbh=oVEXBuDFOlp8PmyyaNgvPYYNsJ4t78PLTcuYTqpcKIE=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=Ac7ijL2+BIxOz8iWslDEm1PhZntAlgpTyMeKzi40SF0I6EHwqa/8nCK2WT3LeW+JM\n\tfPY25laVg6axYnHGOoZGzBX4Jc6Id8hgorOGpX3Su0G414Gk2OUKdRInPFwJy9Y+gq\n\tbjpp8s8dxelqDjYASM3TLwOhCTxvnWt1HdC54YgwFcSgA0Ef9NhmM7GZSKjoL8hq0N\n\tkXh7C4BpTJm4++jnQTvJB2KVzG/b4F5UnrqKfpL/uYa9PSBhmIZzsRSYOP8862XIRk\n\tLW8LTtz3Yig1wur9B6hxbIoDWJgmOEMsqFGNkRZlEn8VViWgGVSvDu9g3X5M/iCv5c\n\tXk99xM5XJHvew==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1660894368;\n\tbh=oVEXBuDFOlp8PmyyaNgvPYYNsJ4t78PLTcuYTqpcKIE=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=dO/iCvBbjkFulGpEq812lmrVgApZ80RtVeqbIIWNTU3SIMDmuTWOsX+yQWoW5IbRL\n\tdSHl7QdQomf5xfQPKN8lVsUag1o0dXTS4zIot4dAMDfz7jSJZ/Ns5EYrMN58CkdivO\n\tV8yJ4WJ1QBuH/AnGu9cqjcmKCR2Qn1kv7VhZIQsc="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"dO/iCvBb\"; dkim-atps=neutral","Date":"Fri, 19 Aug 2022 16:32:41 +0900","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20220819073241.GA34241@pyrite.rasen.tech>","References":"<20220816015414.7462-1-laurent.pinchart@ideasonboard.com>\n\t<20220816015414.7462-4-laurent.pinchart@ideasonboard.com>\n\t<20220818122101.GG2412817@pyrite.rasen.tech>\n\t<Yv5PFzKsmcFoNoss@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=us-ascii","Content-Disposition":"inline","In-Reply-To":"<Yv5PFzKsmcFoNoss@pendragon.ideasonboard.com>","Subject":"Re: [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":"Paul Elder via libcamera-devel <libcamera-devel@lists.libcamera.org>","Reply-To":"paul.elder@ideasonboard.com","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]