From patchwork Thu Jul 21 13:45:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16726 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id C94C7BE173 for ; Thu, 21 Jul 2022 13:45:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8146063315; Thu, 21 Jul 2022 15:45:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658411144; bh=mIvABvWeRKQBY6W0HPNmH9t9v8Zst598xYKrzVVD148=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=LOSSRRo0WJmMswmD0AESo4MTymJM1OZ0hQmVRoaG0FevQcXUPZJZoJ3leFGLVx5VU NovID1YwMzXQdJOQbdR++FeAWvecBlRqVrUIQ/OvisfiH68ydSZq6zV83lfzesXqA4 IWDlSBP31M0vh6qeqlQyWsqrq6XDw2JcuxkiIvWRwFCxhdUnJvunvkBYMdk2VD8C7N WVFg/r5Z31okK5NYuf72klnUkCzvlY8VHQrMrIet+JCDxWGMccr7ROsj12TaBH4oi8 /U8h6m+MERj3hPMXBcTcE73SwWE07Yz5qVclg3HLE/XlAxKZMSZ2c8URu4N4Tfv4EX Nj8lcNhRHa+OA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 3DBE463310 for ; Thu, 21 Jul 2022 15:45:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FrW3pZQo"; dkim-atps=neutral Received: from perceval.ideasonboard.com (unknown [IPv6:2401:4900:1f3f:a2d:c6dd:7a7c:3d3c:dbb9]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 00EBA496; Thu, 21 Jul 2022 15:45:40 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658411141; bh=mIvABvWeRKQBY6W0HPNmH9t9v8Zst598xYKrzVVD148=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FrW3pZQoh+Nx8g50OXmKykhthd71dfs/HjP9jiMb8zbSVJ69i6uoYrpkJ+pyJGM2Q liqCDsTF2ES9xtm/JhJ44AISYfoyDQK8C+F/nBCq5pRimeW30pGM7e75R19+ZmdFr3 81BSLCRkygZ8QyPRl1guLHYVh8U+Unn7MQlIHoAo= To: libcamera-devel@lists.libcamera.org Date: Thu, 21 Jul 2022 19:15:31 +0530 Message-Id: <20220721134531.1091104-2-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220721134531.1091104-1-umang.jain@ideasonboard.com> References: <20220721134531.1091104-1-umang.jain@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 2/2] test: gstreamer: Check availability of cameras before running X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Umang Jain via libcamera-devel From: Umang Jain Reply-To: Umang Jain Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Move the logic for checking the availability of cameras from multi_stream_test to gstreamer test base class. Since single_stream_class always assumes that a camera is available on the system (which is not always the case for e.g. RPi in CI/CD environments) it makes sense to have the availability check in the base class. If no cameras are available, the behaviour should be to skip instead of a failure. We currently have 2 tests for gstreamer differing based on number of streams supported by the camera. Hence, the camera availability is checked in conjunction with the number of the streams required by the derived class. Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- .../gstreamer/gstreamer_multi_stream_test.cpp | 20 +---------- test/gstreamer/gstreamer_test.cpp | 33 ++++++++++++++++++- test/gstreamer/gstreamer_test.h | 4 ++- 3 files changed, 36 insertions(+), 21 deletions(-) diff --git a/test/gstreamer/gstreamer_multi_stream_test.cpp b/test/gstreamer/gstreamer_multi_stream_test.cpp index 112f1dee..b8387c10 100644 --- a/test/gstreamer/gstreamer_multi_stream_test.cpp +++ b/test/gstreamer/gstreamer_multi_stream_test.cpp @@ -29,7 +29,7 @@ class GstreamerMultiStreamTest : public GstreamerTest, public Test { public: GstreamerMultiStreamTest() - : GstreamerTest() + : GstreamerTest(2) { } @@ -39,24 +39,6 @@ protected: if (status_ != TestPass) return status_; - /* Check if platform supports multistream capture */ - libcamera::CameraManager cm; - cm.start(); - bool cameraFound = false; - for (auto &camera : cm.cameras()) { - if (camera->streams().size() > 1) { - cameraName_ = camera->id(); - cameraFound = true; - cm.stop(); - break; - } - } - - if (!cameraFound) { - cm.stop(); - return TestSkip; - } - const gchar *streamDescription = "queue ! fakesink"; g_autoptr(GError) error = NULL; diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp index cfb8afc6..4668aa00 100644 --- a/test/gstreamer/gstreamer_test.cpp +++ b/test/gstreamer/gstreamer_test.cpp @@ -5,6 +5,7 @@ * libcamera Gstreamer element API tests */ +#include #include #include "gstreamer_test.h" @@ -25,9 +26,10 @@ const char *__asan_default_options() } } -GstreamerTest::GstreamerTest() +GstreamerTest::GstreamerTest(unsigned int numStreams) : pipeline_(nullptr), libcameraSrc_(nullptr) { + /* * GStreamer by default spawns a process to run the * gst-plugin-scanner helper. If libcamera is compiled with ASan @@ -67,9 +69,38 @@ GstreamerTest::GstreamerTest() return; } + /* + * Atleast one camera should be available with numStreams streams + * otherwise, skip the test entirely. + */ + if (!satisfyCameraStreams(numStreams)) { + status_ = TestSkip; + return; + } + status_ = TestPass; } +bool GstreamerTest::satisfyCameraStreams(unsigned int numStreams) +{ + libcamera::CameraManager cm; + bool cameraFound = false; + + cm.start(); + + for (auto &camera : cm.cameras()) { + if (camera->streams().size() < numStreams) + continue; + + cameraFound = true; + break; + } + + cm.stop(); + + return cameraFound; +} + GstreamerTest::~GstreamerTest() { g_clear_object(&pipeline_); diff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h index 35adab0e..fa41721f 100644 --- a/test/gstreamer/gstreamer_test.h +++ b/test/gstreamer/gstreamer_test.h @@ -15,7 +15,7 @@ class GstreamerTest { public: - GstreamerTest(); + GstreamerTest(unsigned int numStreams = 1); virtual ~GstreamerTest(); protected: @@ -27,4 +27,6 @@ protected: GstElement *pipeline_; GstElement *libcameraSrc_; int status_; +private: + bool satisfyCameraStreams(unsigned int numStreams); };