From patchwork Fri May 27 14:44:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16086 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 18F7CBD161 for ; Fri, 27 May 2022 14:45:27 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8F0AC65699; Fri, 27 May 2022 16:45:26 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653662726; bh=VBDpZl+zXtAcncwxGXSiCPQILej/92/BtQsMZ+bUMPw=; 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=0tSJMHfJSmol8huyYipkHf7UJ8jbtPAYPOvobTX0Y7Bwu5NE+9dz0S8+6uusmqMs3 s7GduJh0OZThX5whL8EVIEVBahyRQzMyoobh1c55Jmka9fbfDbjQkcOjY+Szb2UCZE ZYy7a8Fp+IH0KOvXp1FiPAYT88/fccUisjmNXRK/e12wXHs4vh137QLHrIUGT+gd64 WeKucppt0EBCjB4oAbY9/P4TClc/V64Fffo2UC76AkaPNfToLtIouuO+rhoTcdgtHf VVOulI+QjMWK5/yiU9aUAw7hX5l69jGEustllH9a+gAZjjqdzfZqiZ0UxGorQ47Zu7 +c1p8TapwNNFA== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FC226564C for ; Fri, 27 May 2022 16:45:13 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="Cshmfq0e"; dkim-atps=neutral Received: from deskari.lan (91-156-85-209.elisa-laajakaista.fi [91.156.85.209]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B4F751447; Fri, 27 May 2022 16:45:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653662713; bh=VBDpZl+zXtAcncwxGXSiCPQILej/92/BtQsMZ+bUMPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Cshmfq0ex8YZ2lgaGrYFdKpMUZw7ycgNgUlijw36J38JtnZ2g6kBA4ZblXnUiU8P/ GOJSpaOFXGVnWlxFMYaxUzxiGxULdLceBzYmfpRpaRMDV2u/hb5i06yHI1iiGCIQAo ZXXijID/bhk7abtwlIxvhAMV2+dZPNE71bYExkwM= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Fri, 27 May 2022 17:44:34 +0300 Message-Id: <20220527144447.94891-18-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220527144447.94891-1-tomi.valkeinen@ideasonboard.com> References: <20220527144447.94891-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 17/30] py: unittests: Fix test_sleep() 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: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Waiting for 0.5 secs and expecting that the requests have been completed is... bad. Fix the test case by using cam.read_event() as a blocking wait, and wait until we have received all the requests that we queued. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- test/py/unittests.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/test/py/unittests.py b/test/py/unittests.py index 426efb06..45b35223 100755 --- a/test/py/unittests.py +++ b/test/py/unittests.py @@ -161,7 +161,7 @@ class AllocatorTestMethods(CameraTesterBase): class SimpleCaptureMethods(CameraTesterBase): - def test_sleep(self): + def test_blocking(self): cm = self.cm cam = self.cam @@ -207,11 +207,17 @@ class SimpleCaptureMethods(CameraTesterBase): reqs = None gc.collect() - time.sleep(0.5) + reqs = [] - reqs = cm.get_ready_requests() + while True: + cm.read_event() - self.assertTrue(len(reqs) == num_bufs) + ready_reqs = cm.get_ready_requests() + + reqs += ready_reqs + + if len(reqs) == num_bufs: + break for i, req in enumerate(reqs): self.assertTrue(i == req.cookie)