[{"id":1031,"web_url":"https://patchwork.libcamera.org/comment/1031/","msgid":"<20190310133039.GG4814@pendragon.ideasonboard.com>","date":"2019-03-10T13:30:39","subject":"Re: [libcamera-devel] [PATCH 3/5] test: camera: Add setting of\n\tformat test","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 Wed, Mar 06, 2019 at 03:47:53AM +0100, Niklas Söderlund wrote:\n> Try to set the default format, a modified valid format and an invalid\n> format.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  test/camera/format_set.cpp | 88 ++++++++++++++++++++++++++++++++++++++\n>  test/camera/meson.build    |  1 +\n>  2 files changed, 89 insertions(+)\n>  create mode 100644 test/camera/format_set.cpp\n> \n> diff --git a/test/camera/format_set.cpp b/test/camera/format_set.cpp\n> new file mode 100644\n> index 0000000000000000..948428ca6b00d2d0\n> --- /dev/null\n> +++ b/test/camera/format_set.cpp\n> @@ -0,0 +1,88 @@\n> +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> +/*\n> + * Copyright (C) 2019, Google Inc.\n> + *\n> + * libcamera Camera API tests\n> + */\n> +\n> +#include <iostream>\n> +\n> +#include \"camera_test.h\"\n> +\n> +using namespace std;\n> +\n> +namespace {\n> +\n> +class FormatSet : public CameraTest\n> +{\n> +protected:\n> +\tint run()\n> +\t{\n> +\t\tif (camera_->acquire()) {\n> +\t\t\tcout << \"Acquiring the camera failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tstd::set<Stream *> streams = { *camera_->streams().begin() };\n> +\t\tstd::map<Stream *, StreamConfiguration> conf =\n> +\t\t\tcamera_->streamConfiguration(streams);\n> +\t\tStreamConfiguration *sconf = &conf.begin()->second;\n> +\t\tif (conf.size() != 1) {\n> +\t\t\tcout << \"Reading default format failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n\nThis could use the validation function I mentioned in patch 2/5. Or you\ncould rely on the test from patch 2/5 performing this check, and skip it\nhere, up to you.\n\n> +\n> +\t\t/*\n> +\t\t * Test setting the default format works.\ns/Test/Test that/\n\n> +\t\t */\n\nThis holds on a single line.\n\n> +\t\tif (camera_->configureStreams(conf)) {\n> +\t\t\tcout << \"Setting valid format test failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Test setting the default format fails the camera is not\n\ns/Test/Test that/\ns/the camera/if the camera/\n\n> +\t\t * acquired.\n> +\t\t */\n> +\t\tif (camera_->release()) {\n> +\t\t\tcout << \"Releasing the camera failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (!camera_->configureStreams(conf)) {\n> +\t\t\tcout << \"Setting valid format on a camera not acquired failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (camera_->acquire()) {\n> +\t\t\tcout << \"Acquiring the camera failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n\nIf you moved this before the previous test you could drop the\nreleast/acquire. On the other hand there's value in testing\nrelease/acquire. If you want to keep them I'd mention that in the\ncomment above.\n\n> +\n> +\t\t/*\n> +\t\t * Test doubling the resolution works.\n\ns/Test/Test that/\n\nYou should expand this comment and mention that VIMC supports it,\notherwise it may not be clear why a double resolution is expected to be\nvalid.\n\n> +\t\t */\n> +\t\tsconf->width *= 2;\n> +\t\tsconf->height *= 2;\n> +\t\tif (camera_->configureStreams(conf)) {\n> +\t\t\tcout << \"Setting modified valid format test failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Test Setting an invalid format fails.\n> +\t\t */\n> +\t\tsconf->width = 0;\n> +\t\tsconf->height = 0;\n> +\t\tif (!camera_->configureStreams(conf)) {\n> +\t\t\tcout << \"Setting invalid format test failed\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +} /* namespace */\n> +\n> +TEST_REGISTER(FormatSet);\n> diff --git a/test/camera/meson.build b/test/camera/meson.build\n> index 4f2ed244a9240512..f5f27c4229ac307f 100644\n> --- a/test/camera/meson.build\n> +++ b/test/camera/meson.build\n> @@ -2,6 +2,7 @@\n>  # They are not alphabetically sorted.\n>  camera_tests = [\n>    [ 'format_default',        'format_default.cpp' ],\n> +  [ 'format_set',            'format_set.cpp' ],\n>  ]\n>  \n>  foreach t : camera_tests","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 7E968600CB\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 10 Mar 2019 14:30:45 +0100 (CET)","from pendragon.ideasonboard.com\n\t(dfj612yhrgyx302h3jwwy-3.rev.dnainternet.fi\n\t[IPv6:2001:14ba:21f5:5b00:ce28:277f:58d7:3ca4])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id EFD97255;\n\tSun, 10 Mar 2019 14:30:44 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1552224645;\n\tbh=/qhppdiUWDGBDE+rCmir4SFoKTql/rw/SUSPIh1xsAk=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=T17/GBDhAt2W7zhPlW3JwJeGHNv6klAnnw2jj2RUviABTpbYshbIr6kgpQbw3ct/K\n\tTAQqtfqO0iNv9GK3/Dej5nv/0DFX5+QL6qvxK94otm/qfA7SBaml7uY8PidXEdTnLc\n\tL513bATNevCxX/y0szjaR1C0Pe/eSlTwgPte72uI=","Date":"Sun, 10 Mar 2019 15:30:39 +0200","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":"<20190310133039.GG4814@pendragon.ideasonboard.com>","References":"<20190306024755.28726-1-niklas.soderlund@ragnatech.se>\n\t<20190306024755.28726-4-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":"<20190306024755.28726-4-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 3/5] test: camera: Add setting of\n\tformat test","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":"Sun, 10 Mar 2019 13:30:45 -0000"}},{"id":1036,"web_url":"https://patchwork.libcamera.org/comment/1036/","msgid":"<20190311012627.GF5281@bigcity.dyn.berto.se>","date":"2019-03-11T01:26:27","subject":"Re: [libcamera-devel] [PATCH 3/5] test: camera: Add setting of\n\tformat test","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your feedback.\n\nOn 2019-03-10 15:30:39 +0200, Laurent Pinchart wrote:\n> Hi Niklas,\n> \n> Thank you for the patch.\n> \n> On Wed, Mar 06, 2019 at 03:47:53AM +0100, Niklas Söderlund wrote:\n> > Try to set the default format, a modified valid format and an invalid\n> > format.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > ---\n> >  test/camera/format_set.cpp | 88 ++++++++++++++++++++++++++++++++++++++\n> >  test/camera/meson.build    |  1 +\n> >  2 files changed, 89 insertions(+)\n> >  create mode 100644 test/camera/format_set.cpp\n> > \n> > diff --git a/test/camera/format_set.cpp b/test/camera/format_set.cpp\n> > new file mode 100644\n> > index 0000000000000000..948428ca6b00d2d0\n> > --- /dev/null\n> > +++ b/test/camera/format_set.cpp\n> > @@ -0,0 +1,88 @@\n> > +/* SPDX-License-Identifier: GPL-2.0-or-later */\n> > +/*\n> > + * Copyright (C) 2019, Google Inc.\n> > + *\n> > + * libcamera Camera API tests\n> > + */\n> > +\n> > +#include <iostream>\n> > +\n> > +#include \"camera_test.h\"\n> > +\n> > +using namespace std;\n> > +\n> > +namespace {\n> > +\n> > +class FormatSet : public CameraTest\n> > +{\n> > +protected:\n> > +\tint run()\n> > +\t{\n> > +\t\tif (camera_->acquire()) {\n> > +\t\t\tcout << \"Acquiring the camera failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\tstd::set<Stream *> streams = { *camera_->streams().begin() };\n> > +\t\tstd::map<Stream *, StreamConfiguration> conf =\n> > +\t\t\tcamera_->streamConfiguration(streams);\n> > +\t\tStreamConfiguration *sconf = &conf.begin()->second;\n> > +\t\tif (conf.size() != 1) {\n> > +\t\t\tcout << \"Reading default format failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> \n> This could use the validation function I mentioned in patch 2/5. Or you\n> could rely on the test from patch 2/5 performing this check, and skip it\n> here, up to you.\n\nGreat idea, I think I will keep the new check here to catch potential \nerrors early.\n\n> \n> > +\n> > +\t\t/*\n> > +\t\t * Test setting the default format works.\n> s/Test/Test that/\n> \n> > +\t\t */\n> \n> This holds on a single line.\n\nThanks.\n\n> \n> > +\t\tif (camera_->configureStreams(conf)) {\n> > +\t\t\tcout << \"Setting valid format test failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Test setting the default format fails the camera is not\n> \n> s/Test/Test that/\n> s/the camera/if the camera/\n\nThanks.\n\n> \n> > +\t\t * acquired.\n> > +\t\t */\n> > +\t\tif (camera_->release()) {\n> > +\t\t\tcout << \"Releasing the camera failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\tif (!camera_->configureStreams(conf)) {\n> > +\t\t\tcout << \"Setting valid format on a camera not acquired failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\tif (camera_->acquire()) {\n> > +\t\t\tcout << \"Acquiring the camera failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> \n> If you moved this before the previous test you could drop the\n> releast/acquire. On the other hand there's value in testing\n> release/acquire. If you want to keep them I'd mention that in the\n> comment above.\n\nIt was my intention to also test the release/acquire, I will add it to \nthe comment.\n\n> \n> > +\n> > +\t\t/*\n> > +\t\t * Test doubling the resolution works.\n> \n> s/Test/Test that/\n> \n> You should expand this comment and mention that VIMC supports it,\n> otherwise it may not be clear why a double resolution is expected to be\n> valid.\n\nGood point.\n\n> \n> > +\t\t */\n> > +\t\tsconf->width *= 2;\n> > +\t\tsconf->height *= 2;\n> > +\t\tif (camera_->configureStreams(conf)) {\n> > +\t\t\tcout << \"Setting modified valid format test failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\t/*\n> > +\t\t * Test Setting an invalid format fails.\n> > +\t\t */\n> > +\t\tsconf->width = 0;\n> > +\t\tsconf->height = 0;\n> > +\t\tif (!camera_->configureStreams(conf)) {\n> > +\t\t\tcout << \"Setting invalid format test failed\" << endl;\n> > +\t\t\treturn TestFail;\n> > +\t\t}\n> > +\n> > +\t\treturn TestPass;\n> > +\t}\n> > +};\n> > +\n> > +} /* namespace */\n> > +\n> > +TEST_REGISTER(FormatSet);\n> > diff --git a/test/camera/meson.build b/test/camera/meson.build\n> > index 4f2ed244a9240512..f5f27c4229ac307f 100644\n> > --- a/test/camera/meson.build\n> > +++ b/test/camera/meson.build\n> > @@ -2,6 +2,7 @@\n> >  # They are not alphabetically sorted.\n> >  camera_tests = [\n> >    [ 'format_default',        'format_default.cpp' ],\n> > +  [ 'format_set',            'format_set.cpp' ],\n> >  ]\n> >  \n> >  foreach t : camera_tests\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from mail-lj1-x229.google.com (mail-lj1-x229.google.com\n\t[IPv6:2a00:1450:4864:20::229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 71B23600F9\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Mar 2019 02:26:29 +0100 (CET)","by mail-lj1-x229.google.com with SMTP id t13so2557923lji.2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSun, 10 Mar 2019 18:26:29 -0700 (PDT)","from localhost (89-233-230-99.cust.bredband2.com. [89.233.230.99])\n\tby smtp.gmail.com with ESMTPSA id\n\ta76sm862422lfe.60.2019.03.10.18.26.27\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tSun, 10 Mar 2019 18:26:27 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to\n\t:user-agent; bh=xYNo7wADVQZeZCyiEkNUuVYhFYjWk2ej+lIp4NvHPcA=;\n\tb=KQChLOruiHPC3iNVd3zyr2/tgE5/0PH7AjvalMK8xDbERLV2rETix7F1+KfSsDIXoF\n\tnYM72m6HmIZB1rCNYK+J4LOc7+eRxdQeSq/MRw0nWrZtc6eSioaxQYtOpJN5BcNP0alN\n\t/oDraWpLpKy/6OJ4dDvXpqggL95YbkVzRBZwtImZ0lXTiCQare4NcUalwUx2J/uLbmPP\n\t1pb/lnsp1MXLDY3/p/IIxtPb1nCItFYzfIJELwHm3myg1RI27Gl7AhLzxrRk3FMgMlaq\n\tkS9hSGLKx48Fp1d3IiKKiraAZ5Dxjtz3rGKol6BD4BfUzKrM3GQFjbQvzEQMKXhjsGXB\n\tjsFA==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to:user-agent;\n\tbh=xYNo7wADVQZeZCyiEkNUuVYhFYjWk2ej+lIp4NvHPcA=;\n\tb=fhp3aoFJrtvtwBOWh+umzjIARKY5Kk1Rc3acLQGU7j9sne6zh9t36z0rwzG0lsVL/J\n\tQbgpOBpqhz4YIA9gMZ8vk/SD3gOLOD+sIXYZNlYPEEOXCaFFQX3hqSn5y5utmV1XolXX\n\tVdyY1cHj16AxbZ7VJ0TANzbE5NAuzRh1IBKehOkOhd0eA6wCOIPwoqYrxY/ubYSh0hOl\n\tlezZZvLHkUVhystSu/CIB9Oeb0lPWHlo8ChqBJWCb9ptqGwVOoIyVi2wb882YK+qVzee\n\tAI6u2Ujk2xFQqClbzU2ZA8/NcmOyLZt1RqHceBcBzgBYGLAOB0lQoe54ZrFYZTRfitOG\n\tMRNA==","X-Gm-Message-State":"APjAAAWYXnA3bGZs16Ye6HgE8eQIUusNb9ikzGhcvDfoXmH1/PnZORsN\n\twApaRoYPDNjb8OGwTJkjIBRwbiDIiTQ=","X-Google-Smtp-Source":"APXvYqzcQzSdNVW4ran3yCTmSr2c2Gz1q7i7tQkzGi+JfTTHAOjs0G25s+MZNG+2FC8oPjZrU1iOlg==","X-Received":"by 2002:a2e:9b99:: with SMTP id\n\tz25mr14781266lji.106.1552267588655; \n\tSun, 10 Mar 2019 18:26:28 -0700 (PDT)","Date":"Mon, 11 Mar 2019 02:26:27 +0100","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Message-ID":"<20190311012627.GF5281@bigcity.dyn.berto.se>","References":"<20190306024755.28726-1-niklas.soderlund@ragnatech.se>\n\t<20190306024755.28726-4-niklas.soderlund@ragnatech.se>\n\t<20190310133039.GG4814@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=iso-8859-1","Content-Disposition":"inline","Content-Transfer-Encoding":"8bit","In-Reply-To":"<20190310133039.GG4814@pendragon.ideasonboard.com>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH 3/5] test: camera: Add setting of\n\tformat test","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, 11 Mar 2019 01:26:29 -0000"}}]