[libcamera-devel,07/11] test: v4l2_device: Add StreamOn/StreamOff test

Message ID 20190203110102.5663-8-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
Provide a small test to exercise the streamOn() and streamOff() calls.
8 buffers are requested locally.

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

Patch

diff --git a/test/v4l2_device/meson.build b/test/v4l2_device/meson.build
index b6b672611d60..cbaa79da9b81 100644
--- a/test/v4l2_device/meson.build
+++ b/test/v4l2_device/meson.build
@@ -3,6 +3,7 @@ 
 v4l2_device_tests = [
   [ 'double_open',        'double_open.cpp' ],
   [ 'request_buffers',    'request_buffers.cpp' ],
+  [ 'stream_on_off',      'stream_on_off.cpp' ],
 ]
 
 foreach t : v4l2_device_tests
diff --git a/test/v4l2_device/stream_on_off.cpp b/test/v4l2_device/stream_on_off.cpp
new file mode 100644
index 000000000000..9f1937b66aae
--- /dev/null
+++ b/test/v4l2_device/stream_on_off.cpp
@@ -0,0 +1,29 @@ 
+/* SPDX-License-Identifier: GPL-2.0-or-later */
+/*
+ * Copyright (C) 2019, Google Inc.
+ *
+ * libcamera V4L2 API tests
+ */
+
+#include "v4l2_device_test.h"
+
+class StreamOnStreamOff : public V4L2DeviceTest
+{
+protected:
+	int run()
+	{
+		int ret;
+
+		BufferPool *pool = dev_->requestBuffers(8);
+		if (!pool)
+			return TestFail;
+
+		ret = dev_->streamOn();
+		if (ret)
+			return ret;
+
+		return dev_->streamOff();
+	}
+};
+
+TEST_REGISTER(StreamOnStreamOff);