{"id":107,"url":"https://patchwork.libcamera.org/api/1.1/patches/107/?format=json","web_url":"https://patchwork.libcamera.org/patch/107/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20181229032855.26249-13-niklas.soderlund@ragnatech.se>","date":"2018-12-29T03:28:55","name":"[libcamera-devel,v2,12/12] tests: add test to list all cameras in the system","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"3b75fc7015fcc0b7b20c373d5d99cec9632a81e5","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/107/mbox/","series":[{"id":41,"url":"https://patchwork.libcamera.org/api/1.1/series/41/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=41","date":"2018-12-29T03:28:43","name":"Add basic camera enumeration","version":2,"mbox":"https://patchwork.libcamera.org/series/41/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/107/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/107/checks/","tags":{},"headers":{"Return-Path":"<niklas.soderlund@ragnatech.se>","Received":["from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D2EF860B41\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tSat, 29 Dec 2018 04:29:59 +0100 (CET)","from bismarck.berto.se (unknown [89.233.230.99])\n\tby bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid fe0d7c96-0b19-11e9-911a-0050569116f7;\n\tSat, 29 Dec 2018 04:29:47 +0100 (CET)"],"X-Halon-ID":"fe0d7c96-0b19-11e9-911a-0050569116f7","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":"Sat, 29 Dec 2018 04:28:55 +0100","Message-Id":"<20181229032855.26249-13-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.20.1","In-Reply-To":"<20181229032855.26249-1-niklas.soderlund@ragnatech.se>","References":"<20181229032855.26249-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 12/12] tests: add test to list all\n\tcameras in the system","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":"Sat, 29 Dec 2018 03:30:00 -0000"},"content":"Add simple test which lists all cameras detected in the system. The test\nfails if no camera can be found.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n---\n test/list.cpp    | 54 ++++++++++++++++++++++++++++++++++++++++++++++++\n test/meson.build |  5 +++++\n 2 files changed, 59 insertions(+)\n create mode 100644 test/list.cpp","diff":"diff --git a/test/list.cpp b/test/list.cpp\nnew file mode 100644\nindex 0000000000000000..39b8a41d1fef892c\n--- /dev/null\n+++ b/test/list.cpp\n@@ -0,0 +1,54 @@\n+/* SPDX-License-Identifier: GPL-2.0-or-later */\n+/*\n+ * Copyright (C) 2018, Google Inc.\n+ *\n+ * list.cpp - camera list tests\n+ */\n+\n+#include <iostream>\n+\n+#include <libcamera/camera_manager.h>\n+\n+#include \"test.h\"\n+\n+using namespace std;\n+using namespace libcamera;\n+\n+class ListTest : public Test\n+{\n+protected:\n+\tint init()\n+\t{\n+\t\tcm = new CameraManager();\n+\t\tif (!cm)\n+\t\t\treturn -ENOMEM;\n+\n+\t\tcm->start();\n+\n+\t\treturn 0;\n+\t}\n+\n+\tint run()\n+\t{\n+\t\tunsigned int count = 0;\n+\n+\t\tfor (auto name : cm->list()) {\n+\t\t\tcout << \"- \" << name << endl;\n+\t\t\tcount++;\n+\t\t}\n+\n+\t\treturn count ? 0 : -ENODEV;\n+\t}\n+\n+\tvoid cleanup()\n+\t{\n+\t\tcm->stop();\n+\n+\t\tdelete cm;\n+\t}\n+\n+private:\n+\tCameraManager *cm;\n+};\n+\n+TEST_REGISTER(ListTest)\ndiff --git a/test/meson.build b/test/meson.build\nindex da0aea9678d127ce..a74629f89197ecea 100644\n--- a/test/meson.build\n+++ b/test/meson.build\n@@ -8,4 +8,9 @@ test_init = executable('test_init', 'init.cpp',\n                        link_with : libcamera,\n                        include_directories : libcamera_includes)\n \n+list = executable('list', 'list.cpp',\n+                    link_with : [libcamera, libtest],\n+                    include_directories : libcamera_includes)\n+\n test('Initialisation test', test_init)\n+test('List Camera API tests', list)\n","prefixes":["libcamera-devel","v2","12/12"]}