summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacopo Mondi <jacopo.mondi@ideasonboard.com>2023-12-29 11:06:57 +0100
committerJacopo Mondi <jacopo.mondi@ideasonboard.com>2023-12-29 11:33:31 +0100
commitf1d94d903966ed2b55d360c006d718d41ee48edd (patch)
tree0b5c5e98c14a2167fada667ea5a1b3585c9e5e02 /src
parente9d1f0e80075b830d180f2690ad758278778560b (diff)
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 <jacopo.mondi@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/apps/lc-compliance/meson.build1
-rw-r--r--src/apps/lc-compliance/tests/configure_test.cpp52
2 files changed, 53 insertions, 0 deletions
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 <gtest/gtest.h>
+
+#include "environment.h"
+
+using namespace libcamera;
+
+class ConfigureTest : public testing::Test
+{
+protected:
+ void SetUp() override;
+ void TearDown() override;
+
+ std::shared_ptr<Camera> 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);
+}