{"id":16086,"url":"https://patchwork.libcamera.org/api/patches/16086/?format=json","web_url":"https://patchwork.libcamera.org/patch/16086/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20220527144447.94891-18-tomi.valkeinen@ideasonboard.com>","date":"2022-05-27T14:44:34","name":"[libcamera-devel,v3,17/30] py: unittests: Fix test_sleep()","commit_ref":null,"pull_url":null,"state":"accepted","archived":false,"hash":"de7668606dba1a62668e0573e2bae3bdf0d539d5","submitter":{"id":109,"url":"https://patchwork.libcamera.org/api/people/109/?format=json","name":"Tomi Valkeinen","email":"tomi.valkeinen@ideasonboard.com"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/16086/mbox/","series":[{"id":3146,"url":"https://patchwork.libcamera.org/api/series/3146/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=3146","date":"2022-05-27T14:44:17","name":"More misc Python patches","version":3,"mbox":"https://patchwork.libcamera.org/series/3146/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/16086/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/16086/checks/","tags":{},"headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 18F7CBD161\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 May 2022 14:45:27 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 8F0AC65699;\n\tFri, 27 May 2022 16:45:26 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 4FC226564C\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 May 2022 16:45:13 +0200 (CEST)","from deskari.lan (91-156-85-209.elisa-laajakaista.fi\n\t[91.156.85.209])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id B4F751447;\n\tFri, 27 May 2022 16:45:12 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653662726;\n\tbh=VBDpZl+zXtAcncwxGXSiCPQILej/92/BtQsMZ+bUMPw=;\n\th=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=0tSJMHfJSmol8huyYipkHf7UJ8jbtPAYPOvobTX0Y7Bwu5NE+9dz0S8+6uusmqMs3\n\ts7GduJh0OZThX5whL8EVIEVBahyRQzMyoobh1c55Jmka9fbfDbjQkcOjY+Szb2UCZE\n\tZYy7a8Fp+IH0KOvXp1FiPAYT88/fccUisjmNXRK/e12wXHs4vh137QLHrIUGT+gd64\n\tWeKucppt0EBCjB4oAbY9/P4TClc/V64Fffo2UC76AkaPNfToLtIouuO+rhoTcdgtHf\n\tVVOulI+QjMWK5/yiU9aUAw7hX5l69jGEustllH9a+gAZjjqdzfZqiZ0UxGorQ47Zu7\n\t+c1p8TapwNNFA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653662713;\n\tbh=VBDpZl+zXtAcncwxGXSiCPQILej/92/BtQsMZ+bUMPw=;\n\th=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n\tb=Cshmfq0ex8YZ2lgaGrYFdKpMUZw7ycgNgUlijw36J38JtnZ2g6kBA4ZblXnUiU8P/\n\tGOJSpaOFXGVnWlxFMYaxUzxiGxULdLceBzYmfpRpaRMDV2u/hb5i06yHI1iiGCIQAo\n\tZXXijID/bhk7abtwlIxvhAMV2+dZPNE71bYExkwM="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"Cshmfq0e\"; dkim-atps=neutral","To":"libcamera-devel@lists.libcamera.org,\n\tDavid Plowman <david.plowman@raspberrypi.com>,\n\tKieran Bingham <kieran.bingham@ideasonboard.com>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tJacopo Mondi <jacopo@jmondi.org>","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","Content-Transfer-Encoding":"8bit","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":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Tomi Valkeinen via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"},"content":"Waiting for 0.5 secs and expecting that the requests have been completed\nis... bad. Fix the test case by using cam.read_event() as a blocking\nwait, and wait until we have received all the requests that we queued.\n\nSigned-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n---\n test/py/unittests.py | 14 ++++++++++----\n 1 file changed, 10 insertions(+), 4 deletions(-)","diff":"diff --git a/test/py/unittests.py b/test/py/unittests.py\nindex 426efb06..45b35223 100755\n--- a/test/py/unittests.py\n+++ b/test/py/unittests.py\n@@ -161,7 +161,7 @@ class AllocatorTestMethods(CameraTesterBase):\n \n \n class SimpleCaptureMethods(CameraTesterBase):\n-    def test_sleep(self):\n+    def test_blocking(self):\n         cm = self.cm\n         cam = self.cam\n \n@@ -207,11 +207,17 @@ class SimpleCaptureMethods(CameraTesterBase):\n         reqs = None\n         gc.collect()\n \n-        time.sleep(0.5)\n+        reqs = []\n \n-        reqs = cm.get_ready_requests()\n+        while True:\n+            cm.read_event()\n \n-        self.assertTrue(len(reqs) == num_bufs)\n+            ready_reqs = cm.get_ready_requests()\n+\n+            reqs += ready_reqs\n+\n+            if len(reqs) == num_bufs:\n+                break\n \n         for i, req in enumerate(reqs):\n             self.assertTrue(i == req.cookie)\n","prefixes":["libcamera-devel","v3","17/30"]}