libcamera/test/list.cpp
Niklas Söderlund 20d15d9dc4 tests: add test to list all cameras in the system
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 <niklas.soderlund@ragnatech.se>
2018-12-31 00:58:32 +01:00

54 lines
668 B
C++

/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* Copyright (C) 2018, Google Inc.
*
* list.cpp - camera list tests
*/
#include <iostream>
#include <libcamera/camera_manager.h>
#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)