[libcamera-devel,05/14] py: unittests: verify that cam and cm are freed
diff mbox series

Message ID 20220516141022.96327-6-tomi.valkeinen@ideasonboard.com
State Superseded
Headers show
Series
  • Misc Python bindings patches
Related show

Commit Message

Tomi Valkeinen May 16, 2022, 2:10 p.m. UTC
Add checks to CameraTesterBase to verify that both the Camera and the
CameraManager gets freed.

Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
---
 test/py/unittests.py | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Laurent Pinchart May 17, 2022, 8:18 a.m. UTC | #1
Hi Tomi,

Thank you for the patch.

On Mon, May 16, 2022 at 05:10:13PM +0300, Tomi Valkeinen wrote:
> Add checks to CameraTesterBase to verify that both the Camera and the
> CameraManager gets freed.
> 
> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>
> ---
>  test/py/unittests.py | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/test/py/unittests.py b/test/py/unittests.py
> index 9326358d..288dcd48 100755
> --- a/test/py/unittests.py
> +++ b/test/py/unittests.py
> @@ -83,6 +83,10 @@ class CameraTesterBase(BaseTestCase):
>              self.cm = None
>              raise Exception('Failed to acquire camera')
>  
> +        self.wr_cam = weakref.ref(self.cam)
> +        self.wr_cm = weakref.ref(self.cm)
> +
> +

Extra blank line ? Apart from that,

Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>

>      def tearDown(self):
>          # If a test fails, the camera may be in running state. So always stop.
>          self.cam.stop()
> @@ -94,6 +98,9 @@ class CameraTesterBase(BaseTestCase):
>          self.cam = None
>          self.cm = None
>  
> +        self.assertIsNone(self.wr_cm())
> +        self.assertIsNone(self.wr_cam())
> +
>  
>  class AllocatorTestMethods(CameraTesterBase):
>      def test_allocator(self):

Patch
diff mbox series

diff --git a/test/py/unittests.py b/test/py/unittests.py
index 9326358d..288dcd48 100755
--- a/test/py/unittests.py
+++ b/test/py/unittests.py
@@ -83,6 +83,10 @@  class CameraTesterBase(BaseTestCase):
             self.cm = None
             raise Exception('Failed to acquire camera')
 
+        self.wr_cam = weakref.ref(self.cam)
+        self.wr_cm = weakref.ref(self.cm)
+
+
     def tearDown(self):
         # If a test fails, the camera may be in running state. So always stop.
         self.cam.stop()
@@ -94,6 +98,9 @@  class CameraTesterBase(BaseTestCase):
         self.cam = None
         self.cm = None
 
+        self.assertIsNone(self.wr_cm())
+        self.assertIsNone(self.wr_cam())
+
 
 class AllocatorTestMethods(CameraTesterBase):
     def test_allocator(self):