From patchwork Thu May 30 13:38:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kieran Bingham X-Patchwork-Id: 1328 Return-Path: Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 22A6A618F4 for ; Thu, 30 May 2019 15:38:54 +0200 (CEST) Received: from localhost.localdomain (cpc89242-aztw30-2-0-cust488.18-1.cable.virginm.net [86.31.129.233]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9A8DC9F9; Thu, 30 May 2019 15:38:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1559223533; bh=kFlERCYONDsxygZnQXFmm5srRh7z0amAzAs+jeWAsjI=; h=From:To:Cc:Subject:Date:From; b=Uy9e5fA5/J6Ipb6QXEOhYfTDp78vuGPN907mlXBDdKaoWDwD97U3pyQctwxOWsGSh XBrD5AundkP6V5KWt3Hp9MLud9fzsz5lkI61kZsX9Ssh9KHE0LXreFAc9/OSuDH41Q UMll1dAcQorcxuuVySXwPIPro4J3UMfkWJ1oWlPs= From: Kieran Bingham To: LibCamera Devel Date: Thu, 30 May 2019 14:38:49 +0100 Message-Id: <20190530133849.17366-1-kieran.bingham@ideasonboard.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH] test: camera: Fix initialisation 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: Thu, 30 May 2019 13:38:54 -0000 Three tests {capture,configuration_set,statemachine} override the CameraTest::init() function, and call it as the first action. However they were not checking the return value, and each of the tests will segfault if the VIMC camera is not obtained. Check the return value of the CameraTest base class initialisation and return any errors to the test suite if initialisation fails. Signed-off-by: Kieran Bingham Reviewed-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- test/camera/capture.cpp | 4 +++- test/camera/configuration_set.cpp | 4 +++- test/camera/statemachine.cpp | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/test/camera/capture.cpp b/test/camera/capture.cpp index c0835c250c65..98e71905531c 100644 --- a/test/camera/capture.cpp +++ b/test/camera/capture.cpp @@ -42,7 +42,9 @@ protected: int init() override { - CameraTest::init(); + int ret = CameraTest::init(); + if (ret) + return ret; config_ = camera_->generateConfiguration({ StreamRole::VideoRecording }); if (!config_ || config_->size() != 1) { diff --git a/test/camera/configuration_set.cpp b/test/camera/configuration_set.cpp index 9f10f795a5d8..f88da96ca2b7 100644 --- a/test/camera/configuration_set.cpp +++ b/test/camera/configuration_set.cpp @@ -18,7 +18,9 @@ class ConfigurationSet : public CameraTest protected: int init() override { - CameraTest::init(); + int ret = CameraTest::init(); + if (ret) + return ret; config_ = camera_->generateConfiguration({ StreamRole::VideoRecording }); if (!config_ || config_->size() != 1) { diff --git a/test/camera/statemachine.cpp b/test/camera/statemachine.cpp index d489f197e402..84d2a6fab5f0 100644 --- a/test/camera/statemachine.cpp +++ b/test/camera/statemachine.cpp @@ -235,7 +235,9 @@ protected: int init() override { - CameraTest::init(); + int ret = CameraTest::init(); + if (ret) + return ret; defconf_ = camera_->generateConfiguration({ StreamRole::VideoRecording }); if (!defconf_) {