From patchwork Wed May 8 16:58:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1178 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8F45A60E59 for ; Wed, 8 May 2019 18:58:30 +0200 (CEST) X-Halon-ID: 806ae0dc-71b2-11e9-81fd-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 806ae0dc-71b2-11e9-81fd-0050569116f7; Wed, 08 May 2019 18:58:28 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 18:58:10 +0200 Message-Id: <20190508165814.26201-2-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> References: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/5] test: v4l2_device: Order class sections X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 16:58:30 -0000 Order the sections of a class public, protected and private. There is no functional change only restructuring of existing code to align with the style of other tests. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- test/v4l2_device/buffer_sharing.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/test/v4l2_device/buffer_sharing.cpp b/test/v4l2_device/buffer_sharing.cpp index 45b07fc4905b826e..09695239ee4b9e80 100644 --- a/test/v4l2_device/buffer_sharing.cpp +++ b/test/v4l2_device/buffer_sharing.cpp @@ -27,14 +27,6 @@ public: { } -private: - const unsigned int bufferCount = 4; - - V4L2Device *output_; - - unsigned int framesCaptured_; - unsigned int framesOutput_; - protected: int init() { @@ -182,6 +174,14 @@ protected: V4L2DeviceTest::cleanup(); } + +private: + const unsigned int bufferCount = 4; + + V4L2Device *output_; + + unsigned int framesCaptured_; + unsigned int framesOutput_; }; TEST_REGISTER(BufferSharingTest); From patchwork Wed May 8 16:58:11 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1179 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 12F1560E59 for ; Wed, 8 May 2019 18:58:31 +0200 (CEST) X-Halon-ID: 80e1b596-71b2-11e9-81fd-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 80e1b596-71b2-11e9-81fd-0050569116f7; Wed, 08 May 2019 18:58:29 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 18:58:11 +0200 Message-Id: <20190508165814.26201-3-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> References: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/5] test: v4l2_device: Implement functions inside class definition in cpp files X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 16:58:31 -0000 Implement the functions instead of just defining them in the class description and implement them bellow for classes which are defined in cpp source files. There is no functional change only restructuring of existing code to align with the style of other tests. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- test/v4l2_device/formats.cpp | 58 +++++++++++++++++------------------- 1 file changed, 28 insertions(+), 30 deletions(-) diff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp index 007e7e9487b57772..72676c9d334a69b0 100644 --- a/test/v4l2_device/formats.cpp +++ b/test/v4l2_device/formats.cpp @@ -18,36 +18,34 @@ using namespace libcamera; class Format : public V4L2DeviceTest { protected: - int run() override; + int run() + { + V4L2DeviceFormat format = {}; + + int ret = capture_->getFormat(&format); + if (ret) { + cerr << "Failed to get format" << endl; + return TestFail; + } + + format.size = { UINT_MAX, UINT_MAX }; + ret = capture_->setFormat(&format); + if (ret) { + cerr << "Failed to set format: image resolution is invalid: " + << "(UINT_MAX x UINT_MAX) but setFormat() should not fail." + << endl; + return TestFail; + } + + if (format.size.width == UINT_MAX || + format.size.height == UINT_MAX) { + cerr << "Failed to update image format = (UINT_MAX x UINT_MAX)" + << endl; + return TestFail; + } + + return TestPass; + } }; -int Format::run() -{ - V4L2DeviceFormat format = {}; - - int ret = capture_->getFormat(&format); - if (ret) { - cerr << "Failed to get format" << endl; - return TestFail; - } - - format.size = { UINT_MAX, UINT_MAX }; - ret = capture_->setFormat(&format); - if (ret) { - cerr << "Failed to set format: image resolution is invalid: " - << "(UINT_MAX x UINT_MAX) but setFormat() should not fail." - << endl; - return TestFail; - } - - if (format.size.width == UINT_MAX || - format.size.height == UINT_MAX) { - cerr << "Failed to update image format = (UINT_MAX x UINT_MAX)" - << endl; - return TestFail; - } - - return TestPass; -} - TEST_REGISTER(Format); From patchwork Wed May 8 16:58:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1180 Return-Path: Received: from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net [195.74.38.228]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id C2A8860E7D for ; Wed, 8 May 2019 18:58:33 +0200 (CEST) X-Halon-ID: 814666cc-71b2-11e9-81fd-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 814666cc-71b2-11e9-81fd-0050569116f7; Wed, 08 May 2019 18:58:31 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 18:58:12 +0200 Message-Id: <20190508165814.26201-4-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> References: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/5] test: v4l2_device: Allow each test to specify which device and entity to test X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 16:58:34 -0000 Prepare for different tests which implements V4L2DeviceTest to specify which media device and entity they wish to test. There is no functional changes, all tests still use vivid to perform there tests. Signed-off-by: Niklas Söderlund Acked-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- test/v4l2_device/buffer_sharing.cpp | 5 ++--- test/v4l2_device/capture_async.cpp | 2 +- test/v4l2_device/double_open.cpp | 3 +++ test/v4l2_device/formats.cpp | 3 +++ test/v4l2_device/request_buffers.cpp | 4 ++++ test/v4l2_device/stream_on_off.cpp | 3 +++ test/v4l2_device/v4l2_device_test.cpp | 6 +++--- test/v4l2_device/v4l2_device_test.h | 6 ++++-- 8 files changed, 23 insertions(+), 9 deletions(-) diff --git a/test/v4l2_device/buffer_sharing.cpp b/test/v4l2_device/buffer_sharing.cpp index 09695239ee4b9e80..e63ddff856894130 100644 --- a/test/v4l2_device/buffer_sharing.cpp +++ b/test/v4l2_device/buffer_sharing.cpp @@ -23,9 +23,8 @@ class BufferSharingTest : public V4L2DeviceTest { public: BufferSharingTest() - : output_(nullptr), framesCaptured_(0), framesOutput_(0) - { - } + : V4L2DeviceTest("vivid", "vivid-000-vid-cap"), + output_(nullptr), framesCaptured_(0), framesOutput_(0) {} protected: int init() diff --git a/test/v4l2_device/capture_async.cpp b/test/v4l2_device/capture_async.cpp index 2a41b11e95e77dac..fd428ff909f32999 100644 --- a/test/v4l2_device/capture_async.cpp +++ b/test/v4l2_device/capture_async.cpp @@ -18,7 +18,7 @@ class CaptureAsyncTest : public V4L2DeviceTest { public: CaptureAsyncTest() - : frames(0){}; + : V4L2DeviceTest("vivid", "vivid-000-vid-cap"), frames(0) {} void receiveBuffer(Buffer *buffer) { diff --git a/test/v4l2_device/double_open.cpp b/test/v4l2_device/double_open.cpp index 7ec80a60f57ee036..b402de04fca5ddbb 100644 --- a/test/v4l2_device/double_open.cpp +++ b/test/v4l2_device/double_open.cpp @@ -13,6 +13,9 @@ namespace { class DoubleOpen : public V4L2DeviceTest { +public: + DoubleOpen() + : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} protected: int run() { diff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp index 72676c9d334a69b0..3ac47f5cc665b62b 100644 --- a/test/v4l2_device/formats.cpp +++ b/test/v4l2_device/formats.cpp @@ -17,6 +17,9 @@ using namespace libcamera; class Format : public V4L2DeviceTest { +public: + Format() + : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} protected: int run() { diff --git a/test/v4l2_device/request_buffers.cpp b/test/v4l2_device/request_buffers.cpp index 938d4f85d5a1e711..794b083eb84d8d2e 100644 --- a/test/v4l2_device/request_buffers.cpp +++ b/test/v4l2_device/request_buffers.cpp @@ -9,6 +9,10 @@ class RequestBuffersTest : public V4L2DeviceTest { +public: + RequestBuffersTest() + : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} + protected: int run() { diff --git a/test/v4l2_device/stream_on_off.cpp b/test/v4l2_device/stream_on_off.cpp index ea1b3f5bd5a4cbea..4902d5fd6d58a73d 100644 --- a/test/v4l2_device/stream_on_off.cpp +++ b/test/v4l2_device/stream_on_off.cpp @@ -9,6 +9,9 @@ class StreamOnStreamOffTest : public V4L2DeviceTest { +public: + StreamOnStreamOffTest() + : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} protected: int run() { diff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp index 833038d56ea4631d..ee5a8e009bef2a5e 100644 --- a/test/v4l2_device/v4l2_device_test.cpp +++ b/test/v4l2_device/v4l2_device_test.cpp @@ -39,14 +39,14 @@ int V4L2DeviceTest::init() return TestFail; } - DeviceMatch dm("vivid"); - dm.add("vivid-000-vid-cap"); + DeviceMatch dm(driver_); + dm.add(entity_); media_ = enumerator_->search(dm); if (!media_) return TestSkip; - MediaEntity *entity = media_->getEntityByName("vivid-000-vid-cap"); + MediaEntity *entity = media_->getEntityByName(entity_); if (!entity) return TestSkip; diff --git a/test/v4l2_device/v4l2_device_test.h b/test/v4l2_device/v4l2_device_test.h index c476d3c05e79747a..651c005f4e5485e6 100644 --- a/test/v4l2_device/v4l2_device_test.h +++ b/test/v4l2_device/v4l2_device_test.h @@ -22,8 +22,8 @@ using namespace libcamera; class V4L2DeviceTest : public Test { public: - V4L2DeviceTest() - : capture_(nullptr) + V4L2DeviceTest(const char *driver, const char *entity) + : driver_(driver), entity_(entity), capture_(nullptr) { } @@ -31,6 +31,8 @@ protected: int init(); void cleanup(); + std::string driver_; + std::string entity_; std::unique_ptr enumerator_; std::shared_ptr media_; V4L2Device *capture_; From patchwork Wed May 8 16:58:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1181 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C8AD60E7D for ; Wed, 8 May 2019 18:58:34 +0200 (CEST) X-Halon-ID: 8277c700-71b2-11e9-81fd-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 8277c700-71b2-11e9-81fd-0050569116f7; Wed, 08 May 2019 18:58:32 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 18:58:13 +0200 Message-Id: <20190508165814.26201-5-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> References: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 4/5] test: v4l2_device: Reset media links and set a resolution X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 16:58:34 -0000 When initializing the test reset any media links and set a know resolutions. This is needed to put the device under test into known state and not have the v4l2 device tests depend on that no one have touched the device before the test is executed. The resolution is picked purely at random and could possibly be moved to each test case if there is a need for different resolutions for a specific one. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- test/v4l2_device/v4l2_device_test.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/test/v4l2_device/v4l2_device_test.cpp b/test/v4l2_device/v4l2_device_test.cpp index ee5a8e009bef2a5e..5bd80a6c68d796b6 100644 --- a/test/v4l2_device/v4l2_device_test.cpp +++ b/test/v4l2_device/v4l2_device_test.cpp @@ -54,7 +54,24 @@ int V4L2DeviceTest::init() if (!capture_) return TestFail; - return capture_->open(); + media_->acquire(); + if (media_->disableLinks()) + return TestFail; + media_->release(); + + if (capture_->open()) + return TestFail; + + V4L2DeviceFormat format = {}; + if (capture_->getFormat(&format)) + return TestFail; + + format.size.width = 640; + format.size.height = 480; + if (capture_->setFormat(&format)) + return TestFail; + + return TestPass; } void V4L2DeviceTest::cleanup() From patchwork Wed May 8 16:58:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Niklas_S=C3=B6derlund?= X-Patchwork-Id: 1182 Return-Path: Received: from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net [195.74.38.229]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 9F4D460E6E for ; Wed, 8 May 2019 18:58:34 +0200 (CEST) X-Halon-ID: 82dc74e4-71b2-11e9-81fd-0050569116f7 Authorized-sender: niklas@soderlund.pp.se Received: from localhost.localdomain (unknown [79.138.136.66]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA id 82dc74e4-71b2-11e9-81fd-0050569116f7; Wed, 08 May 2019 18:58:32 +0200 (CEST) From: =?utf-8?q?Niklas_S=C3=B6derlund?= To: libcamera-devel@lists.libcamera.org Date: Wed, 8 May 2019 18:58:14 +0200 Message-Id: <20190508165814.26201-6-niklas.soderlund@ragnatech.se> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> References: <20190508165814.26201-1-niklas.soderlund@ragnatech.se> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 5/5] test: v4l2_device: Switch most tests to vimc X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 08 May 2019 16:58:34 -0000 The vimc driver delivers frames much faster then the vivid driver hence most v4l2 device tests complete much quicker if vimc is used. The only v4l2 device test which can't be switched is buffer_sharing as it needs to import buffers somewhere, something vimc do not support. With this change I manage to shave of almost 7 seconds for each run of all v4l2 device tests. Signed-off-by: Niklas Söderlund Reviewed-by: Laurent Pinchart --- test/v4l2_device/capture_async.cpp | 2 +- test/v4l2_device/double_open.cpp | 2 +- test/v4l2_device/formats.cpp | 2 +- test/v4l2_device/request_buffers.cpp | 2 +- test/v4l2_device/stream_on_off.cpp | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/v4l2_device/capture_async.cpp b/test/v4l2_device/capture_async.cpp index fd428ff909f32999..69b1d5a13ed8675a 100644 --- a/test/v4l2_device/capture_async.cpp +++ b/test/v4l2_device/capture_async.cpp @@ -18,7 +18,7 @@ class CaptureAsyncTest : public V4L2DeviceTest { public: CaptureAsyncTest() - : V4L2DeviceTest("vivid", "vivid-000-vid-cap"), frames(0) {} + : V4L2DeviceTest("vimc", "Raw Capture 0"), frames(0) {} void receiveBuffer(Buffer *buffer) { diff --git a/test/v4l2_device/double_open.cpp b/test/v4l2_device/double_open.cpp index b402de04fca5ddbb..53850620889b0972 100644 --- a/test/v4l2_device/double_open.cpp +++ b/test/v4l2_device/double_open.cpp @@ -15,7 +15,7 @@ class DoubleOpen : public V4L2DeviceTest { public: DoubleOpen() - : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} + : V4L2DeviceTest("vimc", "Raw Capture 0") {} protected: int run() { diff --git a/test/v4l2_device/formats.cpp b/test/v4l2_device/formats.cpp index 3ac47f5cc665b62b..6be045ff754c4258 100644 --- a/test/v4l2_device/formats.cpp +++ b/test/v4l2_device/formats.cpp @@ -19,7 +19,7 @@ class Format : public V4L2DeviceTest { public: Format() - : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} + : V4L2DeviceTest("vimc", "Raw Capture 0") {} protected: int run() { diff --git a/test/v4l2_device/request_buffers.cpp b/test/v4l2_device/request_buffers.cpp index 794b083eb84d8d2e..7b7b06b2b409bd23 100644 --- a/test/v4l2_device/request_buffers.cpp +++ b/test/v4l2_device/request_buffers.cpp @@ -11,7 +11,7 @@ class RequestBuffersTest : public V4L2DeviceTest { public: RequestBuffersTest() - : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} + : V4L2DeviceTest("vimc", "Raw Capture 0") {} protected: int run() diff --git a/test/v4l2_device/stream_on_off.cpp b/test/v4l2_device/stream_on_off.cpp index 4902d5fd6d58a73d..b158b8e402c83156 100644 --- a/test/v4l2_device/stream_on_off.cpp +++ b/test/v4l2_device/stream_on_off.cpp @@ -11,7 +11,7 @@ class StreamOnStreamOffTest : public V4L2DeviceTest { public: StreamOnStreamOffTest() - : V4L2DeviceTest("vivid", "vivid-000-vid-cap") {} + : V4L2DeviceTest("vimc", "Raw Capture 0") {} protected: int run() {