[{"id":23202,"web_url":"https://patchwork.libcamera.org/comment/23202/","msgid":"<YpEhQiV3sQSmjMOS@pendragon.ideasonboard.com>","date":"2022-05-27T19:06:42","subject":"Re: [libcamera-devel] [PATCH v3 17/30] py: unittests: Fix\n\ttest_sleep()","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nThank you for the patch.\n\nOn Fri, May 27, 2022 at 05:44:34PM +0300, Tomi Valkeinen wrote:\n> Waiting for 0.5 secs and expecting that the requests have been completed\n> is... bad. Fix the test case by using cam.read_event() as a blocking\n> wait, and wait until we have received all the requests that we queued.\n> \n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n> ---\n>  test/py/unittests.py | 14 ++++++++++----\n>  1 file changed, 10 insertions(+), 4 deletions(-)\n> \n> diff --git a/test/py/unittests.py b/test/py/unittests.py\n> index 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)","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 BBC3BBD160\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 27 May 2022 19:06:50 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 22FB7633A3;\n\tFri, 27 May 2022 21:06:50 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id CBD02633A2\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 27 May 2022 21:06:48 +0200 (CEST)","from pendragon.ideasonboard.com (unknown [46.183.103.8])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id ACC2332A;\n\tFri, 27 May 2022 21:06:46 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1653678410;\n\tbh=dw3EPgtk8BBCXcf7N+/vkMRDqqCp+9O+ZCcdo8v3gAw=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=XKgww6v9sFs6qnWriX3HnaVQ5M9XIGOTGyFsCAfN8aI4oEPv5vZbD8fV7vjyoB+a1\n\tJynJxhkaYcj0u+aAVHdKr4Y3UjQX+KIdqdjshney19NtmC3L9J379s/V07JMkRCzTG\n\tkKlfqJyxPva3icofiruNY/nSjzV2cBVZBg8KsT9Q7FmW2PkJfZWW+4ZqXIXwJyCofY\n\tnX7fu1If1r4NG63zRI7gNj7gqQstbatRv8FrPl5dlwoK40zITMceGw1XthHsfiuNpZ\n\tXjccZkij/SyP3ISdSHj/6uWGrODMJ7iDKITxI60CgpZ4vfkSU1vPnYA/6QvENmB3Ma\n\ti7J9bGxd8AEBA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1653678408;\n\tbh=dw3EPgtk8BBCXcf7N+/vkMRDqqCp+9O+ZCcdo8v3gAw=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pLV+2htF39mPv8dOXhLZ/FcfcEp7nQ7Av9oJwsAev2/aYrN+EgEMWzfgkiaNKMt4S\n\tTWvlj9QzhSbqRDdFYsGixMCqGa9FmBL1goMz9Y2tC/HJm8HdM/gknfh3Hy9iLIszFP\n\t1smlrP2nVVFlyCkeXsJBTS6LIHoa638XaKqHR2Wk="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"pLV+2htF\"; dkim-atps=neutral","Date":"Fri, 27 May 2022 22:06:42 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<YpEhQiV3sQSmjMOS@pendragon.ideasonboard.com>","References":"<20220527144447.94891-1-tomi.valkeinen@ideasonboard.com>\n\t<20220527144447.94891-18-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20220527144447.94891-18-tomi.valkeinen@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v3 17/30] py: unittests: Fix\n\ttest_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":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]