[libcamera-devel,v10,19/19] lc-compliance: Add test to ensure MinimumRequests is valid
diff mbox series

Message ID 20221228223003.2265712-20-paul.elder@ideasonboard.com
State New
Headers show
Series
  • lc-compliance: Add test to queue more requests than hardware depth
Related show

Commit Message

Paul Elder Dec. 28, 2022, 10:30 p.m. UTC
From: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>

Add a test in lc-compliance to check that the MinimumRequests property
is set and valid, that is, greater than 0.

Signed-off-by: NĂ­colas F. R. A. Prado <nfraprado@collabora.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
Signed-off-by: Paul Elder <paul.elder@ideasonboard.com>
Reviewed-by: Umang Jain <umang.jain@ideasonboard.com>

---
No change in v10

Changes in v9:
- rebased

Changes in v8:
- Moved RequiredProperties test to property_test.cpp
- Moved CameraTests to new test_base.{cpp,h} files

Changes in v7:
- New
---
 src/apps/lc-compliance/meson.build       |  1 +
 src/apps/lc-compliance/property_test.cpp | 24 ++++++++++++++++++++++++
 src/apps/lc-compliance/test_base.cpp     | 10 ++++++++++
 src/apps/lc-compliance/test_base.h       |  7 +++++++
 4 files changed, 42 insertions(+)
 create mode 100644 src/apps/lc-compliance/property_test.cpp

Patch
diff mbox series

diff --git a/src/apps/lc-compliance/meson.build b/src/apps/lc-compliance/meson.build
index fae290bb..a10a3cc2 100644
--- a/src/apps/lc-compliance/meson.build
+++ b/src/apps/lc-compliance/meson.build
@@ -14,6 +14,7 @@  lc_compliance_sources = files([
     'capture_test.cpp',
     'environment.cpp',
     'main.cpp',
+    'property_test.cpp',
     'simple_capture.cpp',
     'test_base.cpp',
 ])
diff --git a/src/apps/lc-compliance/property_test.cpp b/src/apps/lc-compliance/property_test.cpp
new file mode 100644
index 00000000..6a0951b2
--- /dev/null
+++ b/src/apps/lc-compliance/property_test.cpp
@@ -0,0 +1,24 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2021, Collabora Ltd.
+ *
+ * property_test.cpp - Test camera properties
+ */
+
+#include <libcamera/libcamera.h>
+
+#include <gtest/gtest.h>
+
+#include "test_base.h"
+
+using namespace libcamera;
+
+TEST_F(CameraTests, RequiredProperties)
+{
+	const ControlList &properties = camera_->properties();
+
+	using namespace properties;
+
+	EXPECT_GT(properties.get(MinimumRequests), 0)
+		<< "Camera should have a positive value for MinimumRequests property";
+}
diff --git a/src/apps/lc-compliance/test_base.cpp b/src/apps/lc-compliance/test_base.cpp
index c9957b9e..a5e64c8b 100644
--- a/src/apps/lc-compliance/test_base.cpp
+++ b/src/apps/lc-compliance/test_base.cpp
@@ -26,3 +26,13 @@  void CameraHolder::releaseCamera()
 	camera_->release();
 	camera_.reset();
 }
+
+void CameraTests::SetUp()
+{
+	acquireCamera();
+}
+
+void CameraTests::TearDown()
+{
+	releaseCamera();
+}
diff --git a/src/apps/lc-compliance/test_base.h b/src/apps/lc-compliance/test_base.h
index 52347749..8125e1c6 100644
--- a/src/apps/lc-compliance/test_base.h
+++ b/src/apps/lc-compliance/test_base.h
@@ -21,4 +21,11 @@  protected:
 	std::shared_ptr<libcamera::Camera> camera_;
 };
 
+class CameraTests : public ::testing::Test, public CameraHolder
+{
+protected:
+	void SetUp() override;
+	void TearDown() override;
+};
+
 #endif /* __LC_COMPLIANCE_TEST_BASE_H__ */