From patchwork Sat Dec 22 23:00:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 88 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F94060B0C for ; Sun, 23 Dec 2018 00:02:39 +0100 (CET) X-Halon-ID: 9d335f09-063d-11e9-9adf-005056917a89 Authorized-sender: niklas@soderlund.pp.se Received: from wyvern.dyn.berto.se (unknown [217.31.177.236]) by bin-vsp-out-01.atm.binero.net (Halon) with ESMTPA id 9d335f09-063d-11e9-9adf-005056917a89; Sun, 23 Dec 2018 00:02:12 +0100 (CET) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Sun, 23 Dec 2018 00:00:41 +0100 Message-Id: <20181222230041.29999-13-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20181222230041.29999-1-niklas.soderlund@ragnatech.se> References: <20181222230041.29999-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 12/12] tests: add test to list all cameras in the system X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 22 Dec 2018 23:02:39 -0000 Add simple test which lists all cameras detected in the system. The test fails if no camera can be found. Signed-off-by: Niklas Söderlund --- test/list.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++++ test/meson.build | 5 +++++ 2 files changed, 59 insertions(+) create mode 100644 test/list.cpp diff --git a/test/list.cpp b/test/list.cpp new file mode 100644 index 0000000000000000..6483ffb4f13a8cb6 --- /dev/null +++ b/test/list.cpp @@ -0,0 +1,54 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2018, Google Inc. + * + * list.cpp - camera list tests + */ + +#include + +#include + +#include "test.h" + +using namespace std; +using namespace libcamera; + +class ListTest : public Test +{ +protected: + int init() + { + cm = new CameraManager(); + if (!cm) + return -ENOMEM; + + cm->start(); + + return 0; + } + + int run() + { + unsigned int count = 0; + + for (auto name : cm->list()) { + cout << "- " << name << endl; + count++; + } + + return count ? 0 : -ENODEV; + } + + void cleanup() + { + cm->stop(); + + delete cm; + } + +private: + CameraManager *cm; +}; + +TEST_REGISTER(ListTest) diff --git a/test/meson.build b/test/meson.build index da0aea9678d127ce..a74629f89197ecea 100644 --- a/test/meson.build +++ b/test/meson.build @@ -8,4 +8,9 @@ test_init = executable('test_init', 'init.cpp', link_with : libcamera, include_directories : libcamera_includes) +list = executable('list', 'list.cpp', + link_with : [libcamera, libtest], + include_directories : libcamera_includes) + test('Initialisation test', test_init) +test('List Camera API tests', list)