[{"id":1044,"web_url":"https://patchwork.libcamera.org/comment/1044/","msgid":"<20190311085424.GF4775@pendragon.ideasonboard.com>","date":"2019-03-11T08:54:24","subject":"Re: [libcamera-devel] [PATCH v2 2/4] test: camera: Add setting of\n\tconfiguration 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 Mon, Mar 11, 2019 at 03:22:30AM +0100, Niklas Söderlund wrote:\n> Try to set the default configuration, a modified valid configuration and\n> an invalid configuration.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> ---\n>  test/camera/configuration_set.cpp | 90 +++++++++++++++++++++++++++++++\n>  test/camera/meson.build           |  1 +\n>  2 files changed, 91 insertions(+)\n>  create mode 100644 test/camera/configuration_set.cpp\n> \n> diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp\n> new file mode 100644\n> index 0000000000000000..cf0b96b7d1d6583c\n> --- /dev/null\n> +++ b/test/camera/configuration_set.cpp\n> @@ -0,0 +1,90 @@\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 ConfigurationSet : public CameraTest\n> +{\n> +protected:\n> +\tint run()\n> +\t{\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> +\n> +\t\tif (!configurationValid(streams, conf)) {\n> +\t\t\tcout << \"Reading default configuration\" << endl;\n\n\"Failed to read ...\" ? Same for the other messages.\n\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (camera_->acquire()) {\n> +\t\t\tcout << \"Acquiring the camera\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/* Test that setting the default configuration works. */\n> +\t\tif (camera_->configureStreams(conf)) {\n> +\t\t\tcout << \"Setting default configuration\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Test that configuring the camera fails if it is not\n> +\t\t * acquired, this will also test release and reacquiring\n> +\t\t * of the camera.\n> +\t\t */\n> +\t\tif (camera_->release()) {\n> +\t\t\tcout << \"Releasing the camera\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (!camera_->configureStreams(conf)) {\n> +\t\t\tcout << \"Setting configuration on a camera not acquired\" << endl;\n\n\"... succeeded when it should have failed\" ? (Or maybe something\nshorter)\n\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\tif (camera_->acquire()) {\n> +\t\t\tcout << \"Acquiring the camera\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Test that modifying the default configuration works. Doubling\n> +\t\t * the default configuration of the VIMC camera is known to\n> +\t\t * work.\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 configuration\" << endl;\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\t/*\n> +\t\t * Test that setting an invalid configuration 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 configuration\" << endl;\n\n\"Invalid configuration incorrectly accepted\" ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> +\t\t\treturn TestFail;\n> +\t\t}\n> +\n> +\t\treturn TestPass;\n> +\t}\n> +};\n> +\n> +} /* namespace */\n> +\n> +TEST_REGISTER(ConfigurationSet);\n> diff --git a/test/camera/meson.build b/test/camera/meson.build\n> index 186ba211b9fde026..ed4837190ff6c52c 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>    [ 'configuration_default',  'configuration_default.cpp' ],\n> +  [ 'configuration_set',      'configuration_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 0C656600FC\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Mar 2019 09:54:31 +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 77946255;\n\tMon, 11 Mar 2019 09:54:30 +0100 (CET)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1552294470;\n\tbh=+xqqQL0+UIseR2MfD6YUr3L2e7KzKizfZpzWQdKx9pU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=I9BEqqknGMyilYXvOJcp9BBIpf8DaxnLR8Mxo9I1DcZpNdyYRFibDlgamZtKGi4v/\n\teW8hHWLKG6gEoe8+CHnPJX9sM5Gkg7CfrK+xoZjKUd2C/t1qYMMBNAORwVdTsQaBS3\n\tuo/JWL4TMKzdbzZiPb8g5H3jCr+T1V8UD5JjtHQE=","Date":"Mon, 11 Mar 2019 10:54:24 +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":"<20190311085424.GF4775@pendragon.ideasonboard.com>","References":"<20190311022232.4759-1-niklas.soderlund@ragnatech.se>\n\t<20190311022232.4759-3-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":"<20190311022232.4759-3-niklas.soderlund@ragnatech.se>","User-Agent":"Mutt/1.10.1 (2018-07-13)","Subject":"Re: [libcamera-devel] [PATCH v2 2/4] test: camera: Add setting of\n\tconfiguration 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 08:54:31 -0000"}}]