[{"id":23004,"web_url":"https://patchwork.libcamera.org/comment/23004/","msgid":"<165280495894.2416244.7508177391117509997@Monstersaurus>","date":"2022-05-17T16:29:18","subject":"Re: [libcamera-devel] [PATCH v2 05/13] py: unittests: verify that\n\tcam and cm are freed","submitter":{"id":4,"url":"https://patchwork.libcamera.org/api/people/4/","name":"Kieran Bingham","email":"kieran.bingham@ideasonboard.com"},"content":"Quoting Tomi Valkeinen (2022-05-17 15:33:17)\n> Add checks to CameraTesterBase to verify that both the Camera and the\n> CameraManager gets freed.\n> \n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n\n> ---\n>  test/py/unittests.py | 6 ++++++\n>  1 file changed, 6 insertions(+)\n> \n> diff --git a/test/py/unittests.py b/test/py/unittests.py\n> index 9326358d..4c214f0a 100755\n> --- a/test/py/unittests.py\n> +++ b/test/py/unittests.py\n> @@ -83,6 +83,9 @@ class CameraTesterBase(BaseTestCase):\n>              self.cm = None\n>              raise Exception('Failed to acquire camera')\n>  \n> +        self.wr_cam = weakref.ref(self.cam)\n> +        self.wr_cm = weakref.ref(self.cm)\n> +\n>      def tearDown(self):\n>          # If a test fails, the camera may be in running state. So always stop.\n>          self.cam.stop()\n> @@ -94,6 +97,9 @@ class CameraTesterBase(BaseTestCase):\n>          self.cam = None\n>          self.cm = None\n>  \n> +        self.assertIsNone(self.wr_cm())\n> +        self.assertIsNone(self.wr_cam())\n\nThis seems a bit extreme testing that something is None right after\nsetting it to None? But perhaps there are going to be further expansions\nthat make this worth checking?\n\nDoes this test something that I'm not seeing?\n\n<Edit> Turns out this really is checking that there were no extra\nreferences keeping those objects alive with an extra reference, so this\nis fine by me.\n\n\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n\n\n> +\n>  \n>  class AllocatorTestMethods(CameraTesterBase):\n>      def test_allocator(self):\n> -- \n> 2.34.1\n>","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 AB7D4C3256\n\tfor <parsemail@patchwork.libcamera.org>;\n\tTue, 17 May 2022 16:29:23 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 3035365656;\n\tTue, 17 May 2022 18:29:23 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id D93A96041D\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tTue, 17 May 2022 18:29:21 +0200 (CEST)","from pendragon.ideasonboard.com\n\t(cpc89244-aztw30-2-0-cust3082.18-1.cable.virginm.net [86.31.172.11])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 2BE7E48F;\n\tTue, 17 May 2022 18:29:21 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1652804963;\n\tbh=gUMrcrtfDLa0A810k7CRu6T2rMgM2x8eTFVIxY29Qt8=;\n\th=In-Reply-To:References:To:Date:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:\n\tFrom;\n\tb=RnljJ2bKeCLKDHdCpgPH51RJKsKQJrcwHy0QBFLo5GYGnrITTUrAaPjDsYKB+iXbj\n\tAW3zet+vpYgVVQKilWuiyCrLV0t2Y7yhi2FKW9rpAXHyK44rSUVOUCgrtQCquyNWXh\n\ttiLfnQW75iSU0DwBU4DCI3f7rZT7HCTf4T0KqWHY77RciBtps12j64ggHzcgjfgjEn\n\tiKKahC40nei4jwN3S4r2P76ogPdqvAx1TdXk6awdWCg6DyzprAJDBljbXMqo0sQAPe\n\te19G3xTix6ISpHwN9boW7fJqDsGARRVCzfN4wtePm7nGwB/XLCte9nAQkM22Nn1BEb\n\tnJgjY/mhCgazA==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1652804961;\n\tbh=gUMrcrtfDLa0A810k7CRu6T2rMgM2x8eTFVIxY29Qt8=;\n\th=In-Reply-To:References:Subject:From:Cc:To:Date:From;\n\tb=ST4Av66gxGbTgrKeKxNBjhaNuvoij6HRaZIzJhVyEFx5eK7psQd5zWn/ZOB3Zrsm8\n\tz3awoxUqIvTC6Dq6sPzpYyI/ErTwsNyYrzPldHSEQOYZLZVgoC/OhgiQJQt5nDz93V\n\tVde9N9SpUw9sZrKUQfkFiaTamzznFB465oSdho7c="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"ST4Av66g\"; dkim-atps=neutral","Content-Type":"text/plain; charset=\"utf-8\"","MIME-Version":"1.0","Content-Transfer-Encoding":"quoted-printable","In-Reply-To":"<20220517143325.71784-6-tomi.valkeinen@ideasonboard.com>","References":"<20220517143325.71784-1-tomi.valkeinen@ideasonboard.com>\n\t<20220517143325.71784-6-tomi.valkeinen@ideasonboard.com>","To":"David Plowman <david.plowman@raspberrypi.com>,\n\tJacopo Mondi <jacopo@jmondi.org>,\n\tLaurent Pinchart <laurent.pinchart@ideasonboard.com>,\n\tTomi Valkeinen <tomi.valkeinen@ideasonboard.com>,\n\tlibcamera-devel@lists.libcamera.org","Date":"Tue, 17 May 2022 17:29:18 +0100","Message-ID":"<165280495894.2416244.7508177391117509997@Monstersaurus>","User-Agent":"alot/0.10","Subject":"Re: [libcamera-devel] [PATCH v2 05/13] py: unittests: verify that\n\tcam and cm are freed","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":"Kieran Bingham via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Kieran Bingham <kieran.bingham@ideasonboard.com>","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]