From 20d15d9dc47fcfbf1f02689cc4c882115abe507f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niklas=20S=C3=B6derlund?= Date: Thu, 20 Dec 2018 16:41:50 +0100 Subject: tests: add test to list all cameras in the system MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 test/list.cpp (limited to 'test/list.cpp') diff --git a/test/list.cpp b/test/list.cpp new file mode 100644 index 00000000..39b8a41d --- /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) -- cgit v1.2.1