[{"id":1809,"web_url":"https://patchwork.libcamera.org/comment/1809/","msgid":"<20190610065633.GC4806@pendragon.ideasonboard.com>","date":"2019-06-10T06:56:33","subject":"Re: [libcamera-devel] [PATCH 13/17] test: stream: Add test for\n\tStreamFormat","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Mon, May 27, 2019 at 02:15:39AM +0200, Niklas Söderlund wrote:\n> Test that both discrete and range based stream format descriptions\n> result in good discrete frame sizes. The range based stream formats\n> needs to be fitted with a table of resolutions inside libcamera so if\n> that table is update this test might need to be updated.\n\ns/is update/is updated/\n\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  test/meson.build               |   1 +\n>  test/stream/meson.build        |  11 ++++\n>  test/stream/stream_formats.cpp | 102 +++++++++++++++++++++++++++++++++\n>  3 files changed, 114 insertions(+)\n>  create mode 100644 test/stream/meson.build\n>  create mode 100644 test/stream/stream_formats.cpp\n> \n> diff --git a/test/meson.build b/test/meson.build\n> index 609aeab80e7d0f4f..5370f3028a4fe39d 100644\n> --- a/test/meson.build\n> +++ b/test/meson.build\n> @@ -4,6 +4,7 @@ subdir('camera')\n>  subdir('ipa')\n>  subdir('media_device')\n>  subdir('pipeline')\n> +subdir('stream')\n>  subdir('v4l2_device')\n>  subdir('v4l2_subdevice')\n>  \n> diff --git a/test/stream/meson.build b/test/stream/meson.build\n> new file mode 100644\n> index 0000000000000000..5b42fe32b341970f\n> --- /dev/null\n> +++ b/test/stream/meson.build\n> @@ -0,0 +1,11 @@\n> +stream_tests = [\n> +  [ 'stream_formats', 'stream_formats.cpp' ],\n\nFour spaces for indentation please.\n\n> +]\n> +\n> +foreach t : stream_tests\n> +  exe = executable(t[0], t[1],\n> +                   dependencies : libcamera_dep,\n> +                   link_with : test_libraries,\n> +                   include_directories : test_includes_internal)\n> +  test(t[0], exe, suite: 'stream', is_parallel: false)\n> +endforeach\n> diff --git a/test/stream/stream_formats.cpp b/test/stream/stream_formats.cpp\n> new file mode 100644\n> index 0000000000000000..42a596cc69893b20\n> --- /dev/null\n> +++ b/test/stream/stream_formats.cpp\n> @@ -0,0 +1,102 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * stream_formats.cpp - StreamFormats test\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include <libcamera/geometry.h>\n> +#include <libcamera/stream.h>\n> +\n> +#include \"test.h\"\n> +\n> +using namespace std;\n> +using namespace libcamera;\n> +\n> +class StreamFormatsTest : public Test\n> +{\n> +protected:\n> +\tint testSizes(std::string name, std::vector<Size> test, std::vector<Size> valid)\n> +\t{\n> +\t\tbool pass = false;\n> +\n> +\t\tfor (Size &size : test) {\n> +\t\t\tpass = false;\n> +\n> +\t\t\tfor (Size &validSize : valid) {\n> +\t\t\t\tif (size == validSize) {\n> +\t\t\t\t\tpass = true;\n> +\t\t\t\t\tbreak;\n> +\t\t\t\t}\n> +\t\t\t}\n> +\n> +\t\t\tif (!pass)\n> +\t\t\t\tbreak;\n> +\t\t}\n> +\n> +\t\tif (!pass) {\n> +\t\t\tcout << \"Failed \" << name << endl;\n> +\t\t\tcout << \"Sizes to test:\" << endl;\n> +\t\t\tfor (Size &size : test)\n> +\t\t\t\tcout << size.toString() << endl;\n> +\t\t\tcout << \"Valid sizes:\" << endl;\n> +\t\t\tfor (Size &size : valid)\n> +\t\t\t\tcout << size.toString() << endl;\n> +\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +\n> +\tint run()\n> +\t{\n> +\t\t/* Test discrete sizes */\n> +\t\tStreamFormats discrete({\n> +\t\t\t{ 1, { SizeRange(100, 100), SizeRange(200, 200) } },\n> +\t\t\t{ 2, { SizeRange(300, 300), SizeRange(400, 400) } },\n> +\t\t});\n> +\n> +\t\tif (testSizes(\"discrete 1\", discrete.sizes(1),\n> +\t\t\t      { Size(100, 100), Size(200, 200) }))\n> +\t\t\treturn TestFail;\n> +\t\tif (testSizes(\"discrete 2\", discrete.sizes(2),\n> +\t\t\t      { Size(300, 300), Size(400, 400) }))\n> +\t\t\treturn TestFail;\n> +\n> +\t\t/* Test range sizes */\n> +\t\tStreamFormats range({\n> +\t\t\t{ 1, { SizeRange(640, 480, 640, 480) } },\n> +\t\t\t{ 2, { SizeRange(640, 480, 800, 600, 8, 8) } },\n> +\t\t\t{ 3, { SizeRange(640, 480, 800, 600, 16, 16) } },\n> +\t\t\t{ 4, { SizeRange(128, 128, 4096, 4096, 128, 128) } },\n> +\t\t});\n> +\n> +\t\tif (testSizes(\"range 1\", range.sizes(1), { Size(640, 480) }))\n> +\t\t\treturn TestFail;\n> +\n> +\t\tif (testSizes(\"range 2\", range.sizes(2), {\n> +\t\t\t      Size(640, 480), Size(720, 480),\n> +\t\t\t      Size(720, 576), Size(768, 480),\n> +\t\t\t      Size(800, 600) }))\n> +\t\t\treturn TestFail;\n> +\n> +\n\nExtra blank line.\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\tif (testSizes(\"range 3\", range.sizes(3), {\n> +\t\t\t      Size(640, 480), Size(720, 480),\n> +\t\t\t      Size(720, 576), Size(768, 480) }))\n> +\t\t\treturn TestFail;\n> +\n> +\t\tif (testSizes(\"range 4\", range.sizes(4), {\n> +\t\t\t      Size(1024, 768), Size(1280, 1024),\n> +\t\t\t      Size(2048, 1152), Size(2048, 1536),\n> +\t\t\t      Size(2560, 2048), Size(3200, 2048), }))\n> +\t\t\treturn TestFail;\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +TEST_REGISTER(StreamFormatsTest)","headers":{"Return-Path":"<laurent.pinchart@ideasonboard.com>","Received":["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 7619963766\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 10 Jun 2019 08:56:51 +0200 (CEST)","from pendragon.ideasonboard.com (85-76-134-17-nat.elisa-mobile.fi\n\t[85.76.134.17])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 4E199569;\n\tMon, 10 Jun 2019 08:56:50 +0200 (CEST)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1560149811;\n\tbh=b36Bd3oXGhmUAgnYTkHHQdqcmudBJiimXXbfWMolqhc=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=WYPVOKwbZuHFZESafFihQ3XJK5Ny0MZJ3z+IdEg1M5rC1tc8Q2HoqrYX2yoURpjlQ\n\t27WoeaKj6LBF02K8Qpmy4tHMq+8T8u8CvBfEeKHm0NI0LcZdPq4xKyAybp8YPsZp8F\n\t7BjUIPpo1lrm1m+JSo9X02UJ6/TV3BTxrf75z0XE=","Date":"Mon, 10 Jun 2019 09:56:33 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190610065633.GC4806@pendragon.ideasonboard.com>","References":"<20190527001543.13593-1-niklas.soderlund@ragnatech.se>\n\t<20190527001543.13593-14-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190527001543.13593-14-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 13/17] test: stream: Add test for\n\tStreamFormat","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.23","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>","X-List-Received-Date":"Mon, 10 Jun 2019 06:56:51 -0000"}}]