[libcamera-devel,05/11] test: v4l2_device: Add request_buffers test

Message ID 20190203110102.5663-6-kieran.bingham@ideasonboard.com
State Accepted
Headers show
Series
  • libcamera: V4L2 Streams
Related show

Commit Message

Kieran Bingham Feb. 3, 2019, 11 a.m. UTC
Add a utility to the test suite to request and allocate buffers from
a V4L2Device to ensure it functions successfully.

Signed-off-by: Kieran Bingham <kieran.bingham@ideasonboard.com>
---
 test/v4l2_device/meson.build         |  1 +
 test/v4l2_device/request_buffers.cpp | 28 ++++++++++++++++++++++++++++
 2 files changed, 29 insertions(+)
 create mode 100644 test/v4l2_device/request_buffers.cpp

Patch

diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build
index 41675a303498..b6b672611d60 100644
--- a/test/v4l2_device/meson.build
+++ b/test/v4l2_device/meson.build
@@ -2,6 +2,7 @@ 
 # They are not alphabetically sorted.
 v4l2_device_tests = [
   [ 'double_open',        'double_open.cpp' ],
+  [ 'request_buffers',    'request_buffers.cpp' ],
 ]
 
 foreach t : v4l2_device_tests
diff --git a/test/v4l2_device/request_buffers.cpp b/test/v4l2_device/request_buffers.cpp
new file mode 100644
index 000000000000..8ab0f560516f
--- /dev/null
+++ b/test/v4l2_device/request_buffers.cpp
@@ -0,0 +1,28 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * libcamera V4L2 API tests
+ */
+
+#include "v4l2_device_test.h"
+
+class RequestBuffers : public V4L2DeviceTest
+{
+protected:
+	int run()
+	{
+		/* TODO:
+		 *  Test invalid requests
+		 *  Test different buffer allocations
+		 */
+		BufferPool *pool = dev_->requestBuffers(8);
+
+		if (!pool)
+			return TestFail;
+
+		return TestPass;
+	}
+};
+
+TEST_REGISTER(RequestBuffers);