From patchwork Thu Jul 21 13:45:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Umang Jain X-Patchwork-Id: 16725 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 C9F2FBE173 for ; Thu, 21 Jul 2022 13:45:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id EEB606330F; Thu, 21 Jul 2022 15:45:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1658411142; bh=i+L6j3AdDpIeoMdta1mI0bprcF2kgfzQXMD0Z/TH1+c=; h=To:Date:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=P4IRP+6XHZIUIF6DAOVpjPGVwo9zQKLTcLsLz6bEzvPr8AQ++voo7tq8tEeqOrTaz DYbV818U5D8+nS+/cqPmSGazqu9urJWdLkgxQPFdZ6paSqpeqfThuIOx22duGSSnqz +0sLdl5wUiD4iBLhDBZPiFVAuvfcwbD0vqVBZLdKEIJj171gp8KeZ/GkzDteKk9AKZ 7rap5EOPwtnshXdBwMuE7siJb+XbCKiygTEqPV/z/SFVDCD4IvqPz6CP8SPO79iYiy EzDIMElZ0OtH4TS4me+SqcRnxNrqYialILI2qS4fBh/amEyw9rQCiMJQQaP6caupS9 ydq08Ab2w9rXQ== 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 7EAA1601B8 for ; Thu, 21 Jul 2022 15:45:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="i8gz+92s"; 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 3A7AA496; Thu, 21 Jul 2022 15:45:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1658411139; bh=i+L6j3AdDpIeoMdta1mI0bprcF2kgfzQXMD0Z/TH1+c=; h=From:To:Cc:Subject:Date:From; b=i8gz+92s8QNf3IWC/rNDDM7CDtXShOELABPXErhs/5SkW+aOyR70WEEszhUJBPkLU ++b9eK1OO8Zud2J7CvBVnZSCriyYJRbvoLN75bA+rhVq2eSzgt9TPXa2ZbIfDs8d+H ySCDYI4XOaNr6k4smcdCXUrW15xDyYFInGYsuQOo= To: libcamera-devel@lists.libcamera.org Date: Thu, 21 Jul 2022 19:15:30 +0530 Message-Id: <20220721134531.1091104-1-umang.jain@ideasonboard.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 1/2] test: gstreamer: Drop internal header from base class 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" The internal header isn't needed. The needed function libcameraBuildPath() is exposed by libcamera/base/utils.h header. At the same time, move the utils header to .cpp instead of including it in the base class header itself. Signed-off-by: Umang Jain Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- test/gstreamer/gstreamer_test.cpp | 2 ++ test/gstreamer/gstreamer_test.h | 4 ---- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/test/gstreamer/gstreamer_test.cpp b/test/gstreamer/gstreamer_test.cpp index 227a5c37..cfb8afc6 100644 --- a/test/gstreamer/gstreamer_test.cpp +++ b/test/gstreamer/gstreamer_test.cpp @@ -5,6 +5,8 @@ * libcamera Gstreamer element API tests */ +#include + #include "gstreamer_test.h" #include "test.h" diff --git a/test/gstreamer/gstreamer_test.h b/test/gstreamer/gstreamer_test.h index 9869d252..35adab0e 100644 --- a/test/gstreamer/gstreamer_test.h +++ b/test/gstreamer/gstreamer_test.h @@ -10,10 +10,6 @@ #include #include -#include - -#include "libcamera/internal/source_paths.h" - #include class GstreamerTest 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); };