Patch Detail
Show a patch.
GET /api/1.1/patches/711/?format=api
{ "id": 711, "url": "https://patchwork.libcamera.org/api/1.1/patches/711/?format=api", "web_url": "https://patchwork.libcamera.org/patch/711/", "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": "<20190311022232.4759-2-niklas.soderlund@ragnatech.se>", "date": "2019-03-11T02:22:29", "name": "[libcamera-devel,v2,1/4] test: camera: Add read default configuration test", "commit_ref": null, "pull_url": null, "state": "superseded", "archived": false, "hash": "efed1885030fd2e6f334796ed49c614e1150f987", "submitter": { "id": 5, "url": "https://patchwork.libcamera.org/api/1.1/people/5/?format=api", "name": "Niklas Söderlund", "email": "niklas.soderlund@ragnatech.se" }, "delegate": null, "mbox": "https://patchwork.libcamera.org/patch/711/mbox/", "series": [ { "id": 204, "url": "https://patchwork.libcamera.org/api/1.1/series/204/?format=api", "web_url": "https://patchwork.libcamera.org/project/libcamera/list/?series=204", "date": "2019-03-11T02:22:28", "name": "test: camera: Add basic tests for the camera", "version": 2, "mbox": "https://patchwork.libcamera.org/series/204/mbox/" } ], "comments": "https://patchwork.libcamera.org/api/patches/711/comments/", "check": "pending", "checks": "https://patchwork.libcamera.org/api/patches/711/checks/", "tags": {}, "headers": { "Return-Path": "<niklas.soderlund@ragnatech.se>", "Received": [ "from vsp-unauthed02.binero.net (vsp-unauthed02.binero.net\n\t[195.74.38.227])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 0A1CA610BF\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon, 11 Mar 2019 03:23:06 +0100 (CET)", "from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid 99274ce3-43a4-11e9-985a-005056917f90;\n\tMon, 11 Mar 2019 03:23:03 +0100 (CET)" ], "X-Halon-ID": "99274ce3-43a4-11e9-985a-005056917f90", "Authorized-sender": "niklas@soderlund.pp.se", "From": "=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>", "To": "libcamera-devel@lists.libcamera.org", "Date": "Mon, 11 Mar 2019 03:22:29 +0100", "Message-Id": "<20190311022232.4759-2-niklas.soderlund@ragnatech.se>", "X-Mailer": "git-send-email 2.21.0", "In-Reply-To": "<20190311022232.4759-1-niklas.soderlund@ragnatech.se>", "References": "<20190311022232.4759-1-niklas.soderlund@ragnatech.se>", "MIME-Version": "1.0", "Content-Type": "text/plain; charset=UTF-8", "Content-Transfer-Encoding": "8bit", "Subject": "[libcamera-devel] [PATCH v2 1/4] test: camera: Add read default\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 02:23:07 -0000" }, "content": "Add a test to verify reading the default configuration from a camera\nworks.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/camera/camera_test.cpp | 74 +++++++++++++++++++++++++++\n test/camera/camera_test.h | 35 +++++++++++++\n test/camera/configuration_default.cpp | 68 ++++++++++++++++++++++++\n test/camera/meson.build | 12 +++++\n test/meson.build | 1 +\n 5 files changed, 190 insertions(+)\n create mode 100644 test/camera/camera_test.cpp\n create mode 100644 test/camera/camera_test.h\n create mode 100644 test/camera/configuration_default.cpp\n create mode 100644 test/camera/meson.build", "diff": "diff --git a/test/camera/camera_test.cpp b/test/camera/camera_test.cpp\nnew file mode 100644\nindex 0000000000000000..4ba6813c40ece44b\n--- /dev/null\n+++ b/test/camera/camera_test.cpp\n@@ -0,0 +1,74 @@\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 libcamera;\n+using namespace std;\n+\n+int CameraTest::init()\n+{\n+\tcm_ = CameraManager::instance();\n+\n+\tif (cm_->start()) {\n+\t\tcout << \"Failed to start camera manager\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\tcamera_ = cm_->get(\"VIMC Sensor B\");\n+\tif (!camera_) {\n+\t\tcout << \"Can not find VIMC camera\" << endl;\n+\t\treturn TestSkip;\n+\t}\n+\n+\t/* Sanity check that the camera has streams. */\n+\tif (camera_->streams().empty()) {\n+\t\tcout << \"Camera has no stream\" << endl;\n+\t\treturn TestFail;\n+\t}\n+\n+\treturn TestPass;\n+}\n+\n+void CameraTest::cleanup()\n+{\n+\tif (camera_) {\n+\t\tcamera_->release();\n+\t\tcamera_.reset();\n+\t}\n+\n+\tcm_->stop();\n+};\n+\n+bool CameraTest::configurationValid(const std::set<Stream *> &streams,\n+\t\t\t\t const std::map<Stream *, StreamConfiguration> &conf) const\n+{\n+\t/* Test numbers of streams matches that of configurations. */\n+\tif (streams.size() != conf.size())\n+\t\treturn false;\n+\n+\t/*\n+\t * Test stream can be found in configuration and that the\n+\t * configuration is valid.\n+\t */\n+\tfor (Stream *stream : streams) {\n+\t\tstd::map<Stream *, StreamConfiguration>::const_iterator itr =\n+\t\t\tconf.find(stream);\n+\n+\t\tif (itr == conf.end())\n+\t\t\treturn false;\n+\n+\t\tconst StreamConfiguration *sconf = &itr->second;\n+\t\tif (sconf->width == 0 || sconf->height == 0 ||\n+\t\t sconf->pixelFormat == 0 || sconf->bufferCount == 0)\n+\t\t\treturn false;\n+\t}\n+\n+\treturn true;\n+}\ndiff --git a/test/camera/camera_test.h b/test/camera/camera_test.h\nnew file mode 100644\nindex 0000000000000000..48fb47a23fe8f49c\n--- /dev/null\n+++ b/test/camera/camera_test.h\n@@ -0,0 +1,35 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2019, Google Inc.\n+ *\n+ * camera_test.h - libcamera camera test base class\n+ */\n+#ifndef __LIBCAMERA_CAMERA_TEST_H__\n+#define __LIBCAMERA_CAMERA_TEST_H__\n+\n+#include <libcamera/libcamera.h>\n+\n+#include \"test.h\"\n+\n+using namespace libcamera;\n+\n+class CameraTest : public Test\n+{\n+public:\n+\tCameraTest()\n+\t\t: cm_(nullptr) {}\n+\n+protected:\n+\tint init();\n+\tvoid cleanup();\n+\n+\tbool configurationValid(const std::set<Stream *> &streams,\n+\t\t\t\tconst std::map<Stream *, StreamConfiguration> &conf) const;\n+\n+\tstd::shared_ptr<Camera> camera_;\n+\n+private:\n+\tCameraManager *cm_;\n+};\n+\n+#endif /* __LIBCAMERA_CAMERA_TEST_H__ */\ndiff --git a/test/camera/configuration_default.cpp b/test/camera/configuration_default.cpp\nnew file mode 100644\nindex 0000000000000000..b488b977c890a6da\n--- /dev/null\n+++ b/test/camera/configuration_default.cpp\n@@ -0,0 +1,68 @@\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 ConfigurationDefault : public CameraTest\n+{\n+protected:\n+\tint run()\n+\t{\n+\t\tstd::map<Stream *, StreamConfiguration> conf;\n+\n+\t\t/*\n+\t\t * Test that asking for default configuration for a valid\n+\t\t * array of streams returns something valid.\n+\t\t */\n+\t\tstd::set<Stream *> streams = { *camera_->streams().begin() };\n+\t\tconf = camera_->streamConfiguration(streams);\n+\t\tif (conf.empty()) {\n+\t\t\tcout << \"Retrieving configuration for valid streams\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\tif (!configurationValid(streams, conf)) {\n+\t\t\tcout << \"Default configuration invalid\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test that asking for configuration for an empty array of\n+\t\t * streams returns an empty list of configurations.\n+\t\t */\n+\t\tstd::set<Stream *> streams_empty = {};\n+\t\tconf = camera_->streamConfiguration(streams_empty);\n+\t\tif (!conf.empty()) {\n+\t\t\tcout << \"Retrieving configuration for empty streams\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\t/*\n+\t\t * Test that asking for configuration for an array of bad streams\n+\t\t * returns an empty list of configurations.\n+\t\t */\n+\t\tStream *stream_bad = reinterpret_cast<Stream *>(0xdeadbeef);\n+\t\tstd::set<Stream *> streams_bad = { stream_bad };\n+\t\tconf = camera_->streamConfiguration(streams_bad);\n+\t\tif (!conf.empty()) {\n+\t\t\tcout << \"Retrieving configuration for bad streams\" << endl;\n+\t\t\treturn TestFail;\n+\t\t}\n+\n+\t\treturn TestPass;\n+\t}\n+};\n+\n+} /* namespace */\n+\n+TEST_REGISTER(ConfigurationDefault);\ndiff --git a/test/camera/meson.build b/test/camera/meson.build\nnew file mode 100644\nindex 0000000000000000..186ba211b9fde026\n--- /dev/null\n+++ b/test/camera/meson.build\n@@ -0,0 +1,12 @@\n+# Tests are listed in order of complexity.\n+# They are not alphabetically sorted.\n+camera_tests = [\n+ [ 'configuration_default', 'configuration_default.cpp' ],\n+]\n+\n+foreach t : camera_tests\n+ exe = executable(t[0], [t[1], 'camera_test.cpp'],\n+ link_with : test_libraries,\n+ include_directories : test_includes_internal)\n+ test(t[0], exe, suite: 'camera', is_parallel: false)\n+endforeach\ndiff --git a/test/meson.build b/test/meson.build\nindex 5fb16fa6afb62f8d..71a96921697c0e9e 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -1,5 +1,6 @@\n subdir('libtest')\n \n+subdir('camera')\n subdir('media_device')\n subdir('pipeline')\n subdir('v4l2_device')\n", "prefixes": [ "libcamera-devel", "v2", "1/4" ] }