From f1d94d903966ed2b55d360c006d718d41ee48edd Mon Sep 17 00:00:00 2001 From: Jacopo Mondi Date: Fri, 29 Dec 2023 11:06:57 +0100 Subject: apps: lc-compliance: Add configuration test Add a test suite to test the Camera configuration operations. Add a single simple test that tests an invalid configuration to start with. Signed-off-by: Jacopo Mondi --- src/apps/lc-compliance/meson.build | 1 + src/apps/lc-compliance/tests/configure_test.cpp | 52 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 src/apps/lc-compliance/tests/configure_test.cpp (limited to 'src') diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build index c927dd12..c53b2603 100644 --- a/src/apps/lc-compliance/meson.build +++ b/src/apps/lc-compliance/meson.build @@ -15,6 +15,7 @@ lc_compliance_sources = files([ 'helpers/capture.cpp', 'main.cpp', 'tests/capture_test.cpp', + 'tests/configure_test.cpp', 'tests/controls_test.cpp' ]) diff --git a/src/apps/lc-compliance/tests/configure_test.cpp b/src/apps/lc-compliance/tests/configure_test.cpp new file mode 100644 index 00000000..2ac605f7 --- /dev/null +++ b/src/apps/lc-compliance/tests/configure_test.cpp @@ -0,0 +1,52 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* + * Copyright (C) 2023, Ideas On Board Oy + * + * configure_test.cpp - Camera configuration tests + */ + +#include + +#include "environment.h" + +using namespace libcamera; + +class ConfigureTest : public testing::Test +{ +protected: + void SetUp() override; + void TearDown() override; + + std::shared_ptr camera_; +}; + +void ConfigureTest::SetUp() +{ + Environment *env = Environment::get(); + + camera_ = env->cm()->get(env->cameraId()); + + ASSERT_EQ(camera_->acquire(), 0); +} + +void ConfigureTest::TearDown() +{ + if (!camera_) + return; + + camera_->release(); + camera_.reset(); +} + +/* Test that an empty config doesn't get accepted by the camera. */ +TEST_F(ConfigureTest, EmptyConfig) +{ + auto emptyConfig = camera_->generateConfiguration({}); + ASSERT_EQ(emptyConfig->size(), 0); + + CameraConfiguration::Status status = emptyConfig->validate(); + ASSERT_EQ(status, CameraConfiguration::Invalid); + + int ret = camera_->configure(emptyConfig.get()); + ASSERT_EQ(ret, -EINVAL); +} -- cgit v1.2.1