From patchwork Mon May 30 14:27:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 16108 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 08FDFC3256 for ; Mon, 30 May 2022 14:27:42 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 7E60A6563F; Mon, 30 May 2022 16:27:41 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1653920861; bh=BZb0p4A1aVTXfJycBSMBlwFjjsXco7PjNcFq4WRlQTo=; 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=4XthDISsYQzlQ4Dy6aoxBAzT3usIOkCKvChEU2+41LGKUzCDEwoEuq/oVAN7H94X7 uXOcC7mQzA8DeeVCjpip4X1zMwSPU/KmGeJmpH+vEx2st7xGwvi5+kZr5zBioLyg6L 3EQqSTUjd+7EhSSGDuETK3YFURpAOR4hBcOK4ImZsDjKXu8wxxKsH9P9s9LcpV33LM ZnRLfsRhamQsLzWNImytcK7LUHUII+3mojP/Ps3gJ4n4tVcWjyRjT/WIDDwxdii6Yb Aq2ry5+RB5fhxJleVddd4oaIq5gWBq813R3VxR1TvqJlYKmhisENuct+aVJ0LlCwWo JoNjNVW8aR/sQ== 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 B941F60411 for ; Mon, 30 May 2022 16:27:39 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="FvRn04+n"; 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 310D3B90; Mon, 30 May 2022 16:27:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1653920859; bh=BZb0p4A1aVTXfJycBSMBlwFjjsXco7PjNcFq4WRlQTo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FvRn04+n5o8xsJnJWoGDaBpPwDnfOfl9+jSqxQ9l2yNb4Ntp+M+6D0OAGgUA9YZo2 vchHFvXDYnStZhoLMvSVUW6tjceEDcmtC75vSh1QD4BIxO1XTnzyJHpG1PHFO55x7Z Ql+LuaxgPpKk5OjBgr+8W936ZcaW5a48yeC0lFHo= To: libcamera-devel@lists.libcamera.org, David Plowman , Kieran Bingham , Laurent Pinchart , Jacopo Mondi Date: Mon, 30 May 2022 17:27:07 +0300 Message-Id: <20220530142722.57618-2-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220530142722.57618-1-tomi.valkeinen@ideasonboard.com> References: <20220530142722.57618-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 01/16] 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)